(int)$ex['exam_id'], 'timestamp_seconds' => (int)$ex['timestamp_seconds'], 'rewind_on_fail_seconds' => (int)$ex['rewind_on_fail_seconds'], 'question_text' => $q['question_text'] ?? 'سؤال فحص فهم الفكرة:', 'explanation' => $q['explanation_text'] ?? '', 'options' => array_map(function ($o) { return [ 'id' => (int)$o['id'], 'text' => $o['option_text'], 'is_correct' => (bool)$o['is_correct'], ]; }, $opts) ]; } if (!empty($activeLesson['timeline_chapters_json'])) { $chapters = json_decode($activeLesson['timeline_chapters_json'], true) ?: []; } } // 2. Fetch Real Exams from MySQL $dbExams = Database::select( "SELECT e.*, COALESCE(c.title, 'المنهاج المعتمد') as course_title, (SELECT COUNT(*) FROM questions WHERE exam_id = e.id) as questions_count FROM exams e LEFT JOIN courses c ON e.course_id = c.id WHERE e.is_published = 1 ORDER BY e.id DESC" ); $examsWithQuestions = []; foreach ($dbExams as $ex) { $qs = Database::select("SELECT * FROM questions WHERE exam_id = ? ORDER BY id ASC", [$ex['id']]); foreach ($qs as &$q) { $q['options'] = Database::select("SELECT id, option_text, is_correct, feedback_text FROM question_options WHERE question_id = ? ORDER BY id ASC", [$q['id']]); } $ex['questions'] = $qs; $examsWithQuestions[] = $ex; } // 3. Fetch Real Teachers Marketplace with Fair Composite Merit Telemetry $teachers = \App\Services\TeacherRatingService::getTeachersMarketplace(); $serverDataJson = json_encode([ 'lessons' => $lessons, 'activeLesson' => $activeLesson, 'activeCheckpoints' => $checkpoints, 'activeChapters' => $chapters, 'exams' => $examsWithQuestions, 'teachers' => $teachers, ], JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP); ob_start(); ?> بوابة الطالب — منصة صَقِل التعليمية
صَقِل صَقِل بوابة الطالب الذكية
Workerman غير متصل