<?php
session_start();
require_once __DIR__ . '/config/db.php';

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

$stmt = $pdo->prepare("
    SELECT learning_style, COUNT(*) as count
    FROM learning_styles
    WHERE user_id = ?
    GROUP BY learning_style
");
$stmt->execute([$_SESSION['user_id']]);
$summary = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>

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

<div class="dashboard-wrap">

    <h2>Class Learning Style Summary</h2>
    <p class="sub">
        Overview of how students in your class prefer to learn.
    </p>

    <div class="dashboard-cards">

        <?php foreach ($summary as $row): ?>
            <div class="dash-card">
                <h3><?php echo $row['learning_style']; ?></h3>
                <p><?php echo $row['count']; ?> students</p>
            </div>
        <?php endforeach; ?>

    </div>

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

</body>
</html>
