69 lines
1.0 KiB
PHP
69 lines
1.0 KiB
PHP
<?php
|
|
require_once(__DIR__ . "/../config/db.php");
|
|
|
|
$stmt = $pdo->query("
|
|
SELECT student_name, class, MAX(score) as best_score
|
|
FROM project_submissions
|
|
WHERE status='approved'
|
|
GROUP BY student_id
|
|
ORDER BY best_score DESC
|
|
LIMIT 10
|
|
");
|
|
|
|
$students = $stmt->fetchAll();
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Leaderboard | RS Learning Lab</title>
|
|
<style>
|
|
body{
|
|
background:#020617;
|
|
color:#fff;
|
|
font-family:Arial;
|
|
text-align:center;
|
|
}
|
|
table{
|
|
margin:50px auto;
|
|
border-collapse:collapse;
|
|
width:60%;
|
|
}
|
|
th, td{
|
|
padding:12px;
|
|
border-bottom:1px solid #444;
|
|
}
|
|
th{
|
|
color:#22c55e;
|
|
}
|
|
.rank{
|
|
font-weight:bold;
|
|
color:#facc15;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<h1>🏆 Leaderboard</h1>
|
|
|
|
<table>
|
|
<tr>
|
|
<th>Rank</th>
|
|
<th>Name</th>
|
|
<th>Class</th>
|
|
<th>Score</th>
|
|
</tr>
|
|
|
|
<?php $rank=1; foreach($students as $s): ?>
|
|
<tr>
|
|
<td class="rank"><?= $rank++ ?></td>
|
|
<td><?= htmlspecialchars($s['student_name']) ?></td>
|
|
<td><?= htmlspecialchars($s['class']) ?></td>
|
|
<td><?= $s['best_score'] ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
|
|
</table>
|
|
|
|
</body>
|
|
</html>
|