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

/* 🔒 SAFETY CHECK */
if (!isset($_SESSION['reinforcement_done'])) {
    header("Location: practice_reinforcement.php");
    exit();
}

$score = $_SESSION['reinforcement_score'] ?? 0;
$feedback = $_SESSION['reinforcement_feedback'] ?? [];
?>

<div class="result-container">

    <h2>Reinforcement Completed ✅</h2>

    <p>
        You have completed the reinforcement test.
        This stage helps you understand where to improve.
    </p>

    <p>
        <strong>Your Score:</strong> <?php echo $score; ?>
    </p>

    <?php if (!empty($feedback)): ?>
        <h3>Learning Suggestions</h3>
        <ul class="motivation-list">
            <?php foreach ($feedback as $item): ?>
                <li>
                    <strong><?php echo htmlspecialchars($item['concept']); ?>:</strong>
                    <?php echo htmlspecialchars($item['message']); ?>
                </li>
            <?php endforeach; ?>
        </ul>
    <?php else: ?>
        <p class="success">
            Excellent! You have a strong understanding of all concepts.
        </p>
    <?php endif; ?>

    <div class="actions">
        <a href="final_assessment_intro.php" class="btn primary">
            Proceed to Final Assessment
        </a>
        <br><br>
        <a href="dashboard.php">Go to Dashboard</a>
    </div>

</div>

<?php require_once 'includes/footer.php'; ?>
