-
URL
/api/quizzes
-
Method:
GET
-
URL Params
Required:
There are no required URL params
-
Success Response:
- Code: 200
Content:
- Code: 200
{
"message": "Quizzes retrieved",
"data": [
{
"id": 1,
"name": "Example",
"description": "An example quiz"
}
]
}
-
URL
/api/quizzes/{id}
-
Method:
GET
Example:
/api/quizzes/1
-
Success Response:
- Code: 200
Content:
- Code: 200
{
"message": "Quiz retrieved",
"data": {
"id": 1,
"name": "Example",
"description": "An example quiz",
"questions": [
{
"id": 1,
"question": "What is the S in SOLID?",
"hint": "Hmmmmm",
"points": 2,
"answers": [
{
"id": 1,
"answer": "Single Responsibility Principle",
"feedback": "fake feedback",
"correct": 1
},
{
"id": 2,
"answer": "Separation of concerns",
"feedback": "fake feedback",
"correct": 0
}
]
},
{
"id": 2,
"question": "What is DI short for?",
"hint": "Check notes",
"points": 1,
"answers": [
{
"id": 3,
"answer": "Dependency inclusion",
"feedback": "fake feedback",
"correct": 0
},
{
"id": 5,
"answer": "Dependency Injection",
"feedback": "fake feedback",
"correct": 1
}
]
}
]
}
}
-
Error Response:
- Code: 404 NOT FOUND
Content:{"message": "Quiz not found"}
- Code: 404 NOT FOUND
-
URL
/api/quizzes
-
Method:
POST
-
Body Data
Must be sent as JSON with the correct headers
Required:
{ "name": "string", "description": "string" }
Optional:
There is no optional body data
Example:
/api/quizzes
-
Success Response:
- Code: 201 CREATED
Content:
{"message": "Quiz created"}
- Code: 201 CREATED
-
-
Error Response:
- Code: 500 INTERNAL SERVER ERROR
Content:{ "message": "Quiz creation failed" }
- Code: 422 UNPROCESSABLE CONTENT
Content:
{ "message": "The name field is required. (and 1 more error)", "errors": { "name": [ "The name field is required." ], "description": [ "The description field is required." ] } }
- Code: 500 INTERNAL SERVER ERROR
-
URL
/api/quizzes/{id}
-
Method:
PUT
-
Body Data
Must be sent as JSON with the correct headers
Required:
{ "name": "string", "description": "string" }
Optional:
There is no optional body data
Example:
/api/quizzes/1
-
Success Response:
- Code: 201 CREATED
Content:
{"message": "Quiz created"}
- Code: 201 CREATED
-
-
Error Response:
- Code: 404 NOT FOUND
Content:
{ "message": "Quiz not found" }
- Code: 422 UNPROCESSABLE CONTENT
Content:
{ "message": "The name field is required. (and 1 more error)", "errors": { "name": [ "The name field is required." ], "description": [ "The description field is required." ] } }
- Code: 500 INTERNAL SERVER ERROR
Content:{ "message": "Quiz editing failed" }
- Code: 404 NOT FOUND
-
URL
/api/questions
-
Method:
POST
-
Body Data
Must be sent as JSON with the correct headers
Required:
{ "question": "string", "points": integer, "quiz_id": integer }
Optional:
{ "hint": "string" }
Example:
/api/questions
-
Success Response:
- Code: 201 CREATED
Content:
{"message": "Question created"}
- Code: 201 CREATED
-
-
Error Response:
- Code: 500 INTERNAL SERVER ERROR
Content:{ "message": "Question creation failed" }
- Code: 422 UNPROCESSABLE CONTENT
Content:
{ "message": "The question field is required. (and 2 more errors)", "errors": { "question": [ "The question field is required." ], "points": [ "The points field is required." ], "quiz_id": [ "The quiz id field is required." ] } }
- Code: 500 INTERNAL SERVER ERROR
-
URL
/api/questions/{id}
-
Method:
PUT
-
Body Data
Must be sent as JSON with the correct headers
Required:
{ "question": "string", "points": integer, }
Optional:
{ "hint": "string" }
Example:
/api/questions/1
-
Success Response:
- Code: 200 SUCCESS
Content:
{"message": "Question edited"}
- Code: 200 SUCCESS
-
-
Error Response:
- Code: 404 NOT FOUND
Content:
{ "message": "Question not found" }
- Code: 422 UNPROCESSABLE CONTENT
Content:
{ "message": "The question field is required. (and 1 more error)", "errors": { "question": [ "The question field is required." ], "points": [ "The points field is required." ] } }
- Code: 500 INTERNAL SERVER ERROR
Content:{ "message": "Question editing failed" }
- Code: 404 NOT FOUND
-
URL
/api/questions/{id}
-
Method:
DELETE
Example:
/api/questions/1
-
Success Response:
- Code: 200 OK
Content:
{"message": "Question deleted"}
- Code: 200 OK
-
Error Response:
- Code: 404 NOT FOUND
Content:{"message": "Question not found"}
- Code: 404 NOT FOUND
-
URL
/api/answers
-
Method:
POST
-
Body Data
Must be sent as JSON with the correct headers
Required:
{ "answer": "string", "correct": boolean, "question_id": integer }
Optional:
There is no optional body data
Example:
/api/answers
-
Success Response:
- Code: 201 CREATED
Content:
{"message": "Answer created"}
- Code: 201 CREATED
-
-
Error Response:
- Code: 500 INTERNAL SERVER ERROR
Content:{ "message": "Answer creation failed" }
- Code: 422 UNPROCESSABLE CONTENT
Content:
{ "message": "The answer field is required. (and 2 more errors)", "errors": { "answer": [ "The answer field is required." ], "correct": [ "The correct field is required." ], "question_id": [ "The question id field is required." ] } }
- Code: 500 INTERNAL SERVER ERROR
-
URL
/api/answers/{id}
-
Method:
PUT
-
Body Data
Must be sent as JSON with the correct headers
Required:
{ "answer": "string", "correct": boolean, }
Optional:
There is no optional body data
Example:
/api/answers/1
-
Success Response:
- Code: 200 SUCCESS
Content:
{"message": "Answer edited"}
- Code: 200 SUCCESS
-
-
Error Response:
- Code: 404 NOT FOUND
Content:
{ "message": "Answer not found" }
- Code: 422 UNPROCESSABLE CONTENT
Content:
{ "message": "The question field is required. (and 1 more error)", "errors": { "question": [ "The question field is required." ], "points": [ "The points field is required." ] } }
- Code: 500 INTERNAL SERVER ERROR
Content:{ "message": "Answer editing failed" }
- Code: 404 NOT FOUND
-
URL
/api/answers/{id}
-
Method:
DELETE
Example:
/api/answers/1
-
Success Response:
- Code: 200 OK
Content:
{"message": "Answer deleted"}
- Code: 200 OK
-
Error Response:
- Code: 404 NOT FOUND
Content:{"message": "Answer not found"}
- Code: 404 NOT FOUND
-
URL
/api/scores
-
Method:
POST
-
Body Data
Must be sent as JSON with the correct headers
Required:
{ "quiz": integer, "answers": [ { "question": "integer", "answer": integer } ] }
Answers array must contain an object to represent each question/answer, including the id of the question and the id of the answer selected
Optional:
There is no optional body data
Example:
/api/scores
-
Success Response:
- Code: 200 SUCCESS
Content:
{ "message": "Score calculated", "data": { "question_count": integer, "correct_count": integer, "available_points": integer, "points": integer } }
- Code: 200 SUCCESS
-
-
Error Response:
- Code: 422 UNPROCESSABLE CONTENT
Content:
{ "message": "The quiz field is required. (and 1 more error)", "errors": { "quiz": [ "The quiz field is required." ], "answers": [ "The answers field is required." ] } }
- Code: 422 UNPROCESSABLE CONTENT