-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.php
651 lines (608 loc) · 39.5 KB
/
account.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
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="icon" href="favicon.ico" type="image/icon" sizes="16x16">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Quizzo | Candidate Profile </title>
<link rel="stylesheet" href="css/bootstrap.min.css"/>
<link rel="stylesheet" href="css/bootstrap-theme.min.css"/>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/font.css">
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css'>
<?php
if (@$_GET['w']) {
echo '<script>alert("' . @$_GET['w'] . '");</script>';
}
?>
</head>
<?php
include_once 'dbConnection.php';
?>
<body style="
font-family: sans-serif;
font-weight: 100;
background-image: url(https://raw.githubusercontent.com/kahanikaar/Project-EyT/master/20200712_031013_0000.png);
background-position: center left; background-repeat: no-repeat; background-attachment: fixed;
background-size: cover; ">
<div id="page-container">
<div id="content-wrap">
<div class="header">
<div class="row">
<div class="col-lg-6" style="margin-top:15px;">
<span class="logo">Quizzo | The Online Quiz Platform</span></div>
<div class="col-md-4 col-md-offset-2">
<?php
include_once 'dbConnection.php';
session_start();
if (!(isset($_SESSION['username']))) {
header("location:index.php");
} else {
$name = $_SESSION['name'];
$username = $_SESSION['username'];
include_once 'dbConnection.php';
echo '<span class="pull-right top title1" ><span style="color:white"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Hello,</span> <span class="log log1" style="color:lightyellow">' . $username . ' | <a href="logout.php?q=account.php" style="color:lightyellow"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> Logout</button></a></span>';
}
?>
</div>
</div></div>
<div class="bg">
<nav class="navbar navbar-default title1">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><b> </b></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li <?php
if (@$_GET['q'] == 1)
echo 'class="active"';
?> ><a href="account.php?q=1"><span class="glyphicon glyphicon-home" aria-hidden="true"></span> <b>Home</b><span class="sr-only">(current)</span></a></li>
<li <?php
if (@$_GET['q'] == 2)
echo 'class="active"';
?>><a href="account.php?q=2"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span> <b>My History</b></a></li>
<li <?php
if (@$_GET['q'] == 3)
echo 'class="active"';
?>><a href="account.php?q=3"><span class="glyphicon glyphicon-stats" aria-hidden="true"></span> <b>Leaderboard</b></a></li></ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-md-12">
<?php
if (@$_GET['q'] == 1) {
$result = mysqli_query($con, "SELECT * FROM quiz WHERE status = 'enabled' ORDER BY date DESC") or die('Error');
echo '<div class="panel"><table class="table table-striped title1" style="vertical-align:middle">
<tr><td style="vertical-align:middle"><b>S.N.</b></td><td style="vertical-align:middle"><b>Name</b></td><td style="vertical-align:middle"><b>Total question</b></td><td style="vertical-align:middle"><b>Correct Answer</b></td><td style="vertical-align:middle"><b>Wrong Answer</b></td><td style="vertical-align:middle"><b>Total Marks</b></td><td style="vertical-align:middle"><b>Time limit</b></td><td style="vertical-align:middle"><b>Action</b></td></tr>';
$c = 1;
while ($row = mysqli_fetch_array($result)) {
$title = $row['title'];
$total = $row['total'];
$correct = $row['correct'];
$wrong = $row['wrong'];
$time = $row['time'];
$eid = $row['eid'];
$q12 = mysqli_query($con, "SELECT score FROM history WHERE eid='$eid' AND username='$username'") or die('Error98');
$rowcount = mysqli_num_rows($q12);
if ($rowcount == 0) {
echo '<tr><td style="vertical-align:middle">' . $c++ . '</td><td style="vertical-align:middle">' . $title . '</td><td style="vertical-align:middle">' . $total . '</td><td style="vertical-align:middle">+' . $correct . '</td><td style="vertical-align:middle">-' . $wrong . '</td><td style="vertical-align:middle">' . $correct * $total . '</td><td style="vertical-align:middle">' . $time . ' min</td>
<td style="vertical-align:middle"><b><a href="account.php?q=quiz&step=2&eid=' . $eid . '&n=1&t=' . $total . '&start=start" class="btn" style="color:#FFFFFF;background:darkgreen;font-size:12px;padding:7px;padding-left:10px;padding-right:10px"><span class="glyphicon glyphicon-new-window" aria-hidden="true"></span> <span><b>Start</b></span></a></b></td></tr>';
} else {
$q = mysqli_query($con, "SELECT * FROM history WHERE username='$_SESSION[username]' AND eid='$eid' ") or die('Error197');
while ($row = mysqli_fetch_array($q)) {
$timec = $row['timestamp'];
$status = $row['status'];
}
$q = mysqli_query($con, "SELECT * FROM quiz WHERE eid='$eid' ") or die('Error197');
while ($row = mysqli_fetch_array($q)) {
$ttimec = $row['time'];
$qstatus = $row['status'];
}
$remaining = (($ttimec * 60) - ((time() - $timec)));
if ($remaining > 0 && $qstatus == "enabled" && $status == "ongoing") {
echo '<tr style="color:darkgreen"><td style="vertical-align:middle">' . $c++ . '</td><td style="vertical-align:middle">' . $title . ' <span title="This quiz is already solve by you" class="glyphicon glyphicon-ok" aria-hidden="true"></span></td><td style="vertical-align:middle">' . $total . '</td><td style="vertical-align:middle">+' . $correct . '</td><td style="vertical-align:middle">-' . $wrong . '</td><td style="vertical-align:middle">' . $correct * $total . '</td><td style="vertical-align:middle">' . $time . ' min</td>
<td style="vertical-align:middle"><b><a href="account.php?q=quiz&step=2&eid=' . $eid . '&n=1&t=' . $total . '&start=start" class="btn" style="margin:0px;background:darkorange;color:white"> <span class="title1"><b>Continue</b></span></a></b></td></tr>';
} else {
echo '<tr style="color:darkgreen"><td style="vertical-align:middle">' . $c++ . '</td><td style="vertical-align:middle">' . $title . ' <span title="This quiz is already solve by you" class="glyphicon glyphicon-ok" aria-hidden="true"></span></td><td style="vertical-align:middle">' . $total . '</td><td style="vertical-align:middle">+' . $correct . '</td><td style="vertical-align:middle">-' . $wrong . '</td><td style="vertical-align:middle">' . $correct * $total . '</td><td style="vertical-align:middle">' . $time . ' min</td>
<td style="vertical-align:middle"><b><a href="account.php?q=result&eid=' . $eid . '" class="btn" style="margin:0px;background:darkred;color:white"> <span class="title1"><b>View Result</b></span></a></b></td></tr>';
}
}
}
$c = 0;
echo '</table></div><div class="panel" style="padding-top:1px;padding-left:15%;padding-right:15%;word-wrap:break-word"><h3 align="center" style="font-family:calibri">:: General Instructions ::</h3><br /><ul type="circle"><font style="font-size:14px;font-family:calibri">';
$file = fopen("instructions.txt", "r");
while (!feof($file)) {
echo '<li>';
$string = fgets($file);
$num = strlen($string) - 1;
$c = str_split($string);
for ($i = 0; $i < $num; $i++) {
$last = $c[$i - 1];
if ($c[$i] == ' ' && $last == ' ') {
echo ' ';
} else {
echo $c[$i];
}
}
echo "</li><br />";
}
fclose($file);
echo '</font></ul></div>';
}
?>
<?php
if (@$_GET['q'] == 'quiz' && @$_GET['step'] == 2 && isset($_SESSION['6e447159425d2d']) && $_SESSION['6e447159425d2d'] == "6e447159425d2d" && $_GET['endquiz'] == 'end') {
unset($_SESSION['6e447159425d2d']);
$q = mysqli_query($con, "UPDATE history SET status='finished' WHERE username='$_SESSION[username]' AND eid='$_GET[eid]' ") or die('Error197');
$q = mysqli_query($con, "SELECT * FROM history WHERE eid='$_GET[eid]' AND username='$_SESSION[username]'") or die('Error156');
while ($row = mysqli_fetch_array($q)) {
$s = $row['score'];
$scorestatus = $row['score_updated'];
}
if($scorestatus=="false"){
$q = mysqli_query($con, "UPDATE history SET score_updated='true' WHERE username='$_SESSION[username]' AND eid='$_GET[eid]' ") or die('Error197');
$q = mysqli_query($con, "SELECT * FROM rank WHERE username='$username'") or die('Error161');
$rowcount = mysqli_num_rows($q);
if ($rowcount == 0) {
$q2 = mysqli_query($con, "INSERT INTO rank VALUES(NULL,'$username','$s',NOW())") or die('Error165');
} else {
while ($row = mysqli_fetch_array($q)) {
$sun = $row['score'];
}
$sun = $s + $sun;
$q = mysqli_query($con, "UPDATE `rank` SET `score`=$sun ,time=NOW() WHERE username= '$username'") or die('Error174');
}
}
header('location:account.php?q=result&eid=' . $_GET[eid]);
}
if (@$_GET['q'] == 'quiz' && @$_GET['step'] == 2 && isset($_GET['start']) && $_GET['start'] == "start" && (!isset($_SESSION['6e447159425d2d']))) {
$q = mysqli_query($con, "SELECT * FROM history WHERE username='$username' AND eid='$_GET[eid]' ") or die('Error197');
if (mysqli_num_rows($q) > 0) {
$q = mysqli_query($con, "SELECT * FROM history WHERE username='$_SESSION[username]' AND eid='$_GET[eid]' ") or die('Error197');
while ($row = mysqli_fetch_array($q)) {
$timel = $row['timestamp'];
$status = $row['status'];
}
$q = mysqli_query($con, "SELECT * FROM quiz WHERE eid='$_GET[eid]' ") or die('Error197');
while ($row = mysqli_fetch_array($q)) {
$ttimel = $row['time'];
$qstatus = $row['status'];
}
$remaining = (($ttimel * 60) - ((time() - $timel)));
if ($status == "ongoing" && $remaining > 0 && $qstatus == "enabled") {
$_SESSION['6e447159425d2d'] = "6e447159425d2d";
header('location:account.php?q=quiz&step=2&eid=' . $_GET[eid] . '&n=' . $_GET[n] . '&t=' . $_GET[t]);
} else {
$q = mysqli_query($con, "UPDATE history SET status='finished' WHERE username='$_SESSION[username]' AND eid='$_GET[eid]' ") or die('Error197');
$q = mysqli_query($con, "SELECT * FROM history WHERE eid='$_GET[eid]' AND username='$_SESSION[username]'") or die('Error156');
while ($row = mysqli_fetch_array($q)) {
$s = $row['score'];
$scorestatus = $row['score_updated'];
}
if($scorestatus=="false"){
$q = mysqli_query($con, "UPDATE history SET score_updated='true' WHERE username='$_SESSION[username]' AND eid='$_GET[eid]' ") or die('Error197');
$q = mysqli_query($con, "SELECT * FROM rank WHERE username='$username'") or die('Error161');
$rowcount = mysqli_num_rows($q);
if ($rowcount == 0) {
$q2 = mysqli_query($con, "INSERT INTO rank VALUES(NULL,'$username','$s',NOW())") or die('Error165');
} else {
while ($row = mysqli_fetch_array($q)) {
$sun = $row['score'];
}
$sun = $s + $sun;
$q = mysqli_query($con, "UPDATE `rank` SET `score`=$sun ,time=NOW() WHERE username= '$username'") or die('Error174');
}
}
header('location:account.php?q=result&eid=' . $_GET[eid]);
}
} else {
$time = time();
$q = mysqli_query($con, "INSERT INTO history VALUES(NULL,'$username','$_GET[eid]' ,'0','0','0','0',NOW(),'$time','ongoing','false')") or die('Error137');
$_SESSION['6e447159425d2d'] = "6e447159425d2d";
header('location:account.php?q=quiz&step=2&eid=' . $_GET[eid] . '&n=' . $_GET[n] . '&t=' . $_GET[t]);
}
}
if (@$_GET['q'] == 'quiz' && @$_GET['step'] == 2 && isset($_SESSION['6e447159425d2d']) && $_SESSION['6e447159425d2d'] == "6e447159425d2d") {
$q = mysqli_query($con, "SELECT * FROM history WHERE username='$username' AND eid='$_GET[eid]' ") or die('Error197');
if (mysqli_num_rows($q) > 0) {
$q = mysqli_query($con, "SELECT * FROM history WHERE username='$_SESSION[username]' AND eid='$_GET[eid]' ") or die('Error197');
while ($row = mysqli_fetch_array($q)) {
$time = $row['timestamp'];
$status = $row['status'];
}
$q = mysqli_query($con, "SELECT * FROM quiz WHERE eid='$_GET[eid]' ") or die('Error197');
while ($row = mysqli_fetch_array($q)) {
$ttime = $row['time'];
$qstatus = $row['status'];
}
$remaining = (($ttime * 60) - ((time() - $time)));
if ($status == "ongoing" && $remaining > 0 && $qstatus == "enabled") {
$q = mysqli_query($con, "SELECT * FROM history WHERE username='$_SESSION[username]' AND eid='$_GET[eid]' ") or die('Error197');
while ($row = mysqli_fetch_array($q)) {
$time = $row['timestamp'];
}
$q = mysqli_query($con, "SELECT * FROM quiz WHERE eid='$_GET[eid]' ") or die('Error197');
while ($row = mysqli_fetch_array($q)) {
$ttime = $row['time'];
}
$remaining = (($ttime * 60) - ((time() - $time)));
echo '<script>
var seconds = ' . $remaining . ' ;
function end(){
data = prompt("Are you sure to end this Quiz? Remember, once finished, you wont be able to continue anymore and final results will be displayed. If you want to continue then enter \\"yes\\" in the textbox below and press enter");
if(data=="yes"){
window.location ="account.php?q=quiz&step=2&eid=' . $_GET[eid] . '&n=' . $_GET[n] . '&t=' . $_GET[total] . '&endquiz=end";
}
}
function enable(){
document.getElementById("sbutton").removeAttribute("disabled");
}
function frmreset(){
document.getElementById("sbutton").setAttribute("disabled","true");
document.getElementById("qform").reset();
}
function secondPassed() {
var minutes = Math.round((seconds - 30)/60);
var remainingSeconds = seconds % 60;
if (remainingSeconds < 10) {
remainingSeconds = "0" + remainingSeconds;
}
document.getElementById(\'countdown\').innerHTML = minutes + ":" + remainingSeconds;
if (seconds <= 0) {
clearInterval(countdownTimer);
document.getElementById(\'countdown\').innerHTML = "Buzz Buzz...";
window.location ="account.php?q=quiz&step=2&eid=' . $_GET[eid] . '&n=' . $_GET[n] . '&t=' . $_GET[total] . '&endquiz=end";
} else {
seconds--;
}
}
var countdownTimer = setInterval(\'secondPassed()\', 1000);
</script>';
echo '<font size="3" style="margin-left:100px;font-family:\'typo\' font-size:20px; font-weight:bold;color:white;">Time Left : </font><span class="timer btn btn-default" style="margin-left:20px;"><font style="font-family:\'typo\';font-size:20px;font-weight:bold;color:darkblue" id="countdown"></font></span><span class="timer btn btn-primary" style="margin-left:50px" onclick="end()"><span class=" glyphicon glyphicon-off"></span> <font style="font-size:12px;font-weight:bold">Finish Quiz</font></span>';
$eid = @$_GET['eid'];
$sn = @$_GET['n'];
$total = @$_GET['t'];
$q = mysqli_query($con, "SELECT * FROM questions WHERE eid='$eid' AND sn='$sn' ");
echo '<div class="panel" style="margin-right:5%;margin-left:5%;margin-top:10px;border-radius:10px">';
while ($row = mysqli_fetch_array($q)) {
$qns = stripslashes($row['qns']);
$qid = $row['qid'];
echo '<b><pre style="background-color:white"><div style="font-size:20px;font-weight:bold;font-family:calibri;margin:10px">' . $sn . ' : ' . $qns . '</div></pre></b>';
}
echo '<form id="qform" action="update.php?q=quiz&step=2&eid=' . $eid . '&n=' . $sn . '&t=' . $total . '&qid=' . $qid . '" method="POST" class="form-horizontal">
<br />';
$q = mysqli_query($con, "SELECT * FROM user_answer WHERE qid='$qid' AND username='$_SESSION[username]' AND eid='$_GET[eid]'") or die("Error222");
if (mysqli_num_rows($q) > 0) {
$row = mysqli_fetch_array($q);
$ans = $row['ans'];
$q = mysqli_query($con, "SELECT * FROM options WHERE qid='$qid' AND optionid='$ans'") or die("Error222");
$row = mysqli_fetch_array($q);
$ans = $row['option'];
} else {
$ans = "";
}
if (strlen($ans) > 0) {
echo "<font style=\"color:green;font-size:12px;font-weight:bold\">Selected answer: </font><font style=\"color:#565252;font-size:12px;\">" . $ans . "</font> <a href=update.php?q=quiz&step=2&eid=$eid&n=$sn&t=$total&qid=$qid&delanswer=delanswer><span class=\"glyphicon glyphicon-remove\" style=\"font-size:12px;color:darkred\"></span></a><br /><br />";
}
echo '<div class="funkyradio">';
$q = mysqli_query($con, "SELECT * FROM options WHERE qid='$qid' ");
while ($row = mysqli_fetch_array($q)) {
$option = stripslashes($row['option']);
$optionid = $row['optionid'];
echo '<div class="funkyradio-success"><input type="radio" id="' . $optionid . '" name="ans" value="' . $optionid . '" onclick="enable()"> <label for="' . $optionid . '" style="width:50%"><div style="color:black;font-size:12px;word-wrap:break-word"> ' . $option . '</div></label></div>';
}
echo '</div>';
if ($_GET[t] > $_GET[n] && $_GET[n] != 1) {
echo '<br /><a href="account.php?q=quiz&step=2&eid=' . $eid . '&n=' . ($sn - 1) . '&t=' . $total . '" class="btn btn-primary" style="height:30px"><span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="font-size:12px"></span></a> <button type="submit" class="btn btn-default" disabled="true" id="sbutton" style="height:30px"><span class="glyphicon glyphicon-lock" style="font-size:12px" aria-hidden="true"></span><font style="font-size:12px;font-weight:bold"> Lock</font></button> <button type="button" class="btn btn-default" onclick="frmreset()" style="height:30px"></span><font style="font-size:12px;font-weight:bold">Reset</font></button> <a href="account.php?q=quiz&step=2&eid=' . $eid . '&n=' . ($sn + 1) . '&t=' . $total . '" class="btn btn-primary" style="height:30px"><span class="glyphicon glyphicon-arrow-right" aria-hidden="true" style="font-size:12px"></span></a></form><br><br>';
} else if ($_GET[t] == $_GET[n]) {
echo '<br /><a href="account.php?q=quiz&step=2&eid=' . $eid . '&n=' . ($sn - 1) . '&t=' . $total . '" class="btn btn-primary" style="height:30px"><span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="font-size:12px"></span></a> <button type="submit" class="btn btn-default" disabled="true" id="sbutton" style="height:30px"><span class="glyphicon glyphicon-lock" style="font-size:12px" aria-hidden="true"></span><font style="font-size:12px;font-weight:bold"> Lock</font></button> <button type="button" class="btn btn-default" onclick="frmreset()" style="height:30px"></span><font style="font-size:12px;font-weight:bold">Reset</font></button> </form><br><br>';
} else if ($_GET[t] > $_GET[n] && $_GET[n] == 1) {
echo '<br /> <button type="submit" class="btn btn-default" disabled="true" id="sbutton" style="height:30px"><span class="glyphicon glyphicon-lock" style="font-size:12px" aria-hidden="true"></span><font style="font-size:12px;font-weight:bold"> Lock<font></button> <button type="button" class="btn btn-default" onclick="frmreset()" style="height:30px"></span><font style="font-size:12px;font-weight:bold">Reset</font></button> <a href="account.php?q=quiz&step=2&eid=' . $eid . '&n=' . ($sn + 1) . '&t=' . $total . '" class="btn btn-primary" style="height:30px"><span class="glyphicon glyphicon-arrow-right" aria-hidden="true" style="font-size:12px"></span></a></form><br><br>';
} else {
}
echo '</div>';
echo '<div class="panel" style="text-align:center">';
$q = mysqli_query($con, "SELECT * FROM questions WHERE eid='$_GET[eid]'") or die("Error222");
$i = 1;
while ($row = mysqli_fetch_array($q)) {
$ques[$row['qid']] = $i;
$i++;
}
$q = mysqli_query($con, "SELECT * FROM user_answer WHERE eid='$_GET[eid]' AND username='$_SESSION[username]'") or die("Error222a");
$i = 1;
while ($row = mysqli_fetch_array($q)) {
if (isset($ques[$row['qid']])) {
$quesans[$ques[$row['qid']]] = true;
}
}
for ($i = 1; $i <= $total; $i++) {
echo '<a href="account.php?q=quiz&step=2&eid=' . $eid . '&n=' . $i . '&t=' . $total . '" style="margin:5px;padding:5px;background-color:';
if ($quesans[$i]) {
echo "darkgreen";
} else {
echo "darkred";
}
echo ';color:white;font-size:16px;font-family:calibri;border-radius:4px"> ' . $i . ' </a>';
}
} else {
unset($_SESSION['6e447159425d2d']);
$q = mysqli_query($con, "UPDATE history SET status='finished' WHERE username='$_SESSION[username]' AND eid='$_GET[eid]' ") or die('Error197');
$q = mysqli_query($con, "SELECT * FROM history WHERE eid='$_GET[eid]' AND username='$_SESSION[username]'") or die('Error156');
while ($row = mysqli_fetch_array($q)) {
$s = $row['score'];
$scorestatus = $row['score_updated'];
}
if($scorestatus=="false"){
$q = mysqli_query($con, "UPDATE history SET score_updated='true' WHERE username='$_SESSION[username]' AND eid='$_GET[eid]' ") or die('Error197');
$q = mysqli_query($con, "SELECT * FROM rank WHERE username='$username'") or die('Error161');
$rowcount = mysqli_num_rows($q);
if ($rowcount == 0) {
$q2 = mysqli_query($con, "INSERT INTO rank VALUES(NULL,'$username','$s',NOW())") or die('Error165');
} else {
while ($row = mysqli_fetch_array($q)) {
$sun = $row['score'];
}
$sun = $s + $sun;
$q = mysqli_query($con, "UPDATE `rank` SET `score`=$sun ,time=NOW() WHERE username= '$username'") or die('Error174');
}
}
header('location:account.php?q=result&eid=' . $_GET[eid]);
}
} else {
unset($_SESSION['6e447159425d2d']);
$q = mysqli_query($con, "UPDATE history SET status='finished' WHERE username='$_SESSION[username]' AND eid='$_GET[eid]' ") or die('Error197');
$q = mysqli_query($con, "SELECT * FROM history WHERE eid='$_GET[eid]' AND username='$_SESSION[username]'") or die('Error156');
while ($row = mysqli_fetch_array($q)) {
$s = $row['score'];
$scorestatus = $row['score_updated'];
}
if($scorestatus=="false"){
$q = mysqli_query($con, "UPDATE history SET score_updated='true' WHERE username='$_SESSION[username]' AND eid='$_GET[eid]' ") or die('Error197');
$q = mysqli_query($con, "SELECT * FROM rank WHERE username='$username'") or die('Error161');
$rowcount = mysqli_num_rows($q);
if ($rowcount == 0) {
$q2 = mysqli_query($con, "INSERT INTO rank VALUES(NULL,'$username','$s',NOW())") or die('Error165');
} else {
while ($row = mysqli_fetch_array($q)) {
$sun = $row['score'];
}
$sun = $s + $sun;
$q = mysqli_query($con, "UPDATE `rank` SET `score`=$sun ,time=NOW() WHERE username= '$username'") or die('Error174');
}
}
header('location:account.php?q=result&eid=' . $_GET[eid]);
}
}
if (@$_GET['q'] == 'result' && @$_GET['eid']) {
$eid = @$_GET['eid'];
$q = mysqli_query($con, "SELECT * FROM quiz WHERE eid='$eid' ") or die('Error157');
while ($row = mysqli_fetch_array($q)) {
$total = $row['total'];
}
$q = mysqli_query($con, "SELECT * FROM history WHERE eid='$eid' AND username='$username' ") or die('Error157');
while ($row = mysqli_fetch_array($q)) {
$s = $row['score'];
$fin = $row['score'];
$w = $row['wrong'];
$r = $row['correct'];
$status = $row['status'];
}
if ($status == "finished") {
echo '<div class="panel">
<center><h1 class="title" style="color:#660033">Result</h1><center><br /><table class="table table-striped title1" style="font-size:20px;font-weight:1000;">';
echo '<tr style="color:darkblue"><td style="vertical-align:middle">Total Questions</td><td style="vertical-align:middle">' . $total . '</td></tr>
<tr style="color:darkgreen"><td style="vertical-align:middle">Correct Answer <span class="glyphicon glyphicon-ok-arrow" aria-hidden="true"></span></td><td style="vertical-align:middle">' . $r . '</td></tr>
<tr style="color:red"><td style="vertical-align:middle">Wrong Answer <span class="glyphicon glyphicon-remove-arrow" aria-hidden="true"></span></td><td style="vertical-align:middle">' . $w . '</td></tr>
<tr style="color:orange"><td style="vertical-align:middle">Unattempted <span class="glyphicon glyphicon-ban-arrow" aria-hidden="true"></span></td><td style="vertical-align:middle">' . ($total - $r - $w) . '</td></tr>
<tr style="color:darkblue"><td style="vertical-align:middle">Score </td><td style="vertical-align:middle">' . $s . '</td></tr>';
$q = mysqli_query($con, "SELECT * FROM rank WHERE username='$username' ") or die('Error157');
while ($row = mysqli_fetch_array($q)) {
$s = $row['score'];
echo '<tr style="color:#990000"><td style="vertical-align:middle">Overall Score </td><td style="vertical-align:middle">' . $s . '</td></tr>';
}
echo '<tr></tr></table></div><div class="panel"><br /><h3 align="center" style="font-family:calibri">:: Detailed Analysis ::</h3><br /><ol style="font-size:20px;font-weight:bold;font-family:calibri;margin-top:20px">';
$q = mysqli_query($con, "SELECT * FROM questions WHERE eid='$_GET[eid]'") or die('Error197');
while ($row = mysqli_fetch_array($q)) {
$question = $row['qns'];
$qid = $row['qid'];
$q2 = mysqli_query($con, "SELECT * FROM user_answer WHERE eid='$_GET[eid]' AND qid='$qid' AND username='$_SESSION[username]'") or die('Error197');
if (mysqli_num_rows($q2) > 0) {
$row1 = mysqli_fetch_array($q2);
$ansid = $row1['ans'];
$correctansid = $row1['correctans'];
$q3 = mysqli_query($con, "SELECT * FROM options WHERE optionid='$ansid'") or die('Error197');
$q4 = mysqli_query($con, "SELECT * FROM options WHERE optionid='$correctansid'") or die('Error197');
$row2 = mysqli_fetch_array($q3);
$row3 = mysqli_fetch_array($q4);
$ans = $row2['option'];
$correctans = $row3['option'];
} else {
$q3 = mysqli_query($con, "SELECT * FROM answer WHERE qid='$qid'") or die('Error197');
$row1 = mysqli_fetch_array($q3);
$correctansid = $row1['ansid'];
$q4 = mysqli_query($con, "SELECT * FROM options WHERE optionid='$correctansid'") or die('Error197');
$row2 = mysqli_fetch_array($q4);
$correctans = $row2['option'];
$ans = "Unanswered";
}
if ($correctans == $ans && $ans != "Unanswered") {
echo '<li><div style="font-size:16px;font-weight:bold;font-family:calibri;margin-top:20px;background-color:lightgreen;padding:10px;word-wrap:break-word;border:2px solid darkgreen;border-radius:10px;">' . $question . ' <span class="glyphicon glyphicon-ok" style="color:darkgreen"></span></div><br />';
echo '<font style="font-size:14px;color:darkgreen"><b>Your Answer: </b></font><font style="font-size:14px;">' . $ans . '</font><br />';
echo '<font style="font-size:14px;color:darkgreen"><b>Correct Answer: </b></font><font style="font-size:14px;">' . $correctans . '</font><br />';
}
else if ($ans == "Unanswered") {
echo '<li><div style="font-size:16px;font-weight:bold;font-family:calibri;margin-top:20px;background-color:#f7f576;padding:10px;word-wrap:break-word;border:2px solid #b75a0e;border-radius:10px;">' . $question . ' </div><br />';
echo '<font style="font-size:14px;color:darkgreen"><b>Correct Answer: </b></font><font style="font-size:14px;">' . $correctans . '</font><br />';
}
else {
echo '<li><div style="font-size:16px;font-weight:bold;font-family:calibri;margin-top:20px;background-color:#f99595;padding:10px;word-wrap:break-word;border:2px solid darkred;border-radius:10px;">' . $question . ' <span class="glyphicon glyphicon-remove" style="color:red"></span></div><br />';
echo '<font style="font-size:14px;color:darkgreen"><b>Your Answer: </b></font><font style="font-size:14px;">' . $ans . '</font><br />';
echo '<font style="font-size:14px;color:red"><b>Correct Answer: </b></font><font style="font-size:14px;">' . $correctans . '</font><br />';
}
echo "<br /></li>";
}
echo '</ol>';
$cur_dir=getcwd();
$cmd="cd ";
$cmd=$cmd.$cur_dir."/certificate-generator";
//echo getcwd();
//echo $cur_dir;
chdir("certificate-generator");
//echo getcwd();
/*if ($status) echo "Directory path not found";
else
{
echo "<pre>";
foreach($output as $line) echo "$line\n";
}
*/
$correct=1;
$q1 = mysqli_query($con, "SELECT * FROM quiz WHERE eid='$eid' ") or die('Error197');
$q2 = mysqli_query($con, "SELECT * FROM history WHERE eid='$eid' ") or die('Error197');
while ($row = mysqli_fetch_array($q1)) {
$correct = $row['correct'];
$title=$row['title'];
}
while ($row = mysqli_fetch_array($q2)) {
$date = $row['date'];
$username=$row['username'];
}
$q3 = mysqli_query($con, "SELECT * FROM user WHERE username='$username' ") or die('Error197');
while ($row = mysqli_fetch_array($q3)) {
$name=$row['name'];
}
$cmd="python test.py ";
$space=" ";
$cmd=$cmd."'".$name."'".$space."'".$title."'".$space.$fin.$space.$correct*$total.$space.$date;
//echo $cmd;
exec(escapeshellcmd($cmd), $output, $status);
$image = "outputcertificate.png"; //Let say If I put the file name Bang.png
//echo '<img src="images/' . $image . '" width="200" alt="' . pathinfo($image, PATHINFO_FILENAME) .'">';
//echo '<p><a href="download.php?file=' . urlencode($image) . '">Download</a></p>';
echo '
<center><button><a style="text-decoration:none; color:black;" class="no-style" href="certificate-generator/outputcertificate.png" target="_blank">Get Certificate</a></button></center>';
echo "</div>";
} else {
die("Thats a 404 Error bro. You are trying to access a wrong page");
}
}
if (@$_GET['q'] == 2) {
$q = mysqli_query($con, "SELECT * FROM history WHERE username='$username' AND status='finished' ORDER BY date DESC ") or die('Error197');
echo '<div class="panel title">
<table class="table table-striped title1" >
<tr><td style="vertical-align:middle"><b>S.N.</b></td><td style="vertical-align:middle"><b>Quiz</b></td><td style="vertical-align:middle"><b>Total Questions</b></td><td style="vertical-align:middle"><b>Right</b></td><td style="vertical-align:middle"><b>Wrong<b></td><td style="vertical-align:middle"><b>Unattempted<b></td><td style="vertical-align:middle"><b>Score</b></td><td style="vertical-align:middle"><b>Action<b></td></tr>';
$c = 0;
while ($row = mysqli_fetch_array($q)) {
$eid = $row['eid'];
$s = $row['score'];
$w = $row['wrong'];
$r = $row['correct'];
$q23 = mysqli_query($con, "SELECT * FROM quiz WHERE eid='$eid' ") or die('Error208');
while ($row = mysqli_fetch_array($q23)) {
$title = $row['title'];
$total = $row['total'];
}
$c++;
echo '<tr><td style="vertical-align:middle">' . $c . '</td><td style="vertical-align:middle">' . $title . '</td><td style="vertical-align:middle">' . $total . '</td><td style="vertical-align:middle">' . $r . '</td><td style="vertical-align:middle">' . $w . '</td><td style="vertical-align:middle">' . ($total - $r - $w) . '</td><td style="vertical-align:middle">' . $s . '</td><td style="vertical-align:middle"><b><a href="account.php?q=result&eid=' . $eid . '" class="btn" style="margin:0px;background:darkred;color:white"> <span class="title1"><b>View Result</b></td></tr>';
}
echo '</table></div>';
}
if (@$_GET['q'] == 3) {
if(isset($_GET['show'])){
$show = $_GET['show'];
$showfrom = (($show-1)*10) + 1;
$showtill = $showfrom + 9;
}
else{
$show = 1;
$showfrom = 1;
$showtill = 10;
}
$q = mysqli_query($con, "SELECT * FROM rank") or die('Error223');
echo '<div class="panel title">
<table class="table table-striped title1" >
<tr><td style="vertical-align:middle"><b>Rank</b></td><td style="vertical-align:middle"><b>Name</b></td><td style="vertical-align:middle"><b>Branch</b></td><td style="vertical-align:middle"><b>Username</b></td><td style="vertical-align:middle"><b>Score</b></td></tr>';
$c = $showfrom-1;
$total = mysqli_num_rows($q);
if($total >= $showfrom){
$q = mysqli_query($con, "SELECT * FROM rank ORDER BY score DESC, time ASC LIMIT ".($showfrom-1).",10") or die('Error223');
while ($row = mysqli_fetch_array($q)) {
$e = $row['username'];
$s = $row['score'];
$q12 = mysqli_query($con, "SELECT * FROM user WHERE username='$e' ") or die('Error231');
while ($row = mysqli_fetch_array($q12)) {
$name = $row['name'];
$branch = $row['branch'];
$username = $row['username'];
}
$c++;
echo '<tr><td style="color:#99cc32"><b>' . $c . '</b></td><td style="vertical-align:middle">' . $name . '</td><td style="vertical-align:middle">' . $branch . '</td><td style="vertical-align:middle">' . $username . '</td><td style="vertical-align:middle">' . $s . '</td><td style="vertical-align:middle">';
}
}
else{
}
echo '</table></div>';
echo '<div class="panel title"><table class="table table-striped title1" ><tr>';
$total = round($total/10) + 1;
if(isset($_GET['show'])){
$show = $_GET['show'];
}
else{
$show = 1;
}
if($show == 1 && $total==1){
}
else if($show == 1 && $total!=1){
$i = 1;
while($i<=$total){
echo '<td style="vertical-align:middle;text-align:center"><a style="font-size:14px;font-family:typo;font-weight:bold" href="account.php?q=3&show='.$i.'"> '.$i.' </a></td>';
$i++;
}
echo '<td style="vertical-align:middle;text-align:center"><a style="font-size:14px;font-family:typo;font-weight:bold" href="account.php?q=3&show='.($show+1).'"> >> </a></td>';
}
else if($show != 1 && $show==$total){
echo '<td style="vertical-align:middle;text-align:center"><a style="font-size:14px;font-family:typo;font-weight:bold" href="account.php?q=3&show='.($show-1).'"> << </a></td>';
$i = 1;
while($i<=$total){
echo '<td style="vertical-align:middle;text-align:center"><a style="font-size:14px;font-family:typo;font-weight:bold" href="account.php?q=3&show='.$i.'"> '.$i.' </a></td>';
$i++;
}
}
else{
echo '<td style="vertical-align:middle;text-align:center"><a style="font-size:14px;font-family:typo;font-weight:bold" href="account.php?q=3&show='.($show-1).'"> << </a></td>';
$i = 1;
while($i<=$total){
echo '<td style="vertical-align:middle;text-align:center"><a style="font-size:14px;font-family:typo;font-weight:bold" href="account.php?q=3&show='.$i.'"> '.$i.' </a></td>';
$i++;
}
echo '<td style="vertical-align:middle;text-align:center"><a style="font-size:14px;font-family:typo;font-weight:bold" href="account.php?q=3&show='.($show+1).'"> >> </a></td>';
}
echo '</tr></table></div>';
}
?>
</div></div></div></div></div>
<footer style="position:absolute; margin-top: 4%; height:3.5rem; width:100%; background-color: crimson; border-top: 2px solid white; text-align: center; bottom:0;">
<div class="row footer">
<div class="col-md-2 box"></div>
<div class="col-md-6 box">
<span href="#" data-target="#login" style="color:lightyellow">Created in Quizzo©<br><br></span></div>
<div class="col-md-2 box">
<a href="feedback.php" style="color:lightyellow;text-decoration:underline" onmouseover="this.style('color:yellow')" target="new">Feedback</a></div>
<div class="col-md-2 box">
<a href="about.php" s style="color:lightyellow;text-decoration:underline" onmouseover="this.style('color:yellow')" target="new">About Quizzo</a></div>
</div>
</footer>
</div>
</body>
</html>