<?php
require_once 'config/database.php';

try {
    // Check total 4th subjects assigned
    $stmt = $pdo->prepare('SELECT COUNT(*) as count FROM student_subjects WHERE is_fourth_subject = 1');
    $stmt->execute();
    $result = $stmt->fetch();
    echo 'Total 4th subjects assigned: ' . $result['count'] . PHP_EOL;

    // Get sample 4th subjects
    $stmt = $pdo->prepare('SELECT ss.student_id, s.first_name, s.last_name, sub.name as subject_name FROM student_subjects ss JOIN subjects sub ON ss.subject_id = sub.id JOIN students s ON ss.student_id = s.id WHERE ss.is_fourth_subject = 1 LIMIT 5');
    $stmt->execute();
    $results = $stmt->fetchAll();
    echo 'Sample 4th subjects:' . PHP_EOL;
    foreach ($results as $result) {
        echo '  Student: ' . $result['first_name'] . ' ' . $result['last_name'] . ' - Subject: ' . $result['subject_name'] . PHP_EOL;
    }

} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}
?>