📁 File Manager
🏠 /
/
home
/
u857492117
/
domains
/
mangaldaicollege.org
/
public_html
/
dk1
/
admin
Dosya Düzenle: index.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>Admin Dashboard</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 */ .navbar { background: linear-gradient(90deg,#6a11cb,#2575fc); color: white; padding: 15px 50px; display:flex; justify-content: space-between; align-items: center; flex-wrap:wrap; } .navbar h1 { margin:0; font-size:24px; } .navbar .links a { color:white; text-decoration: none; margin-left:20px; font-weight:600; } .navbar .links a:hover { text-decoration: underline; } /* Quick Menu */ .quick-menu { background:#2575fc; padding:10px 50px; display:flex; gap:15px; flex-wrap:wrap; } .quick-menu a { color:white; text-decoration:none; font-weight:600; padding:8px 12px; border-radius:6px; background: #6a11cb; transition:0.3s; } .quick-menu a:hover { background:#1a0595; } /* Container */ .container { width: 95%; max-width:1400px; margin: 30px auto; } h2 { color: #6a11cb; margin-bottom: 15px; } /* Tables */ 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; } /* Buttons */ button, .btn, .add-btn { cursor:pointer; font-weight:600; border:none; border-radius:6px; padding:6px 12px; text-decoration:none; transition:0.3s; display:inline-block;} button, .btn { background:#2575fc; color:white; } button:hover, .btn:hover { background:#6a11cb; } .add-btn { background:#28a745; margin-bottom:10px; } .add-btn:hover { background:#218838; } /* Sections */ .section { margin-bottom:50px; } </style> </head> <body> <!-- Top Navbar --> <div class="navbar"> <h1>Admin Dashboard</h1> <div class="links"> Welcome, <b><?php echo htmlspecialchars($admin_name); ?></b> | <a href="admin_logout.php">Logout</a> </div> </div> <!-- Quick Access Menu --> <div class="quick-menu"> <a href="#quiz-section">Quiz Management</a> <a href="#leaderboard-section">Leaderboard & Reports</a> <a href="#user-section">User Management</a> </div> <div class="container"> <!-- Quiz Management --> <div id="quiz-section" class="section"> <h2>📋 Quiz Management</h2> <a class="add-btn" href="add_quiz.php">➕ Add New Quiz</a> <?php $quiz_res = mysqli_query($conn, "SELECT * FROM quizzes ORDER BY 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>Actions</th> </tr> <?php while($quiz = mysqli_fetch_assoc($quiz_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> <a href="view_quiz.php?quiz_id=<?php echo $quiz['quiz_id']; ?>" class="btn">View Quiz</a> <a href="add_questions.php?quiz_id=<?php echo $quiz['quiz_id']; ?>" class="btn">Add Questions</a> <a href="edit_quiz.php?quiz_id=<?php echo $quiz['quiz_id']; ?>" class="btn">Edit</a> <a href="delete_quiz.php?quiz_id=<?php echo $quiz['quiz_id']; ?>" onclick="return confirm('Are you sure?');" class="btn">Delete</a> </td> </tr> <?php endwhile; ?> </table> <?php else: ?> <p>No quizzes added yet.</p> <?php endif; ?> </div> <!-- Leaderboard / Reports --> <div id="leaderboard-section" class="section"> <h2>🏆 Leaderboard & Reports</h2> <?php $leader_res = mysqli_query($conn, " SELECT q.quiz_id, q.title AS quiz_title, p.name AS participant_name, qa.score, RANK() OVER (PARTITION BY q.quiz_id ORDER BY qa.score DESC) AS rank_position FROM quiz_attempts qa JOIN participants p ON qa.participant_id = p.participant_id JOIN quizzes q ON qa.quiz_id = q.quiz_id ORDER BY q.quiz_id, rank_position "); if(mysqli_num_rows($leader_res) > 0): ?> <table> <tr> <th>Quiz</th> <th>Participant</th> <th>Score</th> <th>Rank</th> </tr> <?php while($row = mysqli_fetch_assoc($leader_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['rank_position']; ?></td> </tr> <?php endwhile; ?> </table> <?php else: ?> <p>No attempts yet.</p> <?php endif; ?> </div> <!-- User Management --> <div id="user-section" class="section"> <h2>👥 User Management</h2> <?php $users_res = mysqli_query($conn, " SELECT participant_id, name, email, phone, age, created_at FROM participants ORDER BY participant_id DESC "); if(mysqli_num_rows($users_res) > 0): ?> <table> <tr> <th>ID</th> <th>Name</th> <th>Email</th> <th>Phone</th> <th>Age</th> <th>Registered At</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['age']; ?></td> <td><?php echo $user['created_at']; ?></td> <td> <a href="quiz_reports.php?participant_id=<?php echo $user['participant_id']; ?>" class="btn">View Reports</a> <a href="user_statistics.php?participant_id=<?php echo $user['participant_id']; ?>" class="btn">Statistics</a> <a href="delete_user.php?participant_id=<?php echo $user['participant_id']; ?>" onclick="return confirm('Are you sure to delete this user?');" class="btn">Delete</a> </td> </tr> <?php endwhile; ?> </table> <?php else: ?> <p>No users registered yet.</p> <?php endif; ?> </div> </div> </body> </html>
💾 Kaydet
İptal