getQueryParams()['directorate_code'] ?? 'MC-JOR'; // Fetch or default Military Culture Directorate $directorate = [ 'code' => 'MC-JOR', 'name' => 'مديرية التربية والتعليم والثقافة العسكرية', 'type' => 'military_culture', 'commander_name' => 'مدير التعليم والثقافة العسكرية', 'total_schools' => 43, 'total_students' => 19350, 'total_teachers' => 812, 'annual_contract_value' => 20000.00, 'recorded_lessons_month'=> 1420, 'compliance_rate' => 94.5, // % of bi-weekly video quotas met 'ai_average_score' => 91.8, 'active_unified_exams' => 2, ]; // Sample list of 43 schools categorized by weight tiers across Jordan $sampleSchools = [ [ 'id' => 1, 'code' => 'SCH-MC-01', 'name' => 'مدرسة الشهيد فيصل الثاني الثانوية العسكرية', 'governorate' => 'العاصمة', 'weight_tier' => 'tier_c_large', 'student_count'=> 980, 'teacher_count'=> 48, 'compliance' => 98.0, 'status' => 'excellent', 'annual_fee' => 900.00, ], [ 'id' => 2, 'code' => 'SCH-MC-02', 'name' => 'مدرسة الملك حسين الثانوية العسكرية', 'governorate' => 'الزرقاء', 'weight_tier' => 'tier_c_large', 'student_count'=> 890, 'teacher_count'=> 42, 'compliance' => 95.5, 'status' => 'excellent', 'annual_fee' => 900.00, ], [ 'id' => 3, 'code' => 'SCH-MC-03', 'name' => 'مدرسة صرح الشهيد العسكرية', 'governorate' => 'إربد', 'weight_tier' => 'tier_b_medium', 'student_count'=> 460, 'teacher_count'=> 24, 'compliance' => 92.0, 'status' => 'good', 'annual_fee' => 450.00, ], [ 'id' => 4, 'code' => 'SCH-MC-04', 'name' => 'مدرسة البادية الشمالية الثانوية العسكرية', 'governorate' => 'المفرق', 'weight_tier' => 'tier_a_small', 'student_count'=> 150, 'teacher_count'=> 12, 'compliance' => 88.0, 'status' => 'warning_under_quota', 'annual_fee' => 250.00, ], [ 'id' => 5, 'code' => 'SCH-MC-05', 'name' => 'مدرسة القويرة الثانوية العسكرية', 'governorate' => 'العقبة', 'weight_tier' => 'tier_a_small', 'student_count'=> 135, 'teacher_count'=> 11, 'compliance' => 91.0, 'status' => 'good', 'annual_fee' => 250.00, ], [ 'id' => 6, 'code' => 'SCH-MC-06', 'name' => 'مدرسة الكرك الثانوية العسكرية', 'governorate' => 'الكرك', 'weight_tier' => 'tier_b_medium', 'student_count'=> 420, 'teacher_count'=> 22, 'compliance' => 94.0, 'status' => 'good', 'annual_fee' => 450.00, ], ]; // Macro Alerts & Anomaly indicators $anomalies = [ [ 'id' => 'ANM-01', 'type' => 'speed_impossible', 'school_name' => 'مدرسة البادية الشمالية العسكرية', 'subject' => 'الرياضيات العلمي', 'description' => 'حل 18 طالباً لمسألة تفاضل في 14 ثانية (تحت التدقيق الإشرافي)', 'severity' => 'medium', 'timestamp' => date('Y-m-d H:i', strtotime('-2 hours')), ] ]; $response->json([ 'status' => 'success', 'directorate' => $directorate, 'schools' => $sampleSchools, 'anomalies' => $anomalies, 'radar' => [ 'top_teachers' => [ ['name' => 'أحمد المجالي', 'school' => 'الشهيد فيصل الثاني', 'subject' => 'الفيزياء', 'score' => 97.4, 'certified_badge' => true], ['name' => 'خلدون بني هاني', 'school' => 'صرح الشهيد إربد', 'subject' => 'الرياضيات', 'score' => 96.8, 'certified_badge' => true], ['name' => 'طارق الحنيطي', 'school' => 'الملك حسين الزرقاء', 'subject' => 'الكيمياء', 'score' => 95.9, 'certified_badge' => true], ], 'needing_support' => [ ['name' => 'معلم لغة عربية', 'school' => 'مدرسة القويرة', 'issue' => 'ضعف الأسئلة السقراطية وتجاوز زمن الشرح 35 دقيقة', 'score' => 74.2], ] ] ]); } /** * Get School Principal / Field Supervisor Dashboard (لوحة مدير المدرسة والمشرف) * GET /api/supervisor/school-dashboard */ public function getSchoolDashboard(Request $request, Response $response): void { $schoolId = (int)($request->getQueryParams()['school_id'] ?? 1); $school = [ 'id' => $schoolId, 'name' => 'مدرسة الشهيد فيصل الثاني الثانوية العسكرية', 'governorate' => 'العاصمة - عمان', 'student_count' => 980, 'teacher_count' => 48, 'weight_tier' => 'tier_c_large', 'director_name' => 'المقدم الركن / مدير المدرسة', 'biweekly_cycle' => 'الدورة الرابعة (الفصل الأول)', 'cycle_progress' => '42 من 48 حصة مسجلة (87.5%)', ]; $teachers = [ [ 'id' => 101, 'name' => 'أحمد المجالي', 'subject' => 'الفيزياء', 'grade' => 'العاشر + الأول ثانوي', 'quota_status' => 'completed', // 1 lesson every 2 weeks completed 'last_lesson' => 'تطبيقات قوانين نيوتن الثالث والمصاعد', 'ai_score' => 97.4, 'recorded_at' => 'منذ 3 أيام', ], [ 'id' => 102, 'name' => 'عمر الحباشنة', 'subject' => 'الرياضيات العلمي', 'grade' => 'التوجيهي 2008', 'quota_status' => 'pending', // Needs recording this week 'last_lesson' => 'تطبيقات القيم القصوى والمعدلات المرتبطة', 'ai_score' => 94.0, 'recorded_at' => 'منذ 12 يوماً', ], [ 'id' => 103, 'name' => 'سليمان الطراونة', 'subject' => 'الكيمياء', 'grade' => 'الأول ثانوي', 'quota_status' => 'completed', 'last_lesson' => 'سرعة التفاعلات ونظرية التصادم', 'ai_score' => 92.5, 'recorded_at' => 'أمس', ], [ 'id' => 104, 'name' => 'محمد الغويري', 'subject' => 'اللغة الإنجليزية', 'grade' => 'العاشر', 'quota_status' => 'completed', 'last_lesson' => 'Conditional Sentences (Type 2 & 3)', 'ai_score' => 96.0, 'recorded_at' => 'منذ 5 أيام', ], ]; $activeExams = [ [ 'id' => 'EX-MC-2026-01', 'title' => 'الامتحان الموحد التجريبي - الرياضيات العلمي', 'subject' => 'الرياضيات العلمي', 'grade_level' => 'التوجيهي 2008', 'scheduled_time' => 'اليوم - 09:00 صباحاً (موعد موحد لكافة المدارس)', 'duration_minutes' => 60, 'pushed_to_lab' => true, 'status' => 'in_progress', 'forms' => ['نموذج أ', 'نموذج ب'], 'anti_cheating' => [ 'kiosk_mode_locked' => true, 'dynamic_numbers' => true, 'smart_sampling' => 'ثانيتان كل دقيقة (حجم الإجمالي 16 ميجابايت)', ] ] ]; $response->json([ 'status' => 'success', 'school' => $school, 'teachers' => $teachers, 'active_exams' => $activeExams ]); } /** * Record Classroom Lesson via Supervisor App * POST /api/supervisor/record-lesson */ public function recordLesson(Request $request, Response $response): void { $body = $request->getBody(); $teacherName = $body['teacher_name'] ?? 'معلم معتمد'; $subject = $body['subject'] ?? 'الفيزياء'; $lessonTitle = $body['lesson_title'] ?? 'حصة صفية ميدانية'; $fileSizeMb = (float)($body['file_size_mb'] ?? 340.0); $durationMin = (int)($body['duration_minutes'] ?? 45); // Quality check constraint: Maximum 400 MB if ($fileSizeMb > 400.0) { $response->status(400)->json([ 'status' => 'error', 'message' => 'حجم الفيديو يتجاوز السقف المعتمد (400 ميجابايت). يرجى التحقق من ترميز الضغط 720p.' ]); return; } // Simulate AI pedagogical audit $aiScore = mt_rand(88, 98); $teacherTalkRatio = mt_rand(55, 68); // healthy balance between 50-70% $socraticCheckpoints = [ [ 'timestamp' => '14:20', 'question' => 'لماذا تختلف قوة التجاذب الكتلي عند الاقتراب من سطح الأرض؟', 'objective' => 'الربط بالمنهاج الوزاري - نتاجات الوحدة الثانية' ], [ 'timestamp' => '28:45', 'question' => 'ما هو التفسير الفيزيائي لقصور الجسم الذاتي في حركة المصعد؟', 'objective' => 'إثارة التفكير الاستنتاجي السقراطي' ] ]; $lessonUuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) ); $response->json([ 'status' => 'success', 'message' => 'تم رفع الحصة بنجاح وإتمام التدقيق التربوي السيادي', 'data' => [ 'lesson_uuid' => $lessonUuid, 'teacher_name' => $teacherName, 'subject' => $subject, 'lesson_title' => $lessonTitle, 'file_size_mb' => $fileSizeMb, 'duration_minutes' => $durationMin, 'ai_alignment_score' => $aiScore, 'teacher_talk_ratio' => $teacherTalkRatio . '%', 'status' => ($aiScore >= 85) ? 'approved_official' : 'under_supervisor_review', 'socratic_checkpoints' => $socraticCheckpoints, 'report_summary' => 'التزام تام بالخطة الفصلية، تسلسل منطقي في طرح المفاهيم، لغة تربوية سليمة خالية من المخالفات.' ] ]); } /** * Push Unified Exam to School Computer Labs * POST /api/supervisor/exam/push-to-lab */ public function pushExamToLab(Request $request, Response $response): void { $body = $request->getBody(); $examId = $body['exam_id'] ?? 'EX-MC-2026-01'; $response->json([ 'status' => 'success', 'message' => 'تم بث الامتحان الموحد لمحطات مختبر الحاسوب وتفعيل البيئة المقفلة (Kiosk Mode)', 'exam_id' => $examId, 'pushed_at' => date('Y-m-d H:i:s'), 'connected_nodes' => 32, // lab PCs 'forms_ready' => ['Form A', 'Form B'], ]); } /** * Upload Smart Sampled Panoramic Surveillance Video * POST /api/supervisor/exam/upload-panoramic-sample */ public function uploadPanoramicSample(Request $request, Response $response): void { $body = $request->getBody(); $fileSizeMb = (float)($body['file_size_mb'] ?? 16.5); $durationSec = (int)($body['duration_seconds'] ?? 120); $response->json([ 'status' => 'success', 'message' => 'تم حفظ العينة البانورامية المقتضبة بنجاح وربطها بسجل الامتحان', 'file_size_mb' => $fileSizeMb, 'duration_seconds' => $durationSec, 'retention_policy' => 'حفظ محلي مشفر لمدة 14 يوماً حتى اعتماد النتائج', 'correlated_anomalies'=> 0 ]); } /** * توليد الامتحان الموحد بنموذجين متوازيين (نموذج أ ونموذج ب) * GET /api/unified-exams/dual-forms */ public function generateDualForms(Request $request, Response $response): void { $subject = (string)$request->getQuery('subject', 'الفيزياء'); $gradeLevel = (string)$request->getQuery('grade_level', 'الأول ثانوي'); $forms = \App\Services\UnifiedExamService::generateDualForms($subject, $gradeLevel); $response->json([ 'status' => 'success', 'data' => $forms ]); } /** * كشف الشذوذ الإحصائي ومكافحة الغش في جلسة الامتحان الموحد * POST /api/unified-exams/evaluate-integrity */ public function evaluateExamSessionIntegrity(Request $request, Response $response): void { $body = $request->getBody(); $submissions = $body['submissions'] ?? []; if (empty($submissions)) { // Default sample submissions demonstrating all 3 statistical anomalies $submissions = [ [ 'student_id' => 101, 'student_name' => 'سيف الدين خالد الرواشدة', 'seat_number' => 'قاعة 1 — مقعد 04', 'time_spent_seconds' => 195, // < 300s 'score' => 95, 'historical_average' => 50.0, 'answers' => [ 1 => ['selected_option' => 0, 'is_correct' => true], 2 => ['selected_option' => 0, 'is_correct' => true], ] ], [ 'student_id' => 102, 'student_name' => 'عمر أحمد الحباشنة', 'seat_number' => 'قاعة 1 — مقعد 05', 'time_spent_seconds' => 720, 'score' => 92, 'historical_average' => 42.0, // Historical leap 'answers' => [ 1 => ['selected_option' => 2, 'is_correct' => false], // identical error 2 => ['selected_option' => 1, 'is_correct' => false], ] ], [ 'student_id' => 103, 'student_name' => 'فيصل محمود الخريشا', 'seat_number' => 'قاعة 1 — مقعد 06', 'time_spent_seconds' => 740, 'score' => 88, 'historical_average' => 84.0, 'answers' => [ 1 => ['selected_option' => 2, 'is_correct' => false], // identical error 2 => ['selected_option' => 1, 'is_correct' => false], ] ] ]; } $result = \App\Services\UnifiedExamService::evaluateExamSessionIntegrity($submissions); $response->json([ 'status' => 'success', 'data' => $result ]); } /** * إرسال ومضات التقارير الشهرية لأولياء الأمور عبر الواتساب وبوابة نبيه * POST /api/parent-reports/dispatch */ public function dispatchParentReports(Request $request, Response $response): void { $body = $request->getBody(); $studentId = !empty($body['student_id']) ? (int)$body['student_id'] : null; $schoolId = !empty($body['school_id']) ? (int)$body['school_id'] : 1; if ($studentId) { $res = \App\Services\ParentReportService::dispatchReportToGuardian($studentId); } else { $res = \App\Services\ParentReportService::dispatchBatchReports($schoolId); } $response->json($res); } /** * استيراد كشف المدرسة وتشفير الأرقام الوطنية (AES-256-GCM) * POST /api/school-roster/import */ public function importSchoolRoster(Request $request, Response $response): void { $body = $request->getBody(); $schoolId = !empty($body['school_id']) ? (int)$body['school_id'] : 1; $records = $body['records'] ?? []; if (empty($records)) { $records = \App\Services\SchoolRosterService::getSampleRosterData(); } $result = \App\Services\SchoolRosterService::importStudentRoster($schoolId, $records); $response->json($result); } }