<?php
session_start();
require_once "config.php";

if (!isset($_GET['quiz_id'])) {
    die("Quiz ID missing.");
}

$quiz_id = intval($_GET['quiz_id']);

// Fetch quiz details
$quiz = $conn->query("SELECT * FROM manual_quizzes WHERE id = $quiz_id");
if ($quiz->num_rows == 0) {
    die("Quiz not found.");
}
$quiz = $quiz->fetch_assoc();
?>
<!DOCTYPE html>
<html>
<head>
    <title>Enter Answers - RS Learning Lab</title>
</head>
<body>
<h2>Enter Answers for Quiz: <?php echo $quiz['quiz_name']; ?></h2>

<form method="POST" action="save_manual_answers.php">
    <input type="hidden" name="quiz_id" value="<?php echo $quiz_id; ?>">

    Student Name: <input type="text" name="student_name" required><br><br>
    Roll Number: <input type="text" name="roll_no" required><br><br>

    <?php for ($i = 1; $i <= $quiz['total_questions']; $i++): ?>
        Q<?php echo $i; ?>:
        <select name="answers[]">
            <option value="">-</option>
            <option>A</option>
            <option>B</option>
            <option>C</option>
            <option>D</option>
        </select>
        <br>
    <?php endfor; ?>

    <button type="submit">Save Answers</button>
</form>

</body>
</html>
