package
0.0.0-20230509074126-181bd5fcb334
Repository: https://github.com/apc-unb/apc-api.git
Documentation: pkg.go.dev
# 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
# Functions
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).
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).
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.
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.
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.