📁 File Manager
🏠 /
/
home
/
u857492117
/
domains
/
mangaldaicollege.org
/
public_html
/
dk1
/
admin
Dosya Düzenle: quiz_management.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']; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Quiz Management</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%; max-width:1400px; margin: 30px auto; } h2 { color: #6a11cb; margin-bottom: 20px; } /* Table Styles */ 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, .btn { background: #2575fc; color:white; border:none; padding:6px 12px; border-radius:6px; cursor:pointer; transition:0.3s; text-decoration:none; display:inline-block; font-weight:600;} button:hover, .btn:hover { background: #6a11cb; } /* Add Quiz Button */ .add-btn { background: #28a745; margin-bottom: 15px; display: inline-block; padding:8px 16px; border-radius:6px; text-decoration:none; color:white; font-weight:600; } .add-btn:hover { background: #218838; } /* Attempt Stats */ .attempt-box { background:#eef2f7; padding:10px; border-radius:8px; margin-top:5px; font-size:14px; } </style> </head> <body> <div class="navbar"> <h1>Admin Dashboard</h1> <div> Welcome, <b><?php echo htmlspecialchars($admin_name); ?></b> | <a href="admin_logout.php">Logout</a> </div> </div> <div class="container"> <h2>📋 Quiz Management</h2> <a class="add-btn" href="add_quiz.php">➕ Add New Quiz</a> <?php $quiz_res = mysqli_query($conn, "SELECT q.*, a.name AS created_by_name FROM quizzes q LEFT JOIN admin_users a ON q.created_by=a.admin_id ORDER BY q.quiz_id DESC"); if(mysqli_num_rows($quiz_res) > 0): ?> <table> <tr> <th>ID</th> <th>Title</th> <th>Description</th> <th>Total Questions</th> <th>Duration (min)</th> <th>Created By</th> <th>Attempts</th> <th>Actions</th> </tr> <?php while($quiz = mysqli_fetch_assoc($quiz_res)): // Fetch attempts summary $attempts_res = mysqli_query($conn, "SELECT COUNT(*) AS total_attempts, MAX(score) AS highest_score, AVG(score) AS avg_score FROM quiz_attempts WHERE quiz_id=".$quiz['quiz_id']); $attempts = mysqli_fetch_assoc($attempts_res); ?> <tr> <td><?php echo $quiz['quiz_id']; ?></td> <td><?php echo htmlspecialchars($quiz['title']); ?></td> <td><?php echo htmlspecialchars($quiz['description']); ?></td> <td><?php echo $quiz['total_questions']; ?></td> <td><?php echo $quiz['duration']; ?></td> <td><?php echo htmlspecialchars($quiz['created_by_name']); ?></td> <td> <div class="attempt-box">Total: <?php echo $attempts['total_attempts']; ?></div> <div class="attempt-box">Highest: <?php echo $attempts['highest_score'] ?? 0; ?></div> <div class="attempt-box">Average: <?php echo round($attempts['avg_score'] ?? 0,2); ?></div> <a href="quiz_reports.php?quiz_id=<?php echo $quiz['quiz_id']; ?>" class="btn">View Details</a> </td> <td> <a class="btn" href="add_questions.php?quiz_id=<?php echo $quiz['quiz_id']; ?>">Add Questions</a><br><br> <a class="btn" href="edit_quiz.php?quiz_id=<?php echo $quiz['quiz_id']; ?>">Edit</a><br><br> <a class="btn" href="delete_quiz.php?quiz_id=<?php echo $quiz['quiz_id']; ?>" onclick="return confirm('Are you sure?');">Delete</a> </td> </tr> <?php endwhile; ?> </table> <?php else: ?> <p>No quizzes added yet.</p> <?php endif; ?> </div> </body> </html>
💾 Kaydet
İptal