This document covers the REST API routes available in the backend, split by the resource being interacted with.
Creates a new user in the database.
None
None
Name | Type | Description |
---|---|---|
userId | string | The user's id generated by Auth0 on login. |
201
User created successfully.
400
Missing userId.
409
User already exists.
Gets the role of a user.
Name | Type | Description |
---|---|---|
userId | string | The user id of a user to get the role of. |
None
None
200
role: number
Role retrieved successfully
404 User not found.
Gets all courses from the database.
None
Name | Type | Description |
---|---|---|
limit | number | Return only this many results. 0 < limit <= 1000. Default is 100. |
offset | number | Skip this many results before returning. 0 <= offset. Default is 0 |
200
List of all courses retrieved.
[
{
"courseCode": string,
"courseName": string,
"courseDescription": string,
"university": string
}
]
Gets the information for a specific course.
Name | Type | Description |
---|---|---|
courseCode | string | Course code to get info for. |
None
None
200
Object with the course's information.
{
"courseCode": string,
"courseName": string,
"courseDescription": string,
"university": string
}
404
Course not found.
Returns all exams for a course.
Name | Type | Description |
---|---|---|
courseCode | string | Course code to get exams for. |
None
None
200
List the exams for the course.
[
{
examId: number,
examYear: number,
examSemester: number,
examType: string
}
]
404
Course not found.
Gives a star rating to a course.
Name | Type | Description |
---|---|---|
courseCode | string | Course code to rate. |
None
Name | Type | Description |
---|---|---|
starRating | number | The star rating to give the course. |
userId | string | The user id of the user giving the rating. |
200 Course rated successfully.
400 Missing star or userId, or star rating is not between 0 and 5.
404 Course not found, or user not found.
Creates a new course in the database.
None
None
Name | Type | Description |
---|---|---|
courseCode | string | The course code. |
courseName | string | The course name. |
courseDescription | string | The course description. |
university | string | The university the course is from. |
201
Course created successfully.
400
Missing courseCode, courseName, courseDescription, university, or userId.
403
User does not have permission to create a course.
409
Course already exists.
Gets the information for a specific exam.
Name | Type | Description |
---|---|---|
examId | number | The exam id |
None
None
200
Object with the exam's information.
{
examId: number,
examYear: number,
examSemester: number,
examType: string
}
404
Exam not found.
Gets the questions for an exam.
Name | Type | Description |
---|---|---|
examId | number | The exam id |
None
None
200
List of questions for the exam.
[
{
questionId: number,
questionText: string,
questionType: string,
questionPNG: string
}
]
404
Exam not found.
Creates a new exam in the database.
None
None
Name | Type | Description |
---|---|---|
examYear | number | The year the exam took place. |
examSemester | number | The semester the exam took place. |
examType | string | The type of exam. |
courseCode | string | The course code of the course the exam is for. |
userId | string | The user id of the user creating the exam. |
201
{ examId: number }
Exam created successfully.
400
Missing examYear, examSemester, examType, courseCode, or userId.
403
User does not have permission to create an exam.
404
Course not found.
Gets the information for a specific question.
Name | Type | Description |
---|---|---|
questionId | number | The question id. |
None
None
200
Object with the question's information.
{
questionId: nubmer,
questionText: string,
questionType: string,
questionPNG: string
}
404
Question not found.
Gets the comments for a question.
Name | Type | Description |
---|---|---|
questionId | number | The question id. |
Name | Type | Description |
---|---|---|
userId | string | The user id to check upvote and downvote status for. |
200
List of comments for the question.
[
{
commentId: number,
parentCommentId: number,
commentText: string,
commentPNG: string,
isCorrect: boolean,
isDeleted: boolean,
upvotes: number,
downvotes: number,
createdAt: timestamp,
updatedAt: timestamp,
upvoted: boolean,
downvoted: boolean
}
]
400
Missing userId.
404
Question not found, or user not found.
Adds a new question to the database.
None
None
The body for this request is multi-part form data.
Name | Type | Description |
---|---|---|
questionPNG | binary | The question's picture. |
questionText | string | The question's text. |
questionType | string | The type of question i.e. multiple choice. |
examId | number | The course code of the course. |
201
{ questionId: number }
Question created successfully.
400
Missing questionType, or examId.
404
Exam not found.
Edits a question.
Name | Type | Description |
---|---|---|
questionId | number | The question's id. |
None
The body for this request is multi-part form data.
Name | Type | Description |
---|---|---|
questionPNG | binary | The question's picture. |
questionText | string | The question's text. |
questionType | string | The type of question i.e. multiple choice. |
examId | number | The course code of the course. |
200
Question edited successfully.
400 No changes made.
404 Question not found.
Gets the information for a specific comment.
Name | Type | Description |
---|---|---|
commentId | number | The comment id. |
None
None
200
Object with the comment's information.
{
commentId: number,
parentCommentId: number,
commentText: string,
commentPNG: string,
isCorrect: boolean,
isDeleted: boolean,
upvotes: number,
downvotes: number,
createdAt: timestamp,
updatedAt: timestamp
}
404 Comment not found.
Adds a new comment to the database.
Name | Type | Description |
---|---|---|
commentId | number | The comment's id. |
None
The body for this request is multi-part form data.
Name | Type | Description |
---|---|---|
questionId | string | The question id the comment belongs to. |
parentCommentId | number | The parent comment id, if needed. |
commentPNG | binary | The comment's picture. |
commentText | string | The comment's text. |
userId | string | The user id of the user writing the comment. |
201
{ commentId: number }
Comment created successfully.
400
Missing questionId, commentText, or userId.
404
Question not found, or parent comment not found.
Edits a comment.
Name | Type | Description |
---|---|---|
commentId | number | The comment's id. |
None
The body for this request is multi-part form data.
Name | Type | Description |
---|---|---|
commentPNG | binary | The comment's picture. |
commentText | string | The comment's text. |
userId | string | The user id of the user writing the comment. |
200
Comment edited successfully.
400
No changes made, or no commentId or userId.
401
User does not have permission to edit the comment.
404
Comment not found.
Upvotes a comment.
Name | Type | Description |
---|---|---|
commentId | number | The comment's id. |
None
Name | Type | Description |
---|---|---|
userId | string | The user id of the user upvoting the comment. |
200
Comment upvoted successfully.
400
Missing userId.
404
Comment not found, or user not found.
Downvotes a comment.
Name | Type | Description |
---|---|---|
commentId | number | The comment's id. |
None
Name | Type | Description |
---|---|---|
userId | string | The user id of the user downvoting the comment. |
200
Comment downvoted successfully.
400
Missing userId.
404
Comment not found, or user not found.
Marks a comment as correct.
Name | Type | Description |
---|---|---|
commentId | number | The comment's id. |
None
None
200
Comment marked as correct successfully.
404
Comment not found.
Marks a comment as incorrect.
Name | Type | Description |
---|---|---|
commentId | number | The comment's id. |
None
None
200
Comment marked as incorrect successfully.
404
Comment not found.
Deletes a comment.
Name | Type | Description |
---|---|---|
commentId | number | The comment's id. |
None
Name | Type | Description |
---|---|---|
userId | string | The user id of the user deleting the comment. |
200
Comment deleted successfully.
401
User does not have permission to delete the comment.
404
Comment not found.