📁 File Manager
🏠 /
/
home
/
u857492117
/
domains
/
mangaldaicollege.org
/
public_html
/
dk1
/
admin
Dosya Düzenle: user_statistics.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']; // Fetch participants with statistics $users_res = mysqli_query($conn, " SELECT p.participant_id, p.name, p.email, p.phone, COUNT(qa.attempt_id) AS total_attempts, COALESCE(AVG(qa.score),0) AS avg_score, COALESCE(MAX(qa.score),0) AS highest_score FROM participants p LEFT JOIN quiz_attempts qa ON p.participant_id = qa.participant_id GROUP BY p.participant_id ORDER BY p.participant_id DESC "); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>User Statistics</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; margin-right:5px; } </style> </head> <body> <div class="navbar"> <h1>User Statistics</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>👥 Participant List</h2> <?php if(mysqli_num_rows($users_res) > 0): ?> <table> <tr> <th>ID</th> <th>Name</th> <th>Email</th> <th>Phone</th> <th>Total Attempts</th> <th>Average Score</th> <th>Highest Score</th> <th>Actions</th> </tr> <?php while($user = mysqli_fetch_assoc($users_res)): ?> <tr> <td><?php echo $user['participant_id']; ?></td> <td><?php echo htmlspecialchars($user['name']); ?></td> <td><?php echo htmlspecialchars($user['email']); ?></td> <td><?php echo htmlspecialchars($user['phone']); ?></td> <td><?php echo $user['total_attempts']; ?></td> <td><?php echo round($user['avg_score'],2); ?></td> <td><?php echo $user['highest_score']; ?></td> <td> <a href="quiz_reports.php?participant_id=<?php echo $user['participant_id']; ?>"><button>View Reports</button></a> <a href="delete_user.php?participant_id=<?php echo $user['participant_id']; ?>" onclick="return confirm('Are you sure to delete this participant?');"><button>Delete</button></a> </td> </tr> <?php endwhile; ?> </table> <?php else: ?> <p>No participants found.</p> <?php endif; ?> </div> </body> </html>
💾 Kaydet
İptal