<?php
require_once 'config/database.php';
$db = getDB();

$modules = $db->query('SELECT id, title FROM course_modules WHERE course_id = 14 ORDER BY sort_order')->fetchAll(PDO::FETCH_ASSOC);
foreach ($modules as $m) {
    $topics = $db->prepare('SELECT id FROM course_topics WHERE module_id = ?');
    $topics->execute([$m['id']]);
    $topicCount = $topics->rowCount();
    
    $lessons = $db->prepare('SELECT id, title FROM course_lessons WHERE module_id = ?');
    $lessons->execute([$m['id']]);
    $lessonRows = $lessons->fetchAll(PDO::FETCH_ASSOC);
    
    echo "Module {$m['id']}: {$m['title']} | topics: {$topicCount} | lessons: " . count($lessonRows) . "\n";
    
    // Show lesson titles
    foreach ($lessonRows as $l) {
        echo "  - Lesson {$l['id']}: {$l['title']}\n";
    }
}