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 ?>
= t('Scheduled for: ', 'مجدول في: ') ?> = date('Y-m-d H:i', strtotime($lesson['scheduled_at'])) ?>
= t('Start Live Streaming Now', 'ابدأ البث المباشر الآن') ?>= t('Thank you for participating.', 'شكراً لمشاركتك.') ?>
= t('Click the button below to join the session in a new tab. You must be logged into your Google account.', 'انقر على الزر أدناه للانضمام إلى الجلسة في علامة تبويب جديدة. يجب أن تكون مسجلاً الدخول إلى حساب Google الخاص بك.') ?>
= t('Join Google Meet', 'انضم إلى Google Meet') ?>