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 -47
View File
@@ -28,56 +28,11 @@ class CurriculumService
}
/**
* Runtime migration: add is_system_curriculum (and related columns) to `courses`
* if they are missing. Safe to call multiple times — uses IF NOT EXISTS / IGNORE.
* Compatibility hook. Course schema is managed by migrations, never by requests.
*/
public static function ensureSystemCurriculumColumn(): void
{
static $ran = false;
if ($ran) return;
$ran = true;
try {
// Check whether the column exists to avoid noisy ALTER errors on every request
$row = Database::selectOne(
"SELECT COUNT(*) as cnt FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'courses'
AND COLUMN_NAME = 'is_system_curriculum'
LIMIT 1"
);
if (empty($row['cnt'])) {
Database::query(
"ALTER TABLE `courses`
ADD COLUMN `is_system_curriculum` TINYINT(1) NOT NULL DEFAULT 0
COMMENT 'الدورة الرئيسية للمنهاج الوزاري'
AFTER `is_school_exclusive`"
);
}
// Also ensure grade_level + stream columns exist (for student filtering)
$gradeRow = Database::selectOne(
"SELECT COUNT(*) as cnt FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'courses'
AND COLUMN_NAME = 'grade_level'
LIMIT 1"
);
if (empty($gradeRow['cnt'])) {
Database::query(
"ALTER TABLE `courses`
ADD COLUMN `grade_level` VARCHAR(50) DEFAULT NULL
COMMENT 'المرحلة الدراسية مثل: tawjihi_2008'
AFTER `is_system_curriculum`,
ADD COLUMN `stream` ENUM('scientific','literary','vocational','general') DEFAULT NULL
COMMENT 'الفرع الدراسي'
AFTER `grade_level`"
);
}
} catch (\Throwable $e) {
error_log('[CurriculumService] ensureSystemCurriculumColumn error: ' . $e->getMessage());
}
// Intentionally empty. Run backend/scripts/run_migrations.php before serving.
}
/**