[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: makeup_sessions.php
<?php /** * Makeup Sessions Management Page * This page allows teachers to record makeup sessions for absent students */ require_once '../config/config.php'; requireLogin('teacher'); $database = new Database(); $conn = $database->getConnection(); $teacher_id = $_SESSION['teacher_id']; $message = ''; $message_type = ''; // Handle form submissions if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_POST['action']) && $_POST['action'] === 'save_makeup') { $student_id = $_POST['student_id']; $original_group_id = $_POST['original_group_id']; $makeup_group_id = $_POST['makeup_group_id']; $session_date = $_POST['session_date']; $session_time = $_POST['session_time']; $homework_level = !empty($_POST['homework_level']) ? $_POST['homework_level'] : null; $has_test = isset($_POST['has_test']) ? 1 : 0; $test_total_score = $has_test && !empty($_POST['test_total_score']) ? floatval($_POST['test_total_score']) : null; $student_test_score = $has_test && !empty($_POST['student_test_score']) ? floatval($_POST['student_test_score']) : null; $teacher_notes = !empty($_POST['teacher_notes']) ? trim($_POST['teacher_notes']) : null; if (empty($student_id) || empty($original_group_id) || empty($makeup_group_id) || empty($session_date) || empty($session_time)) { $message = 'يرجى إدخال جميع البيانات المطلوبة'; $message_type = 'danger'; } else { // Validate test scores if ($has_test && $test_total_score && $student_test_score && $student_test_score > $test_total_score) { $message = 'درجة الطالب لا يمكن أن تكون أكبر من الدرجة الكلية'; $message_type = 'danger'; } else { // Verify both groups belong to teacher $verify_query = "SELECT COUNT(*) as count FROM groups WHERE id IN (:original_id, :makeup_id) AND teacher_id = :teacher_id"; $verify_stmt = $conn->prepare($verify_query); $verify_stmt->bindParam(':original_id', $original_group_id); $verify_stmt->bindParam(':makeup_id', $makeup_group_id); $verify_stmt->bindParam(':teacher_id', $teacher_id); $verify_stmt->execute(); if ($verify_stmt->fetch(PDO::FETCH_ASSOC)['count'] != 2) { $message = 'المجموعات غير صحيحة'; $message_type = 'danger'; } else { $query = "INSERT INTO makeup_sessions (student_id, original_group_id, makeup_group_id, session_date, session_time, homework_level, has_test, test_total_score, student_test_score, teacher_notes) VALUES (:student_id, :original_group_id, :makeup_group_id, :session_date, :session_time, :homework_level, :has_test, :test_total_score, :student_test_score, :teacher_notes)"; $stmt = $conn->prepare($query); $stmt->bindParam(':student_id', $student_id); $stmt->bindParam(':original_group_id', $original_group_id); $stmt->bindParam(':makeup_group_id', $makeup_group_id); $stmt->bindParam(':session_date', $session_date); $stmt->bindParam(':session_time', $session_time); $stmt->bindParam(':homework_level', $homework_level); $stmt->bindParam(':has_test', $has_test); $stmt->bindParam(':test_total_score', $test_total_score); $stmt->bindParam(':student_test_score', $student_test_score); $stmt->bindParam(':teacher_notes', $teacher_notes); if ($stmt->execute()) { $message = 'تم تسجيل حصة التعويض بنجاح'; $message_type = 'success'; } else { $message = 'حدث خطأ أثناء تسجيل حصة التعويض'; $message_type = 'danger'; } } } } } } // Get absent students (students with absences in the last 30 days) $absent_query = "SELECT DISTINCT s.id, s.name, s.student_code, g.name as group_name, g.id as group_id, CONCAT(st.name, ' - ', gr.name, ' - ', sub.name) as full_info, COUNT(a.id) as absence_count, MAX(a.session_date) as last_absence_date FROM students s JOIN groups g ON s.group_id = g.id JOIN grades gr ON g.grade_id = gr.id JOIN stages st ON gr.stage_id = st.id JOIN subjects sub ON g.subject_id = sub.id JOIN attendance a ON s.id = a.student_id WHERE g.teacher_id = :teacher_id AND s.is_active = 1 AND a.is_present = 0 AND a.session_date >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) GROUP BY s.id ORDER BY absence_count DESC, last_absence_date DESC"; $absent_stmt = $conn->prepare($absent_query); $absent_stmt->bindParam(':teacher_id', $teacher_id); $absent_stmt->execute(); $absent_students = $absent_stmt->fetchAll(PDO::FETCH_ASSOC); // Get teacher's groups for makeup selection $groups_query = "SELECT g.id, g.name, CONCAT(st.name, ' - ', gr.name, ' - ', sub.name) as full_info FROM groups g JOIN grades gr ON g.grade_id = gr.id JOIN stages st ON gr.stage_id = st.id JOIN subjects sub ON g.subject_id = sub.id WHERE g.teacher_id = :teacher_id AND g.is_active = 1 ORDER BY g.name"; $groups_stmt = $conn->prepare($groups_query); $groups_stmt->bindParam(':teacher_id', $teacher_id); $groups_stmt->execute(); $groups = $groups_stmt->fetchAll(PDO::FETCH_ASSOC); // Get recent makeup sessions $recent_query = "SELECT ms.*, s.name as student_name, s.student_code, og.name as original_group_name, mg.name as makeup_group_name FROM makeup_sessions ms JOIN students s ON ms.student_id = s.id JOIN groups og ON ms.original_group_id = og.id JOIN groups mg ON ms.makeup_group_id = mg.id WHERE og.teacher_id = :teacher_id ORDER BY ms.created_at DESC LIMIT 10"; $recent_stmt = $conn->prepare($recent_query); $recent_stmt->bindParam(':teacher_id', $teacher_id); $recent_stmt->execute(); $recent_makeups = $recent_stmt->fetchAll(PDO::FETCH_ASSOC); $page_title = 'حصص التعويض'; include '../includes/header.php'; ?> <div class="container-fluid"> <div class="row"> <!-- Sidebar --> <div class="col-lg-3 col-md-4 sidebar p-0"> <div class="d-flex flex-column h-100"> <div class="p-3 text-white"> <h4 class="mb-0"> <i class="fas fa-chalkboard-teacher me-2"></i> لوحة المعلم </h4> <small>مرحباً <?php echo $_SESSION['teacher_name']; ?></small> </div> <nav class="nav nav-pills flex-column p-3"> <a class="nav-link" href="dashboard.php"> <i class="fas fa-tachometer-alt me-2"></i>الرئيسية </a> <a class="nav-link" href="subjects_grades.php"> <i class="fas fa-book me-2"></i>المواد والصفوف </a> <a class="nav-link" href="groups.php"> <i class="fas fa-users me-2"></i>المجموعات </a> <a class="nav-link" href="students.php"> <i class="fas fa-user-graduate me-2"></i>الطلاب </a> <a class="nav-link" href="attendance.php"> <i class="fas fa-clipboard-check me-2"></i>تسجيل الحضور </a> <a class="nav-link active" href="makeup_sessions.php"> <i class="fas fa-redo me-2"></i>حصص التعويض </a> <a class="nav-link" href="reports.php"> <i class="fas fa-chart-bar me-2"></i>التقارير </a> <div class="mt-auto"> <a class="nav-link text-light" href="../logout.php"> <i class="fas fa-sign-out-alt me-2"></i>تسجيل الخروج </a> </div> </nav> </div> </div> <!-- Main Content --> <div class="col-lg-9 col-md-8 main-content p-4"> <div class="d-flex justify-content-between align-items-center mb-4"> <h2>حصص التعويض</h2> <?php if (!empty($absent_students)): ?> <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addMakeupModal"> <i class="fas fa-plus me-2"></i>تسجيل حصة تعويض </button> <?php endif; ?> </div> <!-- Messages --> <?php if (!empty($message)): ?> <div class="alert alert-<?php echo $message_type; ?> alert-dismissible fade show" role="alert"> <i class="fas fa-<?php echo $message_type == 'success' ? 'check-circle' : 'exclamation-triangle'; ?> me-2"></i> <?php echo $message; ?> <button type="button" class="btn-close" data-bs-dismiss="alert"></button> </div> <?php endif; ?> <!-- Absent Students --> <div class="card mb-4"> <div class="card-header"> <h5 class="mb-0"> <i class="fas fa-exclamation-triangle text-warning me-2"></i> الطلاب الذين يحتاجون حصص تعويض </h5> </div> <div class="card-body"> <?php if (empty($absent_students)): ?> <div class="text-center py-4"> <i class="fas fa-check-circle fa-3x text-success mb-3"></i> <h5>ممتاز! لا يوجد طلاب غائبون</h5> <p class="text-muted">جميع الطلاب يحضرون بانتظام</p> </div> <?php else: ?> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr> <th>اسم الطالب</th> <th>كود الطالب</th> <th>المجموعة الأصلية</th> <th>عدد الغيابات</th> <th>آخر غياب</th> <th>الإجراء</th> </tr> </thead> <tbody> <?php foreach ($absent_students as $student): ?> <tr class="<?php echo $student['absence_count'] > 3 ? 'table-danger' : 'table-warning'; ?>"> <td> <strong><?php echo htmlspecialchars($student['name']); ?></strong> <?php if ($student['absence_count'] > 3): ?> <span class="badge bg-danger ms-2">يحتاج متابعة عاجلة</span> <?php endif; ?> </td> <td> <span class="badge bg-info"><?php echo $student['student_code']; ?></span> </td> <td> <small><?php echo htmlspecialchars($student['group_name']); ?></small><br> <small class="text-muted"><?php echo htmlspecialchars($student['full_info']); ?></small> </td> <td> <span class="badge bg-<?php echo $student['absence_count'] > 3 ? 'danger' : 'warning'; ?>"> <?php echo $student['absence_count']; ?> غياب </span> </td> <td><?php echo date('Y/m/d', strtotime($student['last_absence_date'])); ?></td> <td> <button class="btn btn-sm btn-success" onclick="addMakeupSession(<?php echo htmlspecialchars(json_encode($student)); ?>)"> <i class="fas fa-plus me-1"></i>حصة تعويض </button> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php endif; ?> </div> </div> <!-- Recent Makeup Sessions --> <?php if (!empty($recent_makeups)): ?> <div class="card"> <div class="card-header"> <h5 class="mb-0">حصص التعويض الأخيرة</h5> </div> <div class="card-body"> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr> <th>اسم الطالب</th> <th>المجموعة الأصلية</th> <th>مجموعة التعويض</th> <th>التاريخ والوقت</th> <th>مستوى الواجب</th> <th>الاختبار</th> </tr> </thead> <tbody> <?php foreach ($recent_makeups as $makeup): ?> <tr> <td> <strong><?php echo htmlspecialchars($makeup['student_name']); ?></strong><br> <small class="text-muted"><?php echo $makeup['student_code']; ?></small> </td> <td><?php echo htmlspecialchars($makeup['original_group_name']); ?></td> <td><?php echo htmlspecialchars($makeup['makeup_group_name']); ?></td> <td> <?php echo date('Y/m/d', strtotime($makeup['session_date'])); ?><br> <small><?php echo date('g:i A', strtotime($makeup['session_time'])); ?></small> </td> <td> <?php if ($makeup['homework_level']): ?> <span class="badge bg-primary"><?php echo $makeup['homework_level']; ?></span> <?php else: ?> <span class="text-muted">-</span> <?php endif; ?> </td> <td> <?php if ($makeup['has_test']): ?> <span class="badge bg-success"> <?php echo $makeup['student_test_score']; ?>/<?php echo $makeup['test_total_score']; ?> </span> <?php else: ?> <span class="text-muted">لا يوجد</span> <?php endif; ?> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> </div> </div> <?php endif; ?> </div> </div> </div> <!-- Add Makeup Session Modal --> <div class="modal fade" id="addMakeupModal" tabindex="-1"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">تسجيل حصة تعويض</h5> <button type="button" class="btn-close" data-bs-dismiss="modal"></button> </div> <form method="POST" action=""> <div class="modal-body"> <input type="hidden" id="studentId" name="student_id"> <input type="hidden" id="originalGroupId" name="original_group_id"> <input type="hidden" name="action" value="save_makeup"> <!-- Student Info --> <div class="alert alert-info"> <h6 id="studentInfo"></h6> </div> <div class="row"> <div class="col-md-6 mb-3"> <label for="makeupGroupId" class="form-label">مجموعة التعويض</label> <select class="form-select" id="makeupGroupId" name="makeup_group_id" required> <option value="">اختر مجموعة التعويض</option> <?php foreach ($groups as $group): ?> <option value="<?php echo $group['id']; ?>"> <?php echo htmlspecialchars($group['name'] . ' - ' . $group['full_info']); ?> </option> <?php endforeach; ?> </select> </div> <div class="col-md-3 mb-3"> <label for="makeupDate" class="form-label">تاريخ الحصة</label> <input type="date" class="form-control" id="makeupDate" name="session_date" value="<?php echo date('Y-m-d'); ?>" required> </div> <div class="col-md-3 mb-3"> <label for="makeupTime" class="form-label">وقت الحصة</label> <input type="time" class="form-control" id="makeupTime" name="session_time" value="<?php echo date('H:i'); ?>" required> </div> </div> <div class="row"> <div class="col-md-6 mb-3"> <label for="homeworkLevel" class="form-label">مستوى الواجب</label> <select class="form-select" id="homeworkLevel" name="homework_level"> <option value="">لا يوجد</option> <option value="ممتاز">ممتاز</option> <option value="جيد جداً">جيد جداً</option> <option value="جيد">جيد</option> <option value="مقبول">مقبول</option> <option value="ضعيف">ضعيف</option> </select> </div> <div class="col-md-6 mb-3"> <div class="form-check mt-4"> <input class="form-check-input" type="checkbox" id="hasTest" name="has_test" onchange="toggleTestFields()"> <label class="form-check-label" for="hasTest"> يوجد اختبار </label> </div> </div> </div> <!-- Test Fields --> <div id="testFields" class="row" style="display: none;"> <div class="col-md-6 mb-3"> <label for="testTotalScore" class="form-label">الدرجة الكلية</label> <input type="number" class="form-control" id="testTotalScore" name="test_total_score" step="0.01" min="0" onchange="validateMakeupTestScore()"> </div> <div class="col-md-6 mb-3"> <label for="studentTestScore" class="form-label">درجة الطالب</label> <input type="number" class="form-control" id="studentTestScore" name="student_test_score" step="0.01" min="0" onchange="validateMakeupTestScore()"> </div> </div> <div class="mb-3"> <label for="teacherNotes" class="form-label">ملاحظات المعلم</label> <textarea class="form-control" id="teacherNotes" name="teacher_notes" rows="3" placeholder="ملاحظات حول أداء الطالب في حصة التعويض"></textarea> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">إلغاء</button> <button type="submit" class="btn btn-success"> <i class="fas fa-save me-2"></i>حفظ حصة التعويض </button> </div> </form> </div> </div> </div> <script> function addMakeupSession(student) { document.getElementById('studentId').value = student.id; document.getElementById('originalGroupId').value = student.group_id; document.getElementById('studentInfo').textContent = `الطالب: ${student.name} - المجموعة: ${student.group_name}`; const modal = new bootstrap.Modal(document.getElementById('addMakeupModal')); modal.show(); } function toggleTestFields() { const hasTest = document.getElementById('hasTest').checked; const testFields = document.getElementById('testFields'); if (hasTest) { testFields.style.display = 'block'; } else { testFields.style.display = 'none'; document.getElementById('testTotalScore').value = ''; document.getElementById('studentTestScore').value = ''; } } function validateMakeupTestScore() { const total = parseFloat(document.getElementById('testTotalScore').value) || 0; const score = parseFloat(document.getElementById('studentTestScore').value) || 0; if (score > total) { alert('درجة الطالب لا يمكن أن تكون أكبر من الدرجة الكلية'); document.getElementById('studentTestScore').value = total; } } </script> <?php include '../includes/footer.php'; ?>
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.87 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285