Implement verified curriculum, video review, watch sessions, ledger safeguards, and remove demo data

This commit is contained in:
Hamza-Ayed
2026-09-09 17:04:08 +03:00
parent 0dc5df7b5e
commit 5af684a892
49 changed files with 1809 additions and 3005 deletions
+2 -46
View File
@@ -424,18 +424,7 @@ class ExamController
/** Additive production migration for installations created before completed_at. */
private static function ensureAttemptSchema(): void
{
try {
$column = Database::selectOne(
"SELECT COUNT(*) AS cnt FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'exam_attempts'
AND COLUMN_NAME = 'completed_at' LIMIT 1"
);
if (empty($column['cnt'])) {
Database::query("ALTER TABLE exam_attempts ADD COLUMN completed_at TIMESTAMP NULL DEFAULT NULL AFTER ai_diagnostic_report");
}
} catch (\Throwable $e) {
error_log('Exam schema migration note: ' . $e->getMessage());
}
// Kept for compatibility with callers. Schema is installed by migrations.
}
/**
@@ -484,40 +473,7 @@ class ExamController
*/
public static function ensureSchema(): void
{
try {
Database::query(
"CREATE TABLE IF NOT EXISTS `student_question_answers` (
`id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`attempt_id` BIGINT UNSIGNED NOT NULL,
`student_id` BIGINT UNSIGNED NOT NULL,
`question_id` BIGINT UNSIGNED NOT NULL,
`selected_option_id` BIGINT UNSIGNED NULL,
`is_correct` TINYINT(1) NOT NULL DEFAULT 0,
`points_awarded` DECIMAL(5, 2) NOT NULL DEFAULT 0.00,
`time_spent_seconds` INT UNSIGNED NOT NULL DEFAULT 0,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
KEY `idx_sqa_attempt` (`attempt_id`),
KEY `idx_sqa_student` (`student_id`),
KEY `idx_sqa_question` (`question_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
);
// Ensure completed_at in exam_attempts
$colCheck = Database::selectOne(
"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'exam_attempts' AND COLUMN_NAME = 'completed_at' LIMIT 1"
);
if (!$colCheck) {
Database::query("ALTER TABLE exam_attempts ADD COLUMN completed_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP AFTER ai_diagnostic_report");
}
// Safely ensure scope ENUM covers unit_comprehensive if ever passed
try {
Database::query("ALTER TABLE exams MODIFY COLUMN scope ENUM('in_video_checkpoint', 'lesson_exam', 'unit_exam', 'unit_comprehensive', 'semester_final') NOT NULL DEFAULT 'in_video_checkpoint'");
} catch (\Throwable $ign) {}
} catch (\Throwable $e) {
error_log("ExamController ensureSchema notice: " . $e->getMessage());
}
// Kept for compatibility with callers. Schema is installed by migrations.
}
/**