-- name: GetFullLearningTree :many
SELECT
    c.id AS course_id,
    c.title AS course_title,
    p.id AS program_id,
    p.title AS program_title,
    l.id AS level_id,
    l.title AS level_title,
    m.id AS module_id,
    m.title AS module_title
FROM courses c
JOIN programs p ON p.course_id = c.id
JOIN levels l ON l.program_id = p.id
LEFT JOIN modules m ON m.level_id = l.id
WHERE c.is_active = true
ORDER BY p.display_order, l.level_index, m.display_order;
