74 lines
2.9 KiB
PHP
74 lines
2.9 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
// Redirect to login if user is not logged in or not a student
|
|
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'siswa') {
|
|
header("Location: login.php?role=siswa");
|
|
exit();
|
|
}
|
|
|
|
// Fetch all exams
|
|
$exams_stmt = db()->prepare("SELECT * FROM exams ORDER BY created_at DESC");
|
|
$exams_stmt->execute();
|
|
$exams = $exams_stmt->fetchAll();
|
|
|
|
$page_title = "Dashboard Siswa";
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo $page_title; ?> - Ulangan Harian Online</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
</head>
|
|
<body>
|
|
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
|
<div class="container">
|
|
<a class="navbar-brand" href="#">Dashboard Siswa</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav ms-auto">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="logout.php">Logout</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container mt-4">
|
|
<h1>Selamat datang, <?php echo htmlspecialchars($_SESSION['full_name']); ?>!</h1>
|
|
<p>Ini adalah halaman dasbor Anda.</p>
|
|
|
|
<div class="mt-5">
|
|
<h2>Ujian Tersedia</h2>
|
|
<?php if (count($exams) > 0): ?>
|
|
<div class="list-group">
|
|
<?php foreach ($exams as $exam): ?>
|
|
<div class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<h5 class="mb-1"><?php echo htmlspecialchars($exam['title']); ?></h5>
|
|
<p class="mb-1"><?php echo htmlspecialchars($exam['description']); ?></p>
|
|
</div>
|
|
<a href="take_exam.php?exam_id=<?php echo $exam['id']; ?>" class="btn btn-success">Kerjakan</a>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="alert alert-info">
|
|
Saat ini belum ada ujian yang tersedia.
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|