Add quiz support: parse *_quiz_solved.txt files, take and grade quizzes

Scanner indexes quiz files found next to videos ([&] questions, "- "
options, "-- Correct" markers; _notsolved twins ignored). Quizzes appear
in the folder content list interleaved with videos by filename order.
New api/quiz.php serves questions without answers and grades attempts
server-side; per-user best/last score and attempts stored in
quiz_progress. Folder/course progress now aggregates videos + quizzes
with partial credit for partial scores.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Harwinder Sekhon
2026-07-11 11:24:37 -04:00
parent aba6ef4734
commit deda7c3c18
7 changed files with 467 additions and 28 deletions
+16
View File
@@ -24,6 +24,7 @@ function videoSummary(array $v): array
return [
'id' => (int)$v['id'],
'name' => $v['name'],
'filename' => $v['filename'],
'duration' => $duration !== null ? (float)$duration : null,
'position' => $position,
'completed' => (bool)($v['completed'] ?? false),
@@ -31,6 +32,19 @@ function videoSummary(array $v): array
];
}
function quizSummary(array $q): array
{
return [
'id' => (int)$q['id'],
'name' => $q['name'],
'filename' => $q['filename'],
'questions' => (int)$q['num_questions'],
'attempts' => (int)($q['attempts'] ?? 0),
'best_score' => (int)($q['best_score'] ?? 0),
'completed' => (bool)($q['completed'] ?? false),
];
}
function crumbList(array $folder): array
{
return array_map(
@@ -70,6 +84,8 @@ switch ($view) {
childFolders((int)$folder['id'])),
'videos' => array_map('videoSummary',
folderVideos((int)$folder['id'], $userId)),
'quizzes' => array_map('quizSummary',
folderQuizzes((int)$folder['id'], $userId)),
]);
break;