Complete Socratic adaptive exams in Flutter, Guardian WhatsApp alerts, and curriculum robustness
This commit is contained in:
@@ -417,7 +417,37 @@ class CurriculumService
|
||||
public static function getCurriculumContext(int $courseId, string $lessonTitle): array
|
||||
{
|
||||
$tree = self::getCurriculumTree();
|
||||
// Return matching or generic curriculum context
|
||||
$walk = function ($node, string $subject = 'المبحث الدراسي', string $unit = 'الوحدة التعليمية') use (&$walk, $lessonTitle): ?array {
|
||||
if (!is_array($node)) return null;
|
||||
if (isset($node['semesters']) && isset($node['name'])) {
|
||||
$subject = (string)$node['name'];
|
||||
}
|
||||
if (isset($node['lessons']) && is_array($node['lessons'])) {
|
||||
$unit = (string)($node['name'] ?? $unit);
|
||||
foreach ($node['lessons'] as $lesson) {
|
||||
if (!is_array($lesson)) continue;
|
||||
if ((string)($lesson['title'] ?? '') === $lessonTitle) {
|
||||
return [
|
||||
'grade' => 'الصف العاشر',
|
||||
'subject' => $subject,
|
||||
'unit' => $unit,
|
||||
'core_topics' => array_values(array_filter(array_map('strval', $lesson['outcomes'] ?? []))),
|
||||
'lesson_file' => (string)($lesson['file'] ?? '')
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($node as $value) {
|
||||
$found = $walk($value, $subject, $unit);
|
||||
if ($found !== null) return $found;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
$matched = $walk($tree);
|
||||
if ($matched !== null) return $matched;
|
||||
|
||||
// Safe generic context when the lesson is not in the manifest.
|
||||
return [
|
||||
'grade' => 'المرحلة التعليمية المعتمدة',
|
||||
'subject' => 'المبحث الدراسي',
|
||||
|
||||
Reference in New Issue
Block a user