Update Saqel Platform: 2026-09-08 18:55:21
This commit is contained in:
@@ -92,7 +92,23 @@ class VideoController
|
||||
$subject = Database::selectOne(
|
||||
"SELECT id FROM subjects WHERE name = ? ORDER BY id LIMIT 1",
|
||||
[$subjectName]
|
||||
) ?: Database::selectOne("SELECT id FROM subjects ORDER BY id LIMIT 1");
|
||||
);
|
||||
if (!$subject && $subjectName !== '') {
|
||||
// The curriculum tree is the source of truth. When its
|
||||
// subject has not yet been seeded into SQL, create the
|
||||
// minimal canonical subject record instead of attaching
|
||||
// the teacher's lesson to an unrelated first subject.
|
||||
$subjectCode = 'CURR-' . strtoupper(substr(hash('sha256', $subjectName), 0, 12));
|
||||
try {
|
||||
$subjectId = (int)Database::insert(
|
||||
"INSERT INTO subjects (name, code, stream, is_active) VALUES (?, ?, 'common', 1)",
|
||||
[$subjectName, $subjectCode]
|
||||
);
|
||||
$subject = ['id' => $subjectId];
|
||||
} catch (\Throwable $e) {
|
||||
$subject = Database::selectOne("SELECT id FROM subjects WHERE name = ? LIMIT 1", [$subjectName]);
|
||||
}
|
||||
}
|
||||
if (!$subject) {
|
||||
$response->status(409)->json(['status' => 'error', 'message' => 'لا يوجد مبحث معرف لربط الفيديو به']);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user