-
Notifications
You must be signed in to change notification settings - Fork 4
Question CRUD (Admin)
- Short Question
{
"type":"SHORT",
"statement":"What is the difference between `canvas` and `svg`?",
"answer":"* SVG has better scalability. So it can be printed with high quality at any resolution.\n* Canvas has poor scalability.
Hence it is not suitable for printing on the higher resolution",
"explanation": ""
}
- TF Question
{
"type": "TF",
"statement": "`JSON.parse();` Parses JSON to a JavaScript value",
"explanation": "Parses JSON to a JavaScript value",
"correct": true
}
- MCQ Question
{
"type": "MCQ",
"statement": "What will be the output of the following JavaScript code? \n```javascript \n[1, 2, 3].map(num => { \nif (typeof num ===
'number') return; \nreturn num * 2;});\n```",
"explanation": "The above code snippet returns undefined.",
"options": [
{
"text": "Prints the contents of each property of o",
"correct": false
},
{
"text": "Returns undefined",
"correct": true
},
{
"text": "Prints only one property",
"correct": false
},
{
"text": "Prints the address of elements",
"correct": false
}
]
}
- LONG Question
{
"type": "LONG",
statement: "What are the possible ways to create objects in JavaScript"
answer: "There are many ways to create objects in javascript as 1. **Ob..."
}
POST /api/question/create/:topic
PARAMS
- Header:
Bearer Token
- Params:
Topic
- Body:
Any One of Question Structure (MCQ || TF || SHORT)
RESPONSE
Success : (Status Code: 200)
{
error: false,
message: "Question added Successfully"
}
Failure : (Status code: 400)
{
error: true,
message: "Something Went Wrong",
reason: err,
}
GET /api/question/all/?page=1&limit=5&reportedFilter=false&disabledFilter=false
PARAMS
- Header:
Bearer Token
- Query:
page, limit, reportedFilter, disabledFilter
- Default Values:
page = 1, limit = 10, reportedFilter = false, disabledFilter = false
RESPONSE
Success : (Status Code: 200)
{
"error": false,
"message": "Successfully got Questions",
"questions": {
"limit": 1,
"totalCount": 4,
"maxPage": 4,
"currentPage": 2,
"next": {
"page": 3,
"limit": 1
},
"prev": {
"page": 1,
"limit": 1
},
"current": [
{
"stats": {
"alloted": 0,
"skipped": 0,
"correct": 0,
"wrong": 0
},
"type":"SHORT",
"statement":"What is the difference between `canvas` and `svg`?",
"answer":"* SVG has better scalability. So it can be printed with high quality at any resolution.\n*
Canvas has poor scalability. Hence it is not suitable for printing on the higher resolution",
"explanation": "",
"id": "928b2308-0868-4b6b-b538-048d8be31c20",
"topic": "HTML"
}
]
}
}
Failure : (Status code: 400)
{
error: true,
message: "Something Went Wrong",
reason: err,
}
GET /api/question/byTopic/:topic/?page=1&limit=10&reportedFilter=false&disabledFilter=false
- Get all Question in the Topic
PARAMS
- Header:
Bearer Token
- Params:
topic
- Query:
page, limit, reportedFilter, disabledFilter
- Default Values:
page = 1, limit = 10, reportedFilter = false, disabledFilter = false
RESPONSE
Success : (Status Code: 200)
{
error: false,
message: "Question found successfully",
question: question(SHORT && TF && MCQ && LONG)
}
Failure : (Status code: 400)
{
error: true,
message: "Something Went Wrong",
reason: err,
}
GET /api/question/byId/:type/:id
PARAMS
- Header:
Bearer Token
- Params:
type, Id
RESPONSE
Success : (Status Code: 200)
{
error: false,
message: "Question found successfully",
question: question(SHORT || TF || MCQ || LONG)
}
Failure : (Status code: 400)
{
error: true,
message: "Something Went Wrong",
reason: err,
}
PATCH /api/question/toggleVerify/:type/:id
- Header:
Bearer <Token>
- Params:
type, id
RESPONSE
Success : (Status Code: 200)
{
"error": true,
"message": "The toggle of verification has been successful",
"data": {
"verified": false
}
}
Failure : (Status code: 400) - wrong question_id
{
"error": true,
"message": "CastError: Cast to ObjectId failed for value \"60526164d01862ed1350bfe\" at path \"_id\" for model \"topics\""
}
PATCH api/question/toggleDisable/:type/:id
PARAMS
- Header:
Bearer Token
- Params:
type, id
RESPONSE
Success : (Status Code: 200)
{
"error": false,
"message": "successful",
"data": {
"disabled": true
}
}
Failure : (Status code: 400)
{
"error": true,
"message": err
}
PATCH /api/question/update/:topic/:id
PARAMS
- Header:
Bearer Token
- Params:
topic
- Body:
Any One of Question Structure (MCQ || TF || SHORT) and should pass the stats
Success : (Status Code: 200)
{
error: false,
message: " `Topic` Question updated Successfully"
question: question(SHORT || TF || MCQ)
}
Failure : (Status code: 400)
{
error: true,
message: "Something Went Wrong",
reason: err,
}