📁 File Manager
🏠 /
/
home
/
u857492117
/
domains
/
mangaldaicollege.org
/
public_html
/
dk
/
teacher
Dosya Düzenle: reports.php
<?php session_start(); include('../config.php'); if(!isset($_SESSION['teacher_id'])){ header("Location: login.php"); exit(); } // Fetch all exams created by this teacher $exam_res = mysqli_query($conn, "SELECT * FROM exams WHERE teacher_id='".$_SESSION['teacher_id']."' ORDER BY created_at DESC"); // Function to get course name function getCourseName($conn, $course_id){ $course_res = mysqli_query($conn, "SELECT * FROM courses WHERE id='$course_id'"); $course = mysqli_fetch_assoc($course_res); return $course['course_name'] . " - " . $course['semester']; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Reports & Analytics</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <style> body { background: #f8f9fa; } .sidebar { height: 100vh; background: #343a40; color: #fff; padding-top: 20px; min-width: 220px; } .sidebar a { color: #fff; display: block; padding: 10px 20px; text-decoration: none; } .sidebar a:hover { background: #495057; } .main { padding: 20px; flex: 1; } </style> </head> <body> <div class="d-flex"> <div class="sidebar"> <h4 class="text-center">Teacher Panel</h4> <hr> <a href="dashboard.php">Dashboard</a> <a href="create_exam.php">Create Exam</a> <a href="manage_exam.php">Manage Exams</a> <a href="view_students.php">View Students</a> <a href="broadcast_message.php">Broadcast Message</a> <a href="reports.php">Reports & Analytics</a> <a href="logout.php">Logout</a> </div> <div class="main container"> <h3>Reports & Analytics</h3> <table class="table table-bordered table-striped"> <thead> <tr> <th>Exam ID</th> <th>Exam Title</th> <th>Course</th> <th>Total Marks</th> <th>Average Score</th> <th>Highest Score</th> <th>Lowest Score</th> <th>Details</th> </tr> </thead> <tbody> <?php while($exam = mysqli_fetch_assoc($exam_res)) { // Fetch exam statistics $stats_res = mysqli_query($conn, "SELECT COUNT(*) as total_students, AVG(score) as avg_score, MAX(score) as max_score, MIN(score) as min_score FROM results WHERE exam_id='".$exam['id']."'"); $stats = mysqli_fetch_assoc($stats_res); ?> <tr> <td><?php echo $exam['id']; ?></td> <td><?php echo $exam['exam_title']; ?></td> <td><?php echo getCourseName($conn, $exam['course_id']); ?></td> <td><?php echo $exam['total_marks']; ?></td> <td><?php echo round($stats['avg_score'], 2); ?></td> <td><?php echo $stats['max_score']; ?></td> <td><?php echo $stats['min_score']; ?></td> <td> <a href="exam_result.php?exam_id=<?php echo $exam['id']; ?>" class="btn btn-sm btn-primary">View Results</a> </td> </tr> <?php } ?> </tbody> </table> </div> </div> </body> </html>
💾 Kaydet
İptal