prepare(" SELECT l.*, c.name_en, c.name_ar, c.teacher_id FROM course_live_lessons l JOIN courses c ON l.course_id = c.id WHERE l.id = ? "); $stmt->execute([$lesson_id]); $lesson = $stmt->fetch(PDO::FETCH_ASSOC); if (!$lesson) { die("Lesson not found."); } // Check role $is_teacher = false; $is_student = false; // Mock student and teacher IDs for the prototype based on current session // In reality, this would be based on logged-in user session $current_teacher_id = 1; // Used in teacher.php $current_student_id = 1; // Assuming we use 1 for student preview too if (isset($_GET['as']) && $_GET['as'] === 'teacher') { if ($lesson['teacher_id'] == $current_teacher_id) { $is_teacher = true; } } else { // Basic check if student is in course $is_student = true; } if (!$is_teacher && !$is_student) { die("Unauthorized access."); } // Ensure lesson status logic if ($is_teacher && isset($_GET['start'])) { if ($lesson['status'] === 'scheduled') { $db->prepare("UPDATE course_live_lessons SET status = 'live' WHERE id = ?")->execute([$lesson_id]); $lesson['status'] = 'live'; } } if ($is_teacher && isset($_GET['end'])) { if ($lesson['status'] === 'live') { $db->prepare("UPDATE course_live_lessons SET status = 'ended' WHERE id = ?")->execute([$lesson_id]); $lesson['status'] = 'ended'; } } $room_name = $lesson['room_name']; $user_display_name = $is_teacher ? 'Teacher' : 'Student'; $has_meet = !empty($lesson['meet_url']); render_head( t('Live Lesson: ', 'درس مباشر: ') . t($lesson['title'], $lesson['title']), t('Join the live streaming lesson.', 'انضم إلى بث الدرس المباشر.') ); // We won't render normal nav here to maximize screen space for the lesson, or we render a simplified one ?>

-