fix: populate questions and options tables, scale AI chapters/checkpoints to video duration, open student lesson discovery
This commit is contained in:
@@ -312,10 +312,10 @@ class VideoController
|
||||
$lessons = Database::select(
|
||||
"SELECT l.id, l.course_id, l.title, l.sequence_order, l.storage_type, l.video_uuid, l.hls_url, l.thumbnail_url,
|
||||
l.duration_seconds, l.is_free_preview, l.created_at,
|
||||
c.title as course_title,
|
||||
COALESCE(c.title, 'توجيهي 2008 — المنهاج المعتمد') as course_title,
|
||||
(SELECT COUNT(*) FROM exams WHERE lesson_id = l.id AND scope = 'in_video_checkpoint') as checkpoints_count
|
||||
FROM lessons l
|
||||
JOIN courses c ON l.course_id = c.id
|
||||
LEFT JOIN courses c ON l.course_id = c.id
|
||||
{$where}
|
||||
ORDER BY l.id DESC"
|
||||
);
|
||||
@@ -354,9 +354,10 @@ class VideoController
|
||||
|
||||
$lessonId = (int)$lesson['id'];
|
||||
|
||||
// If lesson has no checkpoints yet, generate them autonomously
|
||||
// If lesson has no checkpoints or missing questions, generate them autonomously
|
||||
$existingCount = Database::selectOne("SELECT COUNT(*) as cnt FROM exams WHERE lesson_id = ? AND scope = 'in_video_checkpoint'", [$lessonId]);
|
||||
if (empty($existingCount['cnt'])) {
|
||||
$existingQuestions = Database::selectOne("SELECT COUNT(*) as cnt FROM questions q JOIN exams e ON q.exam_id = e.id WHERE e.lesson_id = ?", [$lessonId]);
|
||||
if (empty($existingCount['cnt']) || empty($existingQuestions['cnt'])) {
|
||||
AiVideoAnalyzerService::processLessonAutonomously($lessonId);
|
||||
$lesson = Database::selectOne("SELECT * FROM lessons WHERE id = ? LIMIT 1", [$lessonId]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user