-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquizinfo.php
476 lines (435 loc) · 24.3 KB
/
quizinfo.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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
<!--Check if user is logged in-->
<?php
session_start();
if (!isset($_SESSION["username"])) {
header("Location: login.php");
exit();
}
if (!isset($_GET["quizcode"])) {
header("Location: quiz.php");
exit();
}
include_once("./src/checkmaintenancestatus.php");
include_once("./src/dbconnect.php");
$quiztitle = $_GET['quiztitle'];
$quizid = $_GET['quizid'];
$quizcode = $_GET['quizcode'];
/* verify if the quiz exist and if the user owns the quiz */
$sql = $conn->prepare("SELECT * FROM quizzes WHERE `quiz_id` = ? AND `quiz_title` = ? AND `access_code` = ?");
$sql->bind_param("sss", $quizid, $quiztitle, $quizcode);
$sql->execute();
$result = $sql->get_result();
$sql->close();
if ($result->num_rows == 0) {
header("Location: quiz.php");
exit();
} else {
while ($row = $result->fetch_assoc()) {
if ($row['from_user_id'] != $_SESSION['userid']) {
header("Location: quiz.php");
exit();
}
$ispublic = $row['is_public'];
$hasessay = $row['has_essay'];
}
}
$sql = $conn->prepare("SELECT * FROM results WHERE `from_quiz_id` = ? ORDER BY attempt_datetime DESC");
$sql->bind_param("s", $quizid);
$sql->execute();
$result = $sql->get_result();
$sql->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Quizzes | ANYQUIZ</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-theme.css" rel="stylesheet">
<link href="css/elegant-icons-style.css" rel="stylesheet" />
<link href="css/font-awesome.min.css" rel="stylesheet" />
<link href="css/jquery-jvectormap-1.2.2.css" rel="stylesheet">
<link rel="stylesheet" href="css/fullcalendar.css">
<link href="css/widgets.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<link href="css/style-responsive.css" rel="stylesheet" />
<link href="css/xcharts.min.css" rel=" stylesheet">
<link href="css/jquery-ui-1.10.4.min.css" rel="stylesheet">
<link rel="icon" href="favicon.ico">
<meta name="description" content="ANYQUIZ is a fully featured quiz maker for school, business, or just for fun. Create one now and explore its awesome features that match your desire and purpose.">
<meta name="author" content="Wayne Dayata">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- javascripts -->
<script src="js/jquery.js"></script>
<script src="js/jquery-ui-1.10.4.min.js"></script>
<script src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.9.2.custom.min.js"></script>
<!-- bootstrap -->
<script src="js/bootstrap.min.js"></script>
<!--custome script for all page-->
<script src="js/scripts.js"></script>
<!-- nice scroll -->
<script src="js/jquery.nicescroll.js" type="text/javascript"></script>
<script type="text/javascript" src="./src/auth.js"></script>
<script type="text/javascript" src="./src/quizedit.js"></script>
<script type="text/javascript" src="./src/unifiedpopups.js"></script>
<style>
td {
padding: 7px 15px 5px !important
}
</style>
<script>
$(document).ready(function() {
$('html').getNiceScroll().remove();
$('html').css({
"overflow-x": "hidden"
});
});
var ispublic = <?php echo $ispublic; ?>;
</script>
<link href="css/offline-theme-chrome.css" rel="stylesheet">
<link href="css/offline-language-english.min.css" rel="stylesheet">
<script src="js/offline.min.js" type="text/javascript"></script>
</head>
<body>
<section id="container" class="">
<header class="header white-bg " style="z-index:5;">
<div class="toggle-nav">
<div class="icon-reorder tooltips" data-original-title="Toggle Navigation" data-placement="bottom"><i class="icon_menu"></i></div>
</div>
<!--logo start-->
<a href="index.php" class="logo"><b>ANY <span class="lite">QUIZ</span></b></a>
<!--logo end-->
<div class="nav search-row" id="top_menu">
<!-- search form start -->
<ul class="nav top-menu">
<li>
<form class="navbar-form" method="GET" action="quiztaking.php">
<input class="form-control" name="quizcode" maxlength="6" placeholder="Search Quiz Code">
<!-- hit ENTER to submit the form -->
</form>
</li>
</ul>
<!-- search form end -->
</div>
<div class="top-nav notification-row">
<!-- notificatoin dropdown start-->
<ul class="nav pull-right top-menu">
<!-- user login dropdown start-->
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
<span class="profile-ava">
<img alt="" src="img/id-pic1.png">
</span>
<!-- User name-->
<span class="username">
<?php echo $_SESSION['username']; ?>
</span>
<b class="caret"></b>
</a>
<ul class="dropdown-menu extended logout">
<div class="log-arrow-up"></div>
<li class="eborder-top">
<a href="profile.php"><i class="icon_profile"></i> My Profile</a>
</li>
<li>
<a onclick="signoutClick(event)" style="cursor:pointer;"><i class="icon_key_alt"></i> Log Out</a>
</li>
</ul>
</li>
<!-- user login dropdown end -->
</ul>
<a class="btn btn-success" href="quiz_maker.php" style=" margin-top: 7px;"><span class="fa fa-plus"> </span><b>Create New Quiz</b></a>
<!-- notificatoin dropdown end-->
</div>
</header>
<!--header end-->
<!--sidebar start-->
<aside>
<div id="sidebar" class="nav-collapse " style="z-index:4;">
<!-- sidebar menu start-->
<ul class="sidebar-menu">
<li class="sub-menu">
<a class="" href="index.php">
<i class="icon_house"></i>
<span>Dashboard</span>
</a>
</li>
<li class="active">
<a href="quiz.php" class="">
<i class="icon_document"></i>
<span>My Quizzes</span>
</a>
</li>
<li class="sub-menu mobile">
<a href="quiz_maker.php" class="">
<i class="fa fa-plus"></i>
<span>Create a Quiz</span>
</a>
</li>
<li class="sub-menu">
<a href="quizfetching.php" class="">
<i class="icon_pencil_alt"></i>
<span>Take a Quiz</span>
</a>
</li>
<li class="sub-menu mobile">
<a href="profile.php" class="">
<i class="icon_profile"></i>
<span>My Profile</span>
</a>
</li>
<li class="sub-menu">
<a href="about.php" class="">
<i class="icon_info"></i>
<span>About</span>
</a>
</li>
<li class="sub-menu mobile">
<a onclick="signoutClick(event)" style="cursor:pointer;">
<i class="icon_key"></i>
<span>Log Out</span>
</a>
</li>
</ul>
<!-- sidebar menu end-->
</div>
</aside>
<!--sidebar end-->
<!--main content start-->
<section id="main-content">
<section class="wrapper">
<!--overview start-->
<div class="row">
<div class="col-lg-12">
<h3 style="margin: 20px; padding-bottom: 10px; font-weight:bold;">
<i class="icon_document"></i> View quiz:
<span id="quizTitle"> <?php echo $quiztitle ?> </span>
</h3>
</div>
<div class="col-lg-12">
<h4 id="instructions" style="margin: 20px; padding-left: 20px; font-weight:bold;">
Quiz code: <span id="quizcode" style="color:maroon;"> <?php echo $quizcode ?> </span>
<form id="quiz" method="GET" action="quiztaking.php" style="display:inline;">
<button type="submit" name="quizcode" value="<?php echo $quizcode ?>" class="btn btn-info"><b>Launch Quiz</b></button>
</form>
<form id="editquiz" method="GET" action="quizedit.php" style="display:inline;">
<input type="hidden" name="quizid" value="<?php echo $quizid ?>">
<input type="hidden" name="quiztitle" value="<?php echo $quiztitle ?>">
<input type="hidden" name="quizcode" value="<?php echo $quizcode ?>">
<button type="submit" class="btn btn-info"><b>Edit Quiz Settings</b></button>
</form>
<button type="button" class="btn btn-info" style="font-weight:bold;" onclick="copyquizlink()">Copy Quiz Link</button>
</h4>
</div>
</div>
<!--Project Activity start-->
<section class="panel" style="margin-left:30px; margin-right:30px; max-width:960px; border:2px solid #e6e6e6;">
<div class="panel-body progress-panel" style="border:1px; padding:15px 15px 10px;">
<div class="row">
<?php
echo <<<EOT
<div class="col-lg-8 task-progress pull-left">
<h1><b>Attempt history for this quiz:</b></h1>
</div>
EOT;
/* Check if there are valid attempts. If there are none, do not show stat */
$sql = $conn->prepare("SELECT COUNT(score) FROM results WHERE `from_quiz_id` = ? AND `score` >= 0 AND `is_final` = '1'");
$sql->bind_param("s", $quizid);
$sql->execute();
$result3 = $sql->get_result();
$sql->close();
$data = $result3->fetch_assoc();
if ($data['COUNT(score)'] != 0) {
/* query min, mean, max scores */
$sql = $conn->prepare("SELECT MIN(score),AVG(score),MAX(score) FROM results WHERE `from_quiz_id` = ? AND `score` >= 0 AND `is_final` = '1'");
$sql->bind_param("s", $quizid);
$sql->execute();
$result3 = $sql->get_result();
$sql->close();
while ($data = $result3->fetch_assoc()) {
$low = round($data['MIN(score)'], 2);
$mean = round($data['AVG(score)'], 2);
$high = round($data['MAX(score)'], 2);
}
echo <<<EOT
<div class="task-progress" style="margin-right:15px; float:right;">
<h1><b>Low: $low Mean: $mean High: $high</b><h1>
</div>
EOT;
}
?>
</div>
</div>
<table class="table table-hover personal-task" style="margin-bottom:4px;">
<?php
if ($result->num_rows > 0) {
echo <<<EOT
<thead>
<tr>
<td><b>#</b></td>
<td><b>Attempt by</b></td>
<td><b>Attempt time</b></td>
<td><b>Duration</b></td>
<td><b>Score</b></td>
<td></td>
</tr>
</thead>
EOT;
}
?>
<tbody>
<?php
$count = 1;
$haspending = 0;
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
//get quiz name
$sql = $conn->prepare("SELECT username FROM users WHERE `user_id` = ?");
$sql->bind_param("s", $row['from_user_id']);
$sql->execute();
$result2 = $sql->get_result();
$sql->close();
$row2 = $result2->fetch_assoc();
$username = $row2['username'];
$username = ($username == $_SESSION['username']) ? "Me" : $username;
$attempttime = $row['attempt_datetime'];
$resultid = $row['result_id'];
$duration = $row['duration'];
$score = round($row['score'], 2);
$perfectscore = $row['perfect_score'];
$isfinal = $row['is_final'];
//check the score for status
if ($score == -2) {
$scorecomment = "Unfinished attempt";
} else if ($score == -1) {
$scorecomment = "Invalid attempt";
} else {
if ($hasessay == 0 || $isfinal == 1) {
$scorecomment = $score . " / " . $perfectscore . " (" . intval($score * 100 / $perfectscore) . "%)";
} else {
$scorecomment = $score . " / " . $perfectscore . " (Partial)";
}
}
//check response status to determine button type
if ($hasessay == 1) {
if ($isfinal == 1) {
$btntype = "secondary";
$btnmsg = "Recheck";
$remark = "";
} else {
$btntype = "warning";
$btnmsg = "Check";
$remark = "*";
$haspending = 1;
}
if($score < 0){
$disabled = "disabled";
} else {
$disabled = "";
}
$responseform = <<<EOT
<form id="checkresponse$count" method="GET" action="responsechecking.php">
<input type="hidden" name="resultid" value="$resultid">
<input type="hidden" name="uname" value="$username">
</form>
EOT;
$responsebutton = <<<EOT
<button type="button" $disabled onclick="document.getElementById('checkresponse$count').submit()" class="btn btn-$btntype btn-sm" style="padding:3px 9px; width:66px; margin-top:-3px; margin-right:5px;"><b>$btnmsg</b></button>
EOT;
} else {
$responseform = "";
$responsebutton = "";
$remark = "";
}
echo <<<EOT
<tr>
<td>$count$remark</td>
<td>$username</td>
<td>$attempttime</td>
<td>$duration</td>
<td>$scorecomment</td>
<td>
$responseform
<form id="deleteattempt$count" method="get" onsubmit="deleteattempt(event,$count)" style="display:inline;">
<input type="hidden" name="quiztitle" value="$quiztitle">
<input type="hidden" name="quizid" value="$quizid">
<input type="hidden" name="quizcode" value="$quizcode">
<input type="hidden" name="resultid" value="$resultid">
$responsebutton
<button type="submit" class="btn btn-danger btn-sm" style="padding:3px 9px; width:66px; margin-top:-3px;"><b>Remove</b></button>
</form>
</td>
</tr>
EOT;
$count++;
}
if ($haspending == 1) {
echo <<<EOT
<tr>
<td colspan="6" style="font-size:11px;" align="left"><b>*Some items not yet graded; not included in score statistics above</b></td>
<tr>
EOT;
}
} else {
echo <<<EOT
<tr style="padding-bottom:10px;">
<td colspan="5" style="text-align:center;">
<img src="./img/noattempt.png">
<h4><b>No attempts made yet for this quiz.<b></b></h4>
</td>
</tr>
EOT;
}
?>
</tbody>
</table>
</section>
<h4 id="todelete" style="margin: 20px; padding-left: 20px; font-weight:bold;">
Click the button to delete the quiz:
<form id="deletequiz" method="post" onsubmit="removequiz()" style="display:inline;">
<input type="hidden" name="quizid" value="<?php echo $quizid ?>">
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#deletequizconfirm"><b>Delete Quiz</b></button>
</form>
</h4>
<a href="quiz.php"><button class="btn btn-info" style="margin-left:40px;"><b>Back to Quizzes</b></button></a>
</section>
<div style="height:50px">
</div>
</section>
<!--main content end-->
</section>
<input type="text" id="quizlink" style="position:fixed; top:-50px;" value="https://anyquiz.me/quiztaking.php?quizcode=<?php echo $quizcode; ?>">
<!-- pop up alert -->
<div style="position:fixed; top:80px; width:100%; padding-left:42px; z-index:6;">
<div id="popupalert" class="alert alert-danger" style="border-radius:6px; width:450px; margin:auto; display:none; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);">
<i class='icon_error-circle'></i> <span id="alertcontent"></span>
</div>
<div id="popupsuccess" class="alert alert-success" style="border-radius:6px; width:320px; margin:auto; display:none; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);">
<i class='icon_check_alt'></i> <span id="successcontent"></span>
</div>
</div>
<!-- modals for confirm remove actions -->
<div id="deletequizconfirm" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-header">
<h4 class="modal-title" id="exampleModalLongTitle" style="color:34aadc; font-weight:bold"><i class="icon_info"></i> Delete "<?php echo $quiztitle; ?>"?</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-content" style="padding:15px 20px; box-shadow:none; -webkit-box-shadow:none;">
<b>Are you sure you want to delete the entire quiz and all the records - settings, questions, attempt history - that are associated with it?
<br><br><span style="color:maroon">WARNING: This action cannot be undone!</span></b>
</div>
<div class="modal-footer" style="margin:0">
<button type="button" class="btn btn-info" data-dismiss="modal"><b>Cancel</b></button>
<button type="button" class="btn btn-danger" data-dismiss="modal" onclick="$('#deletequiz').submit();"><b>Delete forever</b></button>
</div>
</div>
</div>
</body>
</html>