-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponseviewing.php
More file actions
418 lines (369 loc) · 17.1 KB
/
responseviewing.php
File metadata and controls
418 lines (369 loc) · 17.1 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
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
<!--Check if user is logged in-->
<?php
session_start();
if (!isset($_SESSION["username"])) {
header("Location: login.php");
exit();
}
if (!isset($_GET["resultid"])) {
header("Location: index.php");
exit();
}
$resultid = $_GET["resultid"];
include_once("./src/checkmaintenancestatus.php");
include_once("./src/dbconnect.php");
/* check if result id exits and its from quiz id belongs to the quiz owner, else redirect to home page */
$sql = $conn->prepare("SELECT * FROM results WHERE result_id = ?");
$sql->bind_param("s", ($resultid));
$sql->execute();
$result = $sql->get_result();
if ($result->num_rows == 0) {
//result does not exist
header("Location: index.php");
exit();
} else {
//search for the quiz to determine owner
while ($row = $result->fetch_assoc()) {
if ($row['from_user_id'] != $_SESSION['userid']) {
//user is not the result owner
header("Location: index.php");
exit();
}
$quizid = $row['from_quiz_id'];
$sql = $conn->prepare("SELECT quiz_title, is_viewquestions, has_essay FROM quizzes WHERE quiz_id = ?");
$sql->bind_param("s", $quizid);
$sql->execute();
$result2 = $sql->get_result();
while ($row2 = $result2->fetch_assoc()) {
//check if quiz has essays and if responses are viewable
$hasessay = $row2['has_essay'];
if ($hasessay == 0) {
//no essays to show
header("Location: index.php");
exit();
}
$isviewquestions = $row2['is_viewquestions'];
if ($isviewquestions == 0) {
//viewing of questions disabled
header("Location: index.php");
exit();
}
/* get total number of questions */
$sql = $conn->prepare("SELECT COUNT(question_id) FROM questions WHERE from_quiz_id = ?");
$sql->bind_param("s", $quizid);
$sql->execute();
$result = $sql->get_result();
while ($row3 = $result->fetch_assoc()) {
$totalquestions = $row3['COUNT(question_id)'];
}
//get quiz and attempt data
$quiztitle = $row2['quiz_title'];
$attempttime = $row['attempt_datetime'];
$duration = $row['duration'];
$score = round($row['score'], 2);
$perfectscore = $row['perfect_score'];
$isfinal = $row['is_final'];
}
}
}
if ($isfinal == 0) {
$scorecomment = $score . " / " . $perfectscore . " (Partial)";
} else {
$scorecomment = $score . " / " . $perfectscore . " (" . intval($score * 100 / $perfectscore) . "%)";
}
$ndx = 0;
$questionlist = [];
/* get all responses */
$sql = $conn->prepare("SELECT * FROM essay_responses WHERE from_result_id = ? ORDER BY from_question_id");
$sql->bind_param("s", $resultid);
$sql->execute();
$result = $sql->get_result();
while ($row = $result->fetch_assoc()) {
$currquestionid = $row['from_question_id'];
/* get corresponding question info */
$sql = $conn->prepare("SELECT question_text, points FROM questions WHERE question_id = ?");
$sql->bind_param("s", $currquestionid);
$sql->execute();
$result2 = $sql->get_result();
while ($row2 = $result2->fetch_assoc()) {
//details to display (store in array)
$questionlist[$ndx] = array(
'questionnum' => $row['question_no_label'],
'questiontext' => $row2['question_text'],
'maxpoints' => $row2['points'],
'answer' => $row['answer'],
'points' => $row['points'],
'feedback' => $row['feedback']
);
$ndx++;
}
}
$sql->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<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 href="css/helptip.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/unifiedpopups.js"></script>
<script type="text/javascript" src="./src/auth.js"></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>
<style>
.link {
cursor: pointer;
}
.stats {
margin-left: 75px;
font-size: 16px;
width: 620px;
padding: 12px 15px;
background-color: #cce6ff;
border: 2px solid #81c0ff;
border-radius: 12px;
}
@media (min-width:1100px) {
.warningcont {
margin-left: 87px;
}
}
.code {
font-family:monospace;
font-size:14px;
}
</style>
<!--For MathJax expressions-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<style>
.mjx-chtml,
.MJXc-display {
display: inline-block !important;
margin: 4px 1px !important;
}
</style>
<script>
$(document).ready(function() {
$('html').getNiceScroll().remove();
$('html').css({
"overflow-x": "hidden"
});
});
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [
["$$", "$$"]
],
processEscapes: true
}
});
</script>
<title>View Feedback | ANYQUIZ</title>
</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="sub-menu">
<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-9">
<h3 style="margin: 20px; padding-bottom: 10px; font-weight:bold;">
<?php echo $quiztitle; ?>
</h3>
<h5 style="margin: 20px; padding-bottom: 10px; font-weight:bold;">
Attempt time: <span style="color:blue;"><?php echo $attempttime; ?></span>
Duration: <span style="color:blue;"><?php echo $duration; ?></span>
Score: <span style="color:blue;"><?php echo $scorecomment; ?></span>
</h5>
</div>
</div>
<!-- questions tab -->
<div class="row maintab">
<!-- question groups tab - each question will be added and set via PHP/MySQL -->
<div class="questions">
<?php
$count = 1;
for ($x = 0; $x < $ndx; $x++) {
$questionnum = $questionlist[$x]['questionnum'];
$questiontext = nl2br($questionlist[$x]['questiontext']);
$maxpoints = $questionlist[$x]['maxpoints'];
$answer = $questionlist[$x]['answer'];
$points = $questionlist[$x]['points'] == -1 ? "Not yet graded" : round($questionlist[$x]['points'], 1);
$feedback = $questionlist[$x]['feedback'];
if ($feedback == "" || $feedback == NULL) {
$display = "display:none;";
} else {
$display = "";
}
echo <<<EOT
<div class="question">
<div class="row">
<div class="count questionnum" style="padding-left: 45px; margin-bottom:15px;">
Question $questionnum of $totalquestions<span style="font-size:17px;">
( <span class="obtainedpoints">$points</span> / <span class="points">$maxpoints</span> points )</span>
</div>
</div>
<div class="count-7" style="padding-left: 60px; font-size: 20px; padding-right:20%; margin-bottom:15px;">
$questiontext
<div class="ESSAY" style="padding-left: 15px; font-size: 18px; padding-top: 20px;">
<textarea disabled class="form-control ESSAY$count" placeholder="No answer text provided." style="height:135px; min-height: 135px; min-width:85%; max-width:85%; max-height:396px; font-family:monospace; font-size:12.5px; cursor:auto;">$answer</textarea>
</div>
</div>
<div class='alert alert-info comment' role='alert' style='$display width:550px; margin:20px auto 15px 75px; padding: 10px 15px; border-radius:10px;'><i class='icon_info'></i> <b>Answer feedback: </b>$feedback</div>
<br>
</div>
EOT;
$count++;
}
?>
<!-- end of question groups tab-->
</div>
<!-- additional info to pass to server -->
<div class="row" style="padding-left:60px;">
<div style="width:auto; display:inline; float:left; font-size: 15px; font-weight: 700px; margin-right: 20px;">
Only constructed response questions and answers are permanently stored and viewable by users.
</div>
</div>
<!-- end of questions tab-->
</div>
</section>
<a href="index.php"><button type="button" class="btn btn-info" style="margin-left:40px;"><b>Back to Dashboard</b></button>
<div style="height:50px">
</div>
</section>
</section>
</body>
</html>