fix: Align exams creator_type enum to ai_adaptive and add fault-tolerant checkpoint generation
This commit is contained in:
@@ -48,6 +48,7 @@ class AiVideoAnalyzerService
|
|||||||
// 3. Save Socratic Checkpoints into exams, questions, question_options
|
// 3. Save Socratic Checkpoints into exams, questions, question_options
|
||||||
if (!empty($analysisResult['socratic_checkpoints'])) {
|
if (!empty($analysisResult['socratic_checkpoints'])) {
|
||||||
foreach ($analysisResult['socratic_checkpoints'] as $cp) {
|
foreach ($analysisResult['socratic_checkpoints'] as $cp) {
|
||||||
|
try {
|
||||||
$examUuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
$examUuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
||||||
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
|
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
|
||||||
mt_rand(0, 0xffff),
|
mt_rand(0, 0xffff),
|
||||||
@@ -58,7 +59,7 @@ class AiVideoAnalyzerService
|
|||||||
|
|
||||||
$examId = Database::insert(
|
$examId = Database::insert(
|
||||||
"INSERT INTO exams (uuid, course_id, lesson_id, creator_type, scope, title, timestamp_seconds, rewind_on_fail_seconds, passing_percentage, total_points, is_mandatory, is_published)
|
"INSERT INTO exams (uuid, course_id, lesson_id, creator_type, scope, title, timestamp_seconds, rewind_on_fail_seconds, passing_percentage, total_points, is_mandatory, is_published)
|
||||||
VALUES (?, ?, ?, 'system', 'in_video_checkpoint', ?, ?, ?, 100.00, 10, 1, 1)",
|
VALUES (?, ?, ?, 'ai_adaptive', 'in_video_checkpoint', ?, ?, ?, 100.00, 10, 1, 1)",
|
||||||
[
|
[
|
||||||
$examUuid,
|
$examUuid,
|
||||||
$courseId,
|
$courseId,
|
||||||
@@ -95,6 +96,9 @@ class AiVideoAnalyzerService
|
|||||||
[$qId, $optText, ($idx === $correctIdx) ? 1 : 0]
|
[$qId, $optText, ($idx === $correctIdx) ? 1 : 0]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
error_log("Checkpoint insert error: " . $e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1287,7 +1287,8 @@ class TeacherPortal
|
|||||||
alert('❌ ' + (data.message || 'فشل رفع الفيديو'));
|
alert('❌ ' + (data.message || 'فشل رفع الفيديو'));
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('❌ خطأ في معالجة استجابة السيرفر');
|
console.error('Response:', xhr.responseText);
|
||||||
|
alert('❌ خطأ في معالجة استجابة السيرفر:\n' + (xhr.responseText ? xhr.responseText.substring(0, 250) : 'استجابة فارغة'));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user