exam

package
v0.0.0-...-181bd5f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2023 License: MIT Imports: 4 Imported by: 0

README

Exam

Get all Exams

  • HTTP Request : GET http://api.com/exam

  • Return a list of object in json format as follow

        [
    		{
    			"id"       :	ObjectId,
    			"classid"   :	ObjectId,
    			"title"     :	String
    		}...
    	]
    

Get all Exams from a class

  • HTTP Request : GET http://api.com/exam/{classid}

  • Return a list of object in json format as follow

        [
    		{
    			"id"       :	ObjectId,
    			"classid"   :	ObjectId,
    			"title"     :	String
    		}...
    	]
    

Create Exams

  • HTTP Request : POST http://api.com/exam

  • Send exams's data in the request body in the following format

        [
    		{
    			"classid"   :	ObjectId,
    			"title"     :	String
    		}...
    	]
    
  • http StatusCreated (201) will be sent if the student has been created correctly

Update Exams

  • HTTP Request : PUT http://api.com/exam

  • Send data in the request body in the following format

        [
    		{
    			"id"       :	ObjectId,
    			"classid"   :	ObjectId,
    			"title"     :	String
    		}...
    	]
    
  • http StatusCreated (201) will be sent if the student has been updated correctly

Delete Exams

  • HTTP Request : DELETE http://api.com/exam

  • Send data in the request body in the following format

    	[
    		{  
    			"id" : ObjectId
    		},...
    	]
    
  • http StatusOK (200) will be sent if the students have been deleted correctly

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateExams

func CreateExams(db *mongo.Client, exams []ExamCreate, databaseName, collectionName string) error

CreateExams receive a list of exams Checks if that list is not null (can't insert null list) Insert each exams individually in database @param db pointer to database @param exams list of exams @param databaseName name of database @param collectionName name of collection @return error function error TODO : Insert all exams at the same time (if possible)

func DeleteExams

func DeleteExams(db *mongo.Client, exams []Exam, databaseName, collectionName string) error

DeleteExams recieve a list of exams (to be deleted) Checks if that list is not null (can't delete null list) Delete each exam individually @param db pointer to database (to be deleted) @param exams list of exams @param databaseName name of database @param collectionName name of collection @return error function error TODO : Delete all exams at the same time (if possible)

func UpdateExams

func UpdateExams(db *mongo.Client, exams []Exam, databaseName, collectionName string) error

UpdateExams receive list of exams (updated) Checks if exams old password matches with db to update that exams password or email @param db pointer to database (updated) @param exams list of exams @param databaseName name of database @param collectionName name of collection @return error function error

Types

type Exam

type Exam struct {
	ID      primitive.ObjectID `bson:"_id,omitempty"`
	ClassID primitive.ObjectID `bson:"classid,omitempty"`
	Title   string             `json:"title"`
}

Exam contains all exam data

func GetExams

func GetExams(db *mongo.Client, databaseName, collectionName string) ([]Exam, error)

GetExams return list of all exams from Database Get all exams at the same time and store inside cursor Decode each exam inside exam class and append into exams array @param db pointer to database @param databaseName name of database @param collectionName name of collection @return []Exam list of all exams @return error function error

func GetExamsClass

func GetExamsClass(db *mongo.Client, classID primitive.ObjectID, databaseName, collectionName string) ([]Exam, error)

GetExamsClass return list of all exams from a current class Get class id to filter in mongodb @param db pointer to database @param classID class ID @param databaseName name of database @param collectionName name of collection @return []Exam list of all exams that match with the given class id @return error function error

type ExamCreate

type ExamCreate struct {
	ClassID primitive.ObjectID `bson:"classid,omitempty"`
	Title   string             `json:"title"`
}

Exam contains all exam data excepted from ID

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL