<?php
require_once __DIR__ . '/../includes/auth_check.php';
session_start();

if (!isset($_SESSION['badge_earned'])) {
    header("Location: reinforcement.php");
    exit;
}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $_SESSION['final_completed'] = true;
    header("Location: ../certificates/preview_certificate.php");
    exit;
}
?>

<!DOCTYPE html>
<html>
<head>
<title>Final Track</title>
<link rel="stylesheet" href="../style.css">
<script>
let time = 60;
setInterval(() => {
    document.getElementById("timer").innerText = time;
    time--;
    if (time < 0) document.forms[0].submit();
}, 1000);
</script>
</head>

<body class="dark">
<h1>Final Assessment</h1>
<p>One attempt · Timer based · Certificate after this</p>
<p>Time left: <span id="timer">60</span>s</p>

<form method="post">
<p>Which data structure uses FIFO?</p>
<label><input type="radio" required> Stack</label><br>
<label><input type="radio"> Queue</label><br>

<br>
<button type="submit">Finish Final Track</button>
</form>

</body>
</html>
