-
Notifications
You must be signed in to change notification settings - Fork 0
/
exams.php
276 lines (243 loc) · 17 KB
/
exams.php
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<?php require_once "inc/header.php";
if(!$user)
{
Helper::redirect('index.php');
}
$user = User::auth();
$ins_course = Course::ofThisTeacher($user->id);
$stu_course = Course::ofThisStudent($user->id);
if(isset($_GET['delete']))
{
$slug = $_GET['slug'];
$flag = Exam::delete($slug);
}
?>
<!-- ============================================================== -->
<!-- Page wrapper -->
<!-- ============================================================== -->
<div class="page-wrapper" style="min-height: 250px;">
<!-- ============================================================== -->
<!-- Bread crumb and right sidebar toggle -->
<!-- ============================================================== -->
<div class="page-breadcrumb bg-white">
<div class="row align-items-center">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">Manage Exam</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<div class="d-md-flex">
<ol class="breadcrumb ms-auto">
<li><a href="index.php" class="fw-normal">Dashboard</a></li>
</ol>
<a href="index.php" target="_blank"
class="btn btn-danger d-none d-md-block pull-right ms-3 hidden-xs hidden-sm waves-effect waves-light text-white">Upgrade
to Pro</a>
</div>
</div>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- ============================================================== -->
<!-- End Bread crumb and right sidebar toggle -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- Container fluid -->
<!-- ============================================================== -->
<div class="container-fluid">
<!-- ============================================================== -->
<!-- Start Page Content -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- Instructor COURSE -->
<!-- ============================================================== -->
<?php if($courseTeacher): ?>
<div class="row">
<div class="col-md-12 col-lg-12 col-sm-12">
<div class="white-box">
<div class="d-md-flex mb-3">
<h3 class="box-title mb-0">Exam Lists as Teacher</h3>
<?php if(isset($flag) && $flag == "success"): ?>
<div class="alert alert-success">Exam DELETE successed!</div>
<?php elseif(isset($flag) and is_array($flag)): ?>
<div class="alert alert-danger"><?php print_r(array_values($flag))?></div>
<?php endif; ?>
<div class="col-md-3 col-sm-4 col-xs-6 ms-auto">
<select class="form-select shadow-none row border-top">
<?php if(empty($ins_course)): ?>
<option value="">No Course</option>
<?php else:
foreach($ins_course as $c):
?>
<option value=""><?= $c->name ?></option>
<?php endforeach;
endif; ?>
</select>
</div>
</div>
<div class="table-responsive">
<table class="table no-wrap text-center">
<thead>
<tr>
<th class="border-top-0">#</th>
<th class="border-top-0">Course</th>
<th class="border-top-0">Questioner</th>
<th class="border-top-0">Exam Topic</th>
<th class="border-top-0">Total Questions</th>
<th class="border-top-0">Marks</th>
<th class="border-top-0">Time Limit</th>
<th class="border-top-0">Actions to Exams</th>
<th class="border-top-0">Options</th>
</tr>
</thead>
<tbody>
<?php $count = 1;
if(($ins_course)):
foreach($ins_course as $c):
$course_name = $c->name;
$course_exam = Exam::ofCourse($c->id);
foreach($course_exam as $ex):
?>
<tr>
<td><?= $count++; ?></td>
<td class="txt-oflo"><?= $course_name ?></td>
<td class="txt-oflo"><?= DB::table('users')->where('id',$ex->ins_id)->getOne()->username; ?></td>
<td class="txt-oflo"><?= $ex->title ?></td>
<td class="txt-oflo"><?= Exam::getTotalQuestions($ex->id) ?></td>
<td class="txt-oflo"><?= Exam::getTotalMark($ex->id) ?></td>
<td><span class="text-danger"><?= $ex->time_limit ?></span></td>
<td>
<a href="add-questions.php?slug=<?= $ex->slug ?>" class="text-primary btn">Add Q <i class="fas fa-plus-circle"></i></a>
<a href="questions.php?exam_slug=<?= $ex->slug ?>" class="text-dark btn">Review Q <i class="fas fa-cubes"></i></a>
</td>
<td>
<a href="edit-exam.php?slug=<?= $ex->slug ?>" class="btn"><i class="fas fa-edit text-info"></i></a>
<a href="exams.php?slug=<?= $ex->slug ?>&delete=true" class="btn"><i class="fas fa-trash text-danger"></i></a>
</td>
</tr>
<?php endforeach;
endforeach;
endif;
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php endif; ?>
<!-- Instructor COURSE -->
<!-- ============================================================== -->
<!-- Student COURSE -->
<!-- ============================================================== -->
<?php if($courseStudent): ?>
<div class="row">
<div class="col-md-12 col-lg-12 col-sm-12">
<div class="white-box">
<div class="d-md-flex mb-3">
<h3 class="box-title mb-0">Exam Lists</h3>
<div class="col-md-3 col-sm-4 col-xs-6 ms-auto">
<select class="form-select shadow-none row border-top">
<?php if(empty($stu_course)): ?>
<option value="">No Course</option>
<?php else:
foreach($stu_course as $c): ?>
<option value=""><?= $c->name ?></option>
<?php endforeach;
endif; ?>
</select>
</div>
</div>
<div class="table-responsive">
<table class="table no-wrap text-center">
<thead>
<tr>
<th class="border-top-0">#</th>
<th class="border-top-0">Course</th>
<th class="border-top-0">Questioner</th>
<th class="border-top-0">Exam Topic</th>
<th class="border-top-0">Total Questions</th>
<th class="border-top-0">Marks</th>
<th class="border-top-0">Time Limit</th>
<th class="border-top-0">Actions</th>
</tr>
</thead>
<tbody>
<?php $count = 1;
if(($stu_course)):
foreach($stu_course as $c):
$course_name = $c->name;
$course_exam = Exam::ofCourse($c->id);
foreach($course_exam as $ex):
?>
<tr>
<td><?= $count++; ?></td>
<td class="txt-oflo"><?= $course_name ?></td>
<td class="txt-oflo"><?= DB::table('users')->where('id',$ex->ins_id)->getOne()->username; ?></td>
<td class="txt-oflo"><?= $ex->title ?></td>
<td class="txt-oflo"><?= $total_question = Exam::getTotalQuestions($ex->id); ?></td>
<td class="txt-oflo"><?= Exam::getTotalMark($ex->id) ?></td>
<td><span class="text-danger"><?= $ex->time_limit ?></span></td>
<td>
<?php if($ex->lunch_date <= date('Y-m-d')):
$stu_exam = DB::table('students_exams')->where('exam_id',$ex->id)->andWhere('student_id',$user->id)->getOne();
if(!$stu_exam):
?>
<a href="answer-exam.php?slug=<?= $ex->slug ?>" class="text-primary btn">Answer <i class="fas fa-cubes"></i></a>
<?php else: ?>
<a href="answer-exam.php?slug=<?= $ex->slug ?>" class="text-success btn">Review <i class="fas fa-bolt"></i></a>
<?php endif; ?>
<?php else: ?>
<a href="exams.php" class="text-dark btn btn-warning">Exam At <?= $ex->lunch_date ?> <i class="far fa-meh"></i></a>
<?php endif; ?>
</td>
</tr>
<?php endforeach;
endforeach;
endif;
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php endif; ?>
<!-- ============================================================== -->
<!-- Student COURSE -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- Student COURSE -->
<!-- ============================================================== -->
<?php if(!$courseStudent && !$courseTeacher): ?>
<div class="row">
<div class="col-md-12 col-lg-12 col-sm-12">
<div class="white-box bg-white">
<h4 class="text-center text-primary ">You have No Enrolled Course ! Try enrolled One !</h4>
</div>
</div>
</div>
<?php endif; ?>
<!-- ============================================================== -->
<!-- Student COURSE -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- End PAge Content -->
<!-- ============================================================== -->
</div>
<!-- ============================================================== -->
<!-- End Container fluid -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- footer -->
<!-- ============================================================== -->
<footer class="footer text-center"> 2021 © Ample Admin brought to you by <a
href="https://www.wrappixel.com/">wrappixel.com</a>
</footer>
<!-- ============================================================== -->
<!-- End footer -->
<!-- ============================================================== -->
</div>
<!-- ============================================================== -->
<!-- End Page wrapper -->
<!-- ============================================================== -->
<?php require_once "inc/footer.php" ?>