Fix student grade registration: set grade_10 as default, add auto-heal for legacy tawjihi_2008, add student grade selector and update-grade API
This commit is contained in:
@@ -520,15 +520,20 @@ class VideoController
|
||||
CurriculumService::ensureSchema();
|
||||
|
||||
$curriculumKey = trim((string)($request->getQuery('curriculum_key') ?? ''));
|
||||
$curriculumKeyNoExt = preg_replace('/\.md$/i', '', $curriculumKey);
|
||||
$rawId = $curriculumKey !== '' ? $curriculumKey : ($request->getParam('id') ?? '');
|
||||
$lesson = null;
|
||||
|
||||
if ($curriculumKey !== '') {
|
||||
$lesson = Database::selectOne("SELECT * FROM lessons WHERE curriculum_key = ? LIMIT 1", [$curriculumKey]);
|
||||
$lesson = Database::selectOne(
|
||||
"SELECT * FROM lessons WHERE curriculum_key = ? OR curriculum_key = ? OR local_path LIKE ? OR markdown_content LIKE ? LIMIT 1",
|
||||
[$curriculumKey, $curriculumKeyNoExt, '%' . $curriculumKeyNoExt . '%', '%' . $curriculumKeyNoExt . '%']
|
||||
);
|
||||
} elseif (is_numeric($rawId) && (int)$rawId > 0) {
|
||||
$lesson = Database::selectOne("SELECT * FROM lessons WHERE id = ? LIMIT 1", [(int)$rawId]);
|
||||
} elseif (!empty($rawId)) {
|
||||
$lesson = Database::selectOne("SELECT * FROM lessons WHERE curriculum_key = ? OR title LIKE ? OR local_path LIKE ? OR markdown_content LIKE ? LIMIT 1", [$rawId, "%{$rawId}%", "%{$rawId}%", "%{$rawId}%"]);
|
||||
$rawIdNoExt = preg_replace('/\.md$/i', '', $rawId);
|
||||
$lesson = Database::selectOne("SELECT * FROM lessons WHERE curriculum_key = ? OR curriculum_key = ? OR title LIKE ? OR local_path LIKE ? OR markdown_content LIKE ? LIMIT 1", [$rawId, $rawIdNoExt, "%{$rawId}%", "%{$rawIdNoExt}%", "%{$rawIdNoExt}%"]);
|
||||
// Flutter curriculum lessons use the manifest slug (e.g. u1_l1_*),
|
||||
// while the database stores the canonical lesson title.
|
||||
if (!$lesson) {
|
||||
|
||||
Reference in New Issue
Block a user