<?php require_once __DIR__.'/../includes/auth.php'; require_login(['staff','manager','admin']); $uid=current_user()['id']; $id=(int)($_GET['id']??0);
$stmt=db()->prepare('SELECT c.* FROM courses c JOIN user_learning_paths ulp ON ulp.learning_path_id=c.learning_path_id WHERE c.id=? AND ulp.user_id=?'); $stmt->execute([$id,$uid]); $course=$stmt->fetch(); if(!$course){ http_response_code(404); exit('Course not assigned'); }
$mods=db()->prepare('SELECT * FROM modules WHERE course_id=? ORDER BY sort_order'); $mods->execute([$id]); $modules=$mods->fetchAll(); require __DIR__.'/../includes/header.php'; ?>
<div class="card"><h1><?= htmlspecialchars($course['title']) ?></h1><p><?= htmlspecialchars($course['summary']) ?></p><a class="btn" href="quiz.php?course=<?= $course['id'] ?>">Take Assessment</a></div>
<?php foreach($modules as $m): ?><div class="card"><h2><?= htmlspecialchars($m['title']) ?></h2><div><?= $m['body_html'] ?></div><?php if($m['asset_path']): ?><img class="lesson-img" src="../<?= htmlspecialchars($m['asset_path']) ?>"><?php endif; ?></div><?php endforeach; ?>
<?php require __DIR__.'/../includes/footer.php'; ?>
