Fix MySQL scope ENUM to unit_exam in AiQuestionBankGeneratorService and ExamController

This commit is contained in:
Hamza-Ayed
2026-09-03 16:44:37 +03:00
parent 8d7ffcf2eb
commit be4fe3dabf
2 changed files with 11 additions and 6 deletions
@@ -63,7 +63,7 @@ class AiQuestionBankGeneratorService
// Ensure Unit Exam exists in database
$exam = Database::selectOne(
"SELECT id FROM exams WHERE course_id = ? AND scope = 'unit_comprehensive' AND (title LIKE ? OR title LIKE '%الوحدة الأولى%') LIMIT 1",
"SELECT id FROM exams WHERE course_id = ? AND (scope = 'unit_exam' OR scope = 'unit_comprehensive') AND (title LIKE ? OR title LIKE '%الوحدة الأولى%') LIMIT 1",
[$courseId, "%{$unitTitle}%"]
);
@@ -71,12 +71,12 @@ class AiQuestionBankGeneratorService
if (!$examId) {
$examId = (int)Database::insert(
"INSERT INTO exams (uuid, course_id, lesson_id, creator_type, scope, title, duration_minutes, passing_percentage, total_points, is_mandatory, is_published)
VALUES (UUID(), ?, 0, 'ai_adaptive', 'unit_comprehensive', ?, 45, 70.00, 100, 1, 1)",
VALUES (UUID(), ?, 0, 'ai_adaptive', 'unit_exam', ?, 45, 70.00, 100, 1, 1)",
[$courseId, "اختبار الفهم الشامل: {$unitTitle}"]
);
} else {
Database::query(
"UPDATE exams SET title = ?, duration_minutes = 45, is_published = 1 WHERE id = ?",
"UPDATE exams SET title = ?, duration_minutes = 45, scope = 'unit_exam', is_published = 1 WHERE id = ?",
["اختبار الفهم الشامل: {$unitTitle}", $examId]
);
}