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

try {
    // Check if online exams exist
    $stmt = $pdo->query("SELECT * FROM online_exams");
    $exams = $stmt->fetchAll();
    
    echo "Online Exams:\n";
    foreach ($exams as $exam) {
        echo "ID: " . $exam['id'] . " - Name: " . $exam['name'] . "\n";
        
        // Check questions for this exam
        $stmt = $pdo->prepare("SELECT * FROM online_exam_questions WHERE online_exam_id = ?");
        $stmt->execute([$exam['id']]);
        $questions = $stmt->fetchAll();
        
        echo "  Questions:\n";
        foreach ($questions as $question) {
            echo "    Q" . $question['id'] . ": " . substr($question['question_text'], 0, 50) . "...\n";
        }
        echo "\n";
    }
    
    // Check if the student responses table exists and has data
    $stmt = $pdo->query("SELECT * FROM online_exam_student_responses");
    $responses = $stmt->fetchAll();
    
    echo "Student Responses:\n";
    foreach ($responses as $response) {
        echo "Response ID: " . $response['id'] . " - Exam: " . $response['online_exam_id'] . " - Student: " . $response['student_id'] . " - Question: " . $response['question_id'] . "\n";
    }
    
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
?>