<?php
session_start();

$name  = $_POST['name'] ?? 'Student';
$roll  = $_POST['roll'] ?? 'NA';
$class = $_POST['class'] ?? '';
$lang  = $_POST['lang'] ?? 'python';
$topic_id = $_POST['topic_id'] ?? 1;

/* ✅ Mark reinforcement complete */
$_SESSION['reinforcement_completed'] = true;

/* ✅ Badge unlock */
$_SESSION['earned_badge'] = 'learning_reinforcement';

/* ✅ OPTIONAL: badge generate (you can keep or remove) */
// header("Location: /rs_lab/generate_badge_pdf.php?...");

/* 🔥 IMPORTANT: GO TO FINAL TRACK */
header("Location: /rs_lab/final_track.php?topic_id=$topic_id&name="
    . urlencode($name)
    . "&roll=" . urlencode($roll)
    . "&class=" . urlencode($class)
    . "&lang=" . urlencode($lang)
);
exit;