Update Saqel Platform: 2026-09-02 01:23:51

This commit is contained in:
Hamza-Ayed
2026-09-02 01:23:51 +03:00
parent f4ab43d49a
commit a1c7029838
4 changed files with 43 additions and 6 deletions
@@ -392,6 +392,17 @@ class VideoController
$lesson = Database::selectOne("SELECT * FROM lessons WHERE id = ? LIMIT 1", [(int)$rawId]);
} elseif (!empty($rawId)) {
$lesson = Database::selectOne("SELECT * FROM lessons WHERE title LIKE ? OR local_path LIKE ? OR markdown_content LIKE ? LIMIT 1", ["%{$rawId}%", "%{$rawId}%", "%{$rawId}%"]);
// Flutter curriculum lessons use the manifest slug (e.g. u1_l1_*),
// while the database stores the canonical lesson title.
if (!$lesson) {
$manifestLesson = CurriculumService::findLessonById($rawId);
if ($manifestLesson && !empty($manifestLesson['title'])) {
$lesson = Database::selectOne(
"SELECT * FROM lessons WHERE title = ? OR markdown_content LIKE ? LIMIT 1",
[$manifestLesson['title'], '%' . ($manifestLesson['file'] ?? '') . '%']
);
}
}
}
if (!$lesson) {
@@ -192,6 +192,25 @@ class CurriculumService
return [];
}
/** Resolve a manifest lesson slug to its canonical title/file. */
public static function findLessonById(string $lessonId): ?array
{
$walk = function ($node) use (&$walk, $lessonId): ?array {
if (!is_array($node)) return null;
if (isset($node['lessons']) && is_array($node['lessons'])) {
foreach ($node['lessons'] as $lesson) {
if (is_array($lesson) && (string)($lesson['id'] ?? '') === $lessonId) return $lesson;
}
}
foreach ($node as $value) {
$found = $walk($value);
if ($found !== null) return $found;
}
return null;
};
return $walk(self::getCurriculumTree());
}
/**
* Save/Update Complete Curriculum Tree Manifest
*/