<?php require_once __DIR__.'/../includes/auth.php'; require_login(['staff','manager','admin']); require __DIR__.'/../includes/header.php'; $uid=current_user()['id'];
$sql='SELECT c.*, lp.name path_name, COALESCE(cp.status,"not_started") status, COALESCE(cp.score,0) score FROM user_learning_paths ulp JOIN learning_paths lp ON lp.id=ulp.learning_path_id JOIN courses c ON c.learning_path_id=lp.id LEFT JOIN course_progress cp ON cp.course_id=c.id AND cp.user_id=ulp.user_id WHERE ulp.user_id=? ORDER BY lp.level,c.sort_order'; $stmt=db()->prepare($sql); $stmt->execute([$uid]); $courses=$stmt->fetchAll(); ?>
<div class="card hero"><img src="../assets/chuck-logo.png" class="logo"><h1>My Learning</h1><p>Complete your assigned training and certificates.</p></div>
<div class="grid"><?php foreach($courses as $c): ?><div class="card"><h2><?= htmlspecialchars($c['title']) ?></h2><p class="meta"><?= htmlspecialchars($c['path_name']) ?></p><span class="pill"><?= htmlspecialchars($c['status']) ?></span><?php if($c['score']): ?><span class="pill">Score <?= $c['score'] ?>%</span><?php endif; ?><p><?= htmlspecialchars($c['summary']) ?></p><a class="btn" href="course.php?id=<?= $c['id'] ?>">Open Course</a></div><?php endforeach; ?></div>
<?php require __DIR__.'/../includes/footer.php'; ?>
