Files
saqel/backend/scripts/normalize_manifest.php
T

76 lines
3.3 KiB
PHP

<?php
require_once __DIR__ . '/../app/bootstrap.php';
use App\Services\CurriculumService;
$manifestFile = __DIR__ . '/../storage/curriculum/manifest.json';
$tree = json_decode(file_get_contents($manifestFile), true) ?: [];
// Normalize Grade 10
if (isset($tree['grade_10'])) {
$tree['grade_10']['name'] = 'الصف العاشر الأساسي (Grade 10)';
// 1. English
$engData = null;
if (isset($tree['grade_10']['subjects']['english_action_pack_10'])) {
$engData = $tree['grade_10']['subjects']['english_action_pack_10'];
unset($tree['grade_10']['subjects']['english_action_pack_10']);
} elseif (isset($tree['grade_10']['subjects']['english_10'])) {
$engData = $tree['grade_10']['subjects']['english_10'];
}
if ($engData) {
$engData['name'] = 'اللغة الإنجليزية (English — High Note 10)';
// Replace file paths from jordan_high_note_10 to english_10
array_walk_recursive($engData, function(&$val, $k) {
if ($k === 'file' && is_string($val)) {
$val = str_replace('jordan_high_note_10', 'english_10', $val);
}
});
$tree['grade_10']['subjects']['english_10'] = $engData;
}
// 2. Math
if (isset($tree['grade_10']['subjects']['math_10'])) {
$tree['grade_10']['subjects']['math_10']['name'] = 'الرياضيات (Mathematics 10)';
}
// 3. Physics (Initialize structure if not exists)
if (!isset($tree['grade_10']['subjects']['physics_10'])) {
$tree['grade_10']['subjects']['physics_10'] = [
'name' => 'الفيزياء (Physics 10)',
'semesters' => [
'semester_1' => [
'name' => 'الفصل الدراسي الأول',
'units' => [
'unit_01' => [
'name' => 'الوحدة الأولى: المتجهات (Vectors) — (الصفحات 5 - 33)',
'lessons' => []
],
'unit_02' => [
'name' => 'الوحدة الثانية: الحركة والقوة (Motion and Forces) — (الصفحات 33 - 85)',
'lessons' => []
]
],
'resources' => [
'textbooks' => [
'name' => 'الكتب المقررة',
'items' => [
['title' => 'كتاب الفيزياء - الطالب (85 صفحة)', 'file' => 'grade_10/physics_10/semester_1/physics_student_book.pdf'],
['title' => 'كتاب التجارب والأنشطة العلمية (33 صفحة)', 'file' => 'grade_10/physics_10/semester_1/physics_activities_book.pdf']
]
],
'worksheets' => [
'name' => 'أوراق عمل وتجارب',
'items' => []
]
]
]
]
];
}
}
file_put_contents($manifestFile, json_encode($tree, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
echo "SUCCESS! Normalized manifest with English (اللغة الإنجليزية), Math (الرياضيات), and Physics (الفيزياء)!\n";