📁 File Manager
🏠 /
/
home
/
u857492117
/
domains
/
mangaldaicollege.org
/
public_html
/
dk1
/
admin
Dosya Düzenle: view_quiz.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 from URL if(!isset($_GET['quiz_id'])){ header("Location: index.php"); exit; } $quiz_id = intval($_GET['quiz_id']); // Fetch quiz details $quiz_res = mysqli_query($conn, "SELECT * FROM quizzes WHERE quiz_id = '$quiz_id'"); if(mysqli_num_rows($quiz_res) == 0){ echo "Quiz not found!"; exit; } $quiz = mysqli_fetch_assoc($quiz_res); // Fetch all questions for this quiz $questions_res = mysqli_query($conn, " SELECT * FROM question_bank WHERE quiz_id = '$quiz_id' ORDER BY question_id ASC "); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>View Quiz Questions</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; margin-right:5px; } button:hover { background: #6a11cb; } .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; } </style> </head> <body> <div class="navbar"> <h1>View Quiz: <?php echo htmlspecialchars($quiz['title']); ?></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"> <a class="add-btn" href="add_questions.php?quiz_id=<?php echo $quiz_id; ?>">➕ Add Question</a> <?php if(mysqli_num_rows($questions_res) > 0): ?> <table> <tr> <th>ID</th> <th>Question</th> <th>Options (A/B/C/D)</th> <th>Correct Answer</th> <th>Difficulty</th> <th>Marks</th> <th>Actions</th> </tr> <?php while($q = mysqli_fetch_assoc($questions_res)): ?> <tr> <td><?php echo $q['question_id']; ?></td> <td><?php echo htmlspecialchars($q['question_text']); ?></td> <td> A: <?php echo htmlspecialchars($q['option_a']); ?><br> B: <?php echo htmlspecialchars($q['option_b']); ?><br> C: <?php echo htmlspecialchars($q['option_c']); ?><br> D: <?php echo htmlspecialchars($q['option_d']); ?> </td> <td><?php echo $q['correct_answer']; ?></td> <td><?php echo ucfirst($q['difficulty_level']); ?></td> <td><?php echo $q['marks']; ?></td> <td> <a href="edit_question.php?question_id=<?php echo $q['question_id']; ?>"><button>Edit</button></a> <a href="delete_question.php?question_id=<?php echo $q['question_id']; ?>" onclick="return confirm('Are you sure to delete this question?');"><button>Delete</button></a> </td> </tr> <?php endwhile; ?> </table> <?php else: ?> <p>No questions added for this quiz yet.</p> <?php endif; ?> </div> </body> </html>
💾 Kaydet
İptal