-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_view_exams.php
More file actions
211 lines (176 loc) · 5.11 KB
/
Copy pathadmin_view_exams.php
File metadata and controls
211 lines (176 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?php
session_start();
require "config.php";
if (!isset($_SESSION['id']) || $_SESSION['role'] !== 'admin') {
die("Access denied");
}
/* --------------------------------
FETCH EXAMS (NO duration column)
--------------------------------- */
$exams = $pdo->query("
SELECT
e.id,
e.title,
e.start_at,
e.end_at,
e.created_at,
d.name AS department_name
FROM exams e
LEFT JOIN departments d ON e.department_id = d.id
ORDER BY e.start_at DESC
")->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Admin | Exams Management</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
margin: 0;
font-family: 'Segoe UI', Tahoma, sans-serif;
background: #f4f6f9;
}
.container {
padding: 30px;
}
h2 {
margin-bottom: 20px;
font-size: 22px;
}
/* Card */
.card {
background: #fff;
border-radius: 10px;
padding: 20px;
box-shadow: 0 6px 18px rgba(0,0,0,.05);
}
/* Table */
.table {
width: 100%;
border-collapse: collapse;
}
.table th,
.table td {
padding: 14px;
border-bottom: 1px solid #eee;
font-size: 14px;
}
.table th {
background: #f9fafb;
font-size: 12px;
text-transform: uppercase;
letter-spacing: .04em;
}
.table tr:hover {
background: #f3f4f6;
}
/* Status badge */
.badge {
padding: 5px 10px;
border-radius: 6px;
font-size: 12px;
font-weight: 600;
}
.badge.upcoming { background:#e0f2fe; color:#0369a1; }
.badge.active { background:#dcfce7; color:#166534; }
.badge.closed { background:#fee2e2; color:#991b1b; }
/* Actions */
.actions {
text-align: right;
white-space: nowrap;
}
.btn {
padding: 7px 12px;
border-radius: 6px;
border: none;
font-size: 13px;
cursor: pointer;
}
.btn-view { background:#2563eb; color:#fff; }
.btn-edit { background:#f59e0b; color:#fff; }
.btn-delete { background:#dc2626; color:#fff; }
.close-btn {
background: #2563eb;
color: #fff;
padding: 10px 14px;
border-radius: 6px;
text-decoration: none;
font-weight: 600;
cursor: pointer;
}
@media (max-width: 768px) {
.container { padding: 15px; }
}
</style>
</head>
<body>
<div class="container">
<span class="close-btn" title="Close" onclick="window.location='student_dashboard.php'">×</span>
<h2>Examinations Management</h2>
<div class="card">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Exam Title</th>
<th>Department</th>
<th>Start Time</th>
<th>End Time</th>
<th>Status</th>
<th style="text-align:right;">Actions</th>
</tr>
</thead>
<tbody>
<?php if (!$exams): ?>
<tr>
<td colspan="7">No exams found.</td>
</tr>
<?php else: ?>
<?php foreach ($exams as $i => $e): ?>
<?php
$now = date("Y-m-d H:i:s");
if ($e['start_at'] && $e['start_at'] > $now) {
$status = "upcoming";
$label = "Upcoming";
} elseif ($e['end_at'] && $e['end_at'] < $now) {
$status = "closed";
$label = "Closed";
} else {
$status = "active";
$label = "Active";
}
?>
<tr>
<td><?= $i + 1 ?></td>
<td><?= htmlspecialchars($e['title']) ?></td>
<td><?= htmlspecialchars($e['department_name'] ?? 'All Departments') ?></td>
<td>
<?= $e['start_at'] ? date("d M Y H:i", strtotime($e['start_at'])) : '—' ?>
</td>
<td>
<?= $e['end_at'] ? date("d M Y H:i", strtotime($e['end_at'])) : '—' ?>
</td>
<td>
<span class="badge <?= $status ?>">
<?= $label ?>
</span>
</td>
<td class="actions">
<a href="view_exam.php?id=<?= $e['id'] ?>" class="btn btn-view">View</a>
<a href="edit_exam.php?id=<?= $e['id'] ?>" class="btn btn-edit">Edit</a>
<a href="delete_exam.php?id=<?= $e['id'] ?>" class="btn btn-delete"
onclick="return confirm('Delete this exam?')">
Delete
</a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</body>
</html>