-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_view_assignment.php
More file actions
193 lines (163 loc) · 4.09 KB
/
Copy pathadmin_view_assignment.php
File metadata and controls
193 lines (163 loc) · 4.09 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
<?php
session_start();
require "config.php";
if (!isset($_SESSION['id']) || $_SESSION['role'] !== 'admin') {
die("Access denied");
}
/* --------------------------------
FETCH ASSIGNMENTS (NO DEADLINE)
--------------------------------- */
$assignments = $pdo->query("
SELECT
a.id,
a.title,
a.created_at,
c.code AS course_code,
c.title AS course_title,
u.full_name AS posted_by
FROM assignments a
JOIN courses c ON a.course_id = c.id
LEFT JOIN users u ON a.posted_by = u.id
ORDER BY a.created_at DESC
")->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Assignments 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;
color: #333;
}
.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;
}
.badge {
background: #e0e7ff;
color: #1e40af;
padding: 5px 10px;
border-radius: 6px;
font-size: 12px;
}
/* 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-disable {
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">
<h2>Assignments Management</h2>
<span class="close-btn" title="Close" onclick="window.location='student_dashboard.php'">×</span>
<div class="card">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Assignment Title</th>
<th>Course</th>
<th>Date Posted</th>
<th>Posted By</th>
<th style="text-align:right;">Actions</th>
</tr>
</thead>
<tbody>
<?php if (!$assignments): ?>
<tr>
<td colspan="6">No assignments found.</td>
</tr>
<?php else: ?>
<?php foreach ($assignments as $i => $a): ?>
<tr>
<td><?= $i + 1 ?></td>
<td><?= htmlspecialchars($a['title']) ?></td>
<td>
<span class="badge"><?= htmlspecialchars($a['course_code']) ?></span>
<?= htmlspecialchars($a['course_title']) ?>
</td>
<td><?= date("d M Y", strtotime($a['created_at'])) ?></td>
<td><?= htmlspecialchars($a['posted_by'] ?? 'System') ?></td>
<td class="actions">
<button class="btn btn-view">View</button>
<button class="btn btn-edit">Edit</button>
<button class="btn btn-disable">Disable</button>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</body>
</html>