Quiz record. Served by CourseController::submitQuiz().{module} is route-model-bound to App\Models\Courses\Module by its primary key; the controller then checks it belongs to the same course and course version as the course log (403 otherwise). Scoring is server-side and covers the submitted questions: each key of answers must be a question of the module's quiz pool (the same set the sync download draws from), and no more keys than the module's quiz_questions may be sent, otherwise 403. A question counts as correct when its selected answer is one of its correct answers. The client never sees which answers are correct.App\Http\Controllers\Api\V1\Diver\CourseController::submitQuiz()api.v1.diver.courses.quiz.submitAuthorization: Bearer {token}POST/api/v1/diver/courses/{log_code}/modules/{module}/quizapplication/json| Parameter | Type | Description |
|---|---|---|
{log_code} | string(32) | Opaque course log code, owned by the authenticated diver |
{module} | integer | Module id, route-model-bound |
{
"answers": { "7121": 27632, "7129": 27664 },
"start": "2026-09-17T12:00:00Z",
"end": "2026-09-17T12:05:00Z"
}| Field | Type | Required | Validation | Description |
|---|---|---|---|---|
answers | object | Yes | required|array|min:1 (keys are question ids, values must each individually satisfy the rule below) | {questionId: answerId} map |
answers.* | integer | Yes | required|integer|exists:answers,id | Each value must be a real answer id; the key (question id) is checked against the module's quiz pool by the controller (403) |
start | string | Yes | required|date | Client-supplied attempt start time |
end | string | Yes | required|date|after:start | Client-supplied attempt end time |
App\Http\Requests\Api\V1\Diver\SubmitQuizRequest, which extends ApiFormRequest - the full envelope 422 shape applies (see below), not Laravel's default.total is the module's quiz_questions, so an unanswered question counts as wrong. The stored questions are the submitted keys.201 Created{
"success": true,
"status": "success",
"message": "Quiz submitted successfully",
"data": {
"id": 1582846,
"log_code": "a6b952760c2b672d2f45da6989b1a8c1",
"module_id": 463,
"total": 2,
"correct": 1,
"wrong": 1,
"score": 50,
"passed": true,
"date": "2026-09-17",
"start": "2026-09-17 12:00:00",
"end": "2026-09-17 12:05:00",
"questions": [
{
"id": 7121,
"text": "How should oxygen equipment be cleaned after use?",
"missing": false,
"answers": [
{ "id": 27632, "text": "Wipe down with a soft damp cloth", "is_correct": true, "selected": true },
{ "id": 27633, "text": "Store without cleaning", "is_correct": false, "selected": false }
]
},
{
"id": 7129,
"text": "When should a cylinder be visually inspected?",
"missing": false,
"answers": [
{ "id": 27663, "text": "Once a year", "is_correct": true, "selected": false },
{ "id": 27664, "text": "Never", "is_correct": false, "selected": true }
]
}
]
}
}QuizResultResource shape as GET_quiz_results.md - see _resources.md → "Quiz result". passed is correct >= module.quiz_minimum, not a percentage threshold.401 Unauthorized{
"success": false,
"status": "error",
"message": "Unauthenticated"
}403 Forbidden - module/course log mismatch{module} does not belong to the same course and course version as {log_code}.{
"success": false,
"status": "error",
"message": "Forbidden"
}403 Forbidden - answers outside the module quizanswers is not a question of the module's quiz pool, or when more keys than the module's quiz_questions are sent. Nothing is written.{
"success": false,
"status": "error",
"message": "Forbidden"
}403 Forbidden - quiz locked{
"success": false,
"status": "error",
"message": "Quiz is locked. Contact your instructor."
}log.admin_lock or log.quiz_lock is set.403 Forbidden - repetition{
"success": false,
"status": "error",
"message": "Quiz is not available for a repetition."
}404 Not Found - course log not found{log_code} does not resolve to a course log owned by the authenticated user. Resolved manually in the controller body, so this is only reached once route-model binding for {module} has already succeeded.{
"message": "No query results for model [App\\Models\\CourseLog\\CourseLog]."
}404 Not Found - module not found{module} is route-model-bound; this fires before the controller body runs at all, including before SubmitQuizRequest validation. Confirmed live: unlike the CourseLog 404 above, route-model binding's NotFoundHttpException includes the id that was looked up.{
"message": "No query results for model [App\\Models\\Courses\\Module] 999999999"
}409 Conflict - attempt already submittedstart was already submitted for this log and module: the same attempt sent twice, for example a retry. Nothing is written and the log is not locked. Another attempt, with a different start, is always accepted: there is no limit on the number of attempts.{
"success": false,
"status": "error",
"message": "Attempt already submitted."
}422 Unprocessable Entity - validation{
"success": false,
"status": "error",
"message": "Validation failed",
"errors": {
"answers": ["The answers field is required."],
"start": ["The start field is required."],
"end": ["The end field is required."]
}
}success, status present) because SubmitQuizRequest extends ApiFormRequest, unlike endpoints that call $request->validate() inline.Quiz row.CourseLog::checkQuizResults($module) (app/Models/CourseLog/CourseLog.php:488-503), which counts this module's failed Quiz rows for the log and sets quiz_lock = true (without admin_lock and without an admin_lock_comment) once the count reaches option('max_failed_quiz_before_lock', 10). A diver can be locked out by repeated failures: the next attempt after the threshold hits the 403 Forbidden - quiz locked case already documented.UserQuizCompleted mail is queued to the instructor (cc the dive center when it has an email). A failure to queue it is reported and does not affect the response.start / end are entirely client-supplied and not cross-checked against server time - they are stored as given.docs/api/diver/courses/POST_quiz_submit.mdcurl --location 'https://test.diveraid.com/api/v1/diver/courses//modules//quiz' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"answers": {
"property1": 0,
"property2": 0
},
"start": "2019-08-24T14:15:22.123Z",
"end": "2019-08-24T14:15:22.123Z"
}'{
"status": "success",
"message": "string",
"data": {
"id": 0,
"log_code": "string",
"module_id": 0,
"total": 0,
"correct": 0,
"wrong": 0,
"score": 0,
"passed": true,
"date": "2019-08-24",
"start": "2019-08-24T14:15:22.123Z",
"end": "2019-08-24T14:15:22.123Z",
"questions": [
{
"id": 0,
"text": "string",
"missing": true,
"answers": [
{
"id": 0,
"text": "string",
"is_correct": true,
"selected": true
}
]
}
]
}
}