<?php
session_start();

if (!isset($_SESSION['user_id']) || !isset($_SESSION['students'])) {
    header("Location: teacher_session.php");
    exit();
}

$students = $_SESSION['students'];
?>

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

<div class="dashboard-wrap">

    <h2>
        Class: <?php echo htmlspecialchars($_SESSION['class_name']); ?>
    </h2>

    <p class="sub">
        Teacher: <?php echo htmlspecialchars($_SESSION['teacher_name']); ?>
    </p>

    <table style="width:100%; margin-top:30px; border-collapse:collapse;">
        <thead>
            <tr style="color:#cbd5e1; border-bottom:1px solid rgba(255,255,255,0.2);">
                <th align="left">Roll No</th>
                <th align="left">Student Name</th>
                <th align="left">Action</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($students as $s): ?>
            <tr style="border-bottom:1px solid rgba(255,255,255,0.1);">
                <td><?php echo htmlspecialchars($s['roll']); ?></td>
                <td><?php echo htmlspecialchars($s['name']); ?></td>
                <td>
                    <a href="learning_style.php?roll=<?php echo urlencode($s['roll']); ?>&name=<?php echo urlencode($s['name']); ?>"
                       style="color:#38bdf8;">
                        Start Assessment
                    </a>
                </td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>

    <a href="dashboard.php" class="back-link">← Back to Dashboard</a>
</div>

</body>
</html>
