Update Saqel Platform: 2026-09-08 13:43:36

This commit is contained in:
Hamza-Ayed
2026-09-08 13:43:36 +03:00
parent 0f424062fe
commit bb37b31cab
76 changed files with 3617 additions and 3059 deletions
+17 -20
View File
@@ -31,9 +31,8 @@ class SchoolRosterService
foreach ($records as $index => $row) {
$nationalId = trim((string)($row['national_id'] ?? ''));
$fullName = trim((string)($row['full_name'] ?? ''));
$gradeLevel = trim((string)($row['grade_level'] ?? 'الأول ثانوي'));
$stream = trim((string)($row['stream'] ?? 'علمي'));
$phone = trim((string)($row['phone_number'] ?? ''));
$gradeLevel = trim((string)($row['grade_level'] ?? 'grade_10'));
$stream = self::normalizeStream((string)($row['stream'] ?? 'general'));
// 1. Validate 10-digit Jordanian National ID
if (!preg_match('/^[0-9]{10}$/', $nationalId)) {
@@ -62,15 +61,16 @@ class SchoolRosterService
try {
// If students table is active
Database::query(
"INSERT INTO students (uuid, national_id, full_name, grade_level, stream, school_id, is_school_sponsored, created_at)
VALUES (?, ?, ?, ?, ?, ?, 1, NOW())
ON DUPLICATE KEY UPDATE full_name = VALUES(full_name), grade_level = VALUES(grade_level)",
[$uuid, $encryptedNationalId, $fullName, $gradeLevel, $stream, $schoolId]
"INSERT INTO students (uuid, national_id, national_id_hash, full_name, grade_level, stream, school_id, is_school_sponsored, created_at)
VALUES (?, ?, ?, ?, ?, ?, ?, 1, NOW())
ON DUPLICATE KEY UPDATE national_id = VALUES(national_id), full_name = VALUES(full_name), grade_level = VALUES(grade_level), stream = VALUES(stream), school_id = VALUES(school_id)",
[$uuid, $encryptedNationalId, $blindIndex, $fullName, $gradeLevel, $stream, $schoolId]
);
$importedCount++;
} catch (\Throwable $e) {
// In decoupled test mode, increment count
$importedCount++;
$failedCount++;
$errors[] = 'السطر ' . ($index + 1) . ': تعذر حفظ السجل في قاعدة البيانات.';
error_log('[SchoolRosterService] import failure: ' . $e->getMessage());
}
}
@@ -85,17 +85,14 @@ class SchoolRosterService
];
}
/**
* عينة كشف مدرسي افتراضي للاختبار السريع
*/
public static function getSampleRosterData(): array
private static function normalizeStream(string $stream): string
{
return [
['national_id' => '2009102450', 'full_name' => 'سما حمزة الغويريين', 'grade_level' => 'الصف العاشر الأساسي', 'stream' => 'علمي', 'phone_number' => '0798583052'],
['national_id' => '2008123456', 'full_name' => 'زيد حمزة الغويري', 'grade_level' => 'الأول ثانوي', 'stream' => 'علمي', 'phone_number' => '0798583052'],
['national_id' => '2008123457', 'full_name' => 'عمر خالد بني صخر', 'grade_level' => 'الأول ثانوي', 'stream' => 'علمي', 'phone_number' => '0791112233'],
['national_id' => '2008123459', 'full_name' => 'إبراهيم ناصر العبادي', 'grade_level' => 'الأول ثانوي', 'stream' => 'علمي', 'phone_number' => '0793334455'],
['national_id' => '2008123460', 'full_name' => 'عبد الله محمود العدوان', 'grade_level' => 'الأول ثانوي', 'stream' => 'علمي', 'phone_number' => '0794445566'],
];
return match (trim(mb_strtolower($stream))) {
'علمي', 'scientific' => 'scientific',
'أدبي', 'literary' => 'literary',
'مهني', 'vocational' => 'vocational',
default => 'general',
};
}
}