Quiz API - masai-oss/Masai_Refresh GitHub Wiki
GET /api/topic/summary
PARAMS
- Header:
Authorization: Bearer <Token>
RESPONSE
last attempt data will only be present if proficiency consist of data
Success : (Status Code: 200)
{
"error": false,
"data": [
{
"_id": "603fab1ce066580e7f71b0f2",
"name": "HTML",
"icon":"./path",
"proficiency":{
"alloted": 85,
"correct" : 5,
"wrong" : 5,
"skipped" : 5,
},
"lastAttempt": { // last attempt data will only be present if proficiency consist of data
"alloted": 5,
"skipped": 2,
"correct": 0,
"wrong": 3,
"time": 0
}
"totalNoOfQuestions": 10
},
{
"_id": "603fab2de066580e7f71b0f3",
"name": "DS_ALGO",
"icon":"./path",
"proficiency":{
"alloted": 85,
"correct" : 5,
"wrong" : 5,
"skipped" : 5,
},
"lastAttempt": {
"alloted": 5,
"skipped": 2,
"correct": 0,
"wrong": 3,
"time": 0
}
"totalNoOfQuestions": 10
},
{
"_id": "603fab3ae066580e7f71b0f4",
"name": "CSS",
"icon":"./path",
"proficiency":{
"alloted": 85,
"correct" : 5,
"wrong" : 5,
"skipped" : 5,
},
"lastAttempt": {
"alloted": 5,
"skipped": 2,
"correct": 0,
"wrong": 3,
"time": 0
}
"totalNoOfQuestions": 10
},
{
"_id": "603fabc06ce2880fd2936475",
"name": "REACT",
"icon":"./path",
"proficiency":{
"alloted": 85,
"correct" : 5,
"wrong" : 5,
"skipped" : 5,
},
"lastAttempt": {
"alloted": 5,
"skipped": 2,
"correct": 0,
"wrong": 3,
"time": 0
}
"totalNoOfQuestions": 10
},
{
"_id": "603fb0b31eceff17197a18cf",
"name": "EXPRESS",
"icon":"./path",
"proficiency":[],
"totalNoOfQuestions": 0
}
]
}
Failure : (Status Code: 400)
{
error: true,
message: "Something Went Wrong",
reason: err,
}
POST /api/attempt/create
PARAMS (Start Quiz)
- Header:
Bearer <Token>
- Body:
{
"topic_id": "6047278673ec24bb3b12ebfd",
"size": 10 // default is 5. If only 5 is required, size is not required
}
RESPONSE
Success : (Status Code: 200)
{
"error": false,
"data": {
"questions": [
"6047cbdb791203d645acb097",
"6047cbdb791203d645acb094",
"6047cbdb791203d645acb070",
"6047cbdb791203d645acb05f",
"6047cbdb791203d645acb07c",
"6047cbdb791203d645acb073",
"6047cbdb791203d645acb061",
"6047cbdb791203d645acb093",
"6047cbdb791203d645acb099",
"6047cbdb791203d645acb08b"
],
"attempt_id": "6048b70214799d9df0442bc3",
"submission_id": "60471ea5e8017b0654fef615"
}
}
Failure : (Status code: 400)
If wrong Topic ID is sent in body
{
"error": true,
"message": {}
}
GET /api/attempt/question?attempt_id=<attempt_id>&submission_id=<submission_id>&question_id=<question_id>
- Header:
Bearer <Token>
- Query Params:
-
<attempt_id>
-
<submission_id>
-
<question_id>
-
RESPONSE
Success : (Status Code: 200)
{
"error": false,
"data": {
"id": "60525eb19d5730ea1acd6a0c",
"type": "MCQ",
"statement": "A JavaScript program can traverse and manipulate document content through __________",
"options": [
{
"text": "Element Object"
},
{
"text": "Document Object"
},
{
"text": "Both Element and Document Object"
},
{
"text": "Data object"
}
],
"isStatsUpdated": false,
"selected": 3
}
}
Failure : (Status code: 400) - If all the questions for the quiz is exhausted
{
"error": true,
"message": "Error: The Practice quiz has ended."
}
PATCH /api/attempt/record
PARAMS
- Header:
Bearer <Token>
- Body:
{
"submission_id": "60527af38a9cc80a08424d80",
"attempt_id": "60527af38a9cc80a08424d81",
"question_id": "60525eb19d5730ea1acd6a10",
"answer_type" : "MCQ",
"response" : "something", // short => -1 is not recorded. Note: This is for SHORT type questions
"selected" : 2, // Number => -1 if not recorded // Need only the index of the selected answer. Note: This is for MCQ type questions
"decision" : false // boolean => -1 if not recorded. Note: This is for T/F type questions
}
RESPONSE
Success : (Status Code: 200)
{
"error": false,
"message": "Record updated"
}
Failure : (Status code: 400) - is isStatsUpdated is updated to true
{
"error": true,
"message": "Error: The Practice Quiz has ended"
}
GET /api/attempt/result/:attempt_id
PARAMS
- Header:
Bearer Token
- PARAMS:
attempt_id
RESPONSE
Success : (Status Code: 200)
{
error: false,
result:[
{
"question_id" : "60525eb19d5730ea1acd6a0c"
"statement" : one of (MCQ || TF || SHORT) Question,
"outcome" : (skipped/correct/wrong), "for MCQ || TF || SHORT"
"correct" : "answer", "for MCQ || TF || SHORT"
"response" : "User Response for SHORT || TF || MCQ if skipped will get Skipped",
"explanation" : "explanation of the answer"
"source": "website"
}
]
}
Failure : (Status code: 400)
{
error: true,
message: "Something Went Wrong",
reason: err,
}