📁 File Manager
🏠 /
/
home
/
u857492117
/
domains
/
mangaldaicollege.org
/
public_html
/
dk1
/
admin
Dosya Düzenle: quiz_reports.php
<?php session_start(); include("../config.php"); // Redirect if admin not logged in if(!isset($_SESSION['admin_id'])){ header("Location: admin_login.php"); exit; } $admin_name = $_SESSION['admin_name']; // Get quiz_id or participant_id if passed $quiz_id = isset($_GET['quiz_id']) ? intval($_GET['quiz_id']) : 0; $participant_id = isset($_GET['participant_id']) ? intval($_GET['participant_id']) : 0; // Fetch quizzes for selection $quiz_res = mysqli_query($conn, "SELECT quiz_id, title FROM quizzes ORDER BY quiz_id DESC"); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Quiz Reports</title> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet"> <style> body { font-family: 'Poppins', sans-serif; background: #f4f6f8; margin:0; } .navbar { background: linear-gradient(90deg,#6a11cb,#2575fc); color: white; padding: 15px 50px; display:flex; justify-content: space-between; align-items: center; } .navbar a { color:white; text-decoration: none; margin-left:20px; font-weight:600; } .navbar a:hover { text-decoration: underline; } .container { width: 95%; margin: 30px auto; } h2 { color: #6a11cb; margin-bottom: 15px; } table { width: 100%; border-collapse: collapse; margin-bottom: 30px; } table th, table td { border:1px solid #ddd; padding: 10px; text-align: left; } table th { background: #6a11cb; color: white; } table tr:hover { background: #f3f3f3; } button { background: #2575fc; color:white; border:none; padding:6px 12px; border-radius:6px; cursor:pointer; transition:0.3s; } button:hover { background: #6a11cb; } form select { padding:8px 12px; border-radius:6px; margin-right:10px; border:1px solid #ccc; } form input[type=submit] { padding:8px 16px; border:none; background:#28a745; color:white; border-radius:6px; cursor:pointer; font-weight:600; } form input[type=submit]:hover { background:#218838; } </style> </head> <body> <div class="navbar"> <h1>Quiz Reports</h1> <div> Welcome, <b><?php echo htmlspecialchars($admin_name); ?></b> | <a href="index.php">Dashboard</a> | <a href="admin_logout.php">Logout</a> </div> </div> <div class="container"> <h2>📊 Quiz Reports</h2> <!-- Quiz Selection Form --> <form method="GET" action=""> <label>Select Quiz:</label> <select name="quiz_id"> <option value="0">-- All Quizzes --</option> <?php while($quiz = mysqli_fetch_assoc($quiz_res)): ?> <option value="<?php echo $quiz['quiz_id']; ?>" <?php if($quiz_id==$quiz['quiz_id']) echo 'selected'; ?>> <?php echo htmlspecialchars($quiz['title']); ?> </option> <?php endwhile; ?> </select> <input type="submit" value="View Reports"> </form> <?php // Build query for reports $query = " SELECT q.quiz_id, q.title AS quiz_title, p.participant_id, p.name AS participant_name, qa.score, qa.total_marks, qa.started_at, qa.completed_at FROM quiz_attempts qa JOIN participants p ON qa.participant_id = p.participant_id JOIN quizzes q ON qa.quiz_id = q.quiz_id "; $conditions = []; if($quiz_id > 0) $conditions[] = "qa.quiz_id='$quiz_id'"; if($participant_id > 0) $conditions[] = "qa.participant_id='$participant_id'"; if(count($conditions)>0) $query .= " WHERE ".implode(" AND ", $conditions); $query .= " ORDER BY qa.completed_at DESC"; $report_res = mysqli_query($conn, $query); if(mysqli_num_rows($report_res) > 0): ?> <table> <tr> <th>Quiz</th> <th>Participant</th> <th>Score</th> <th>Total Marks</th> <th>Start Time</th> <th>Completion Time</th> </tr> <?php while($row = mysqli_fetch_assoc($report_res)): ?> <tr> <td><?php echo htmlspecialchars($row['quiz_title']); ?></td> <td><?php echo htmlspecialchars($row['participant_name']); ?></td> <td><?php echo $row['score']; ?></td> <td><?php echo $row['total_marks']; ?></td> <td><?php echo $row['started_at']; ?></td> <td><?php echo $row['completed_at']; ?></td> </tr> <?php endwhile; ?> </table> <?php else: ?> <p>No quiz attempts found.</p> <?php endif; ?> </div> </body> </html>
💾 Kaydet
İptal