This module is responsible for handling all question related requests
The following routes are handled by this module::
POST /question/new - Add a new question to a particular exercise
GET /question/:id - Get a particular question
PATCH /question/update/:id - Update a particular question
DELETE /question/delete/:id - Delete a particular question
Requires
- module:../models/course.models
- module:../utils/errors
Methods
# static createQuestion(question, correct_answer, options, exercise_id) → {MongooseObject}
Create a new question for a particular exercise
Parameters:
Name | Type | Description |
---|---|---|
question |
string
|
|
correct_answer |
string
|
|
options |
Array
|
|
exercise_id |
string
|
if an error occured
error
savedQuestion
MongooseObject
# static deleteQuestion(id)
Delete a particular questions
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
Id of the question |
if an error occured
error
# static getQuestionData(id) → {Object}
Returns the question and it's options
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
id of question |
if missing required param in request
BadRequestError
if question not found
NotFoundError
question
Object
# static getQuestions(exercise_id, _id, correct_option) → {ArrayObject}
By default it gets all available questions, if req.body is provided it'll be used as query params to make a more streamlined query result
Parameters:
Name | Type | Description |
---|---|---|
exercise_id |
string
|
Course id |
_id |
string
|
questions id |
correct_option |
string
|
Correct option to question ['A', 'B', 'C' ...] |
if an error occured
error
Questions
ArrayObject
# static updateQuestion(id) → {MongooseObject}
Update Question data
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
Id of the question |
if question not found //TODO: Add feat to handle updating options and correct option
NotFoundError
- question
MongooseObject