-
Notifications
You must be signed in to change notification settings - Fork 0
/
quizcode.php
595 lines (485 loc) · 20.3 KB
/
quizcode.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
<?php
include 'database.php';
session_start();
if(empty($_SESSION['user'])){
header("location:index.php");
}
$table=$_GET['q'];
//$table2=openssl_decrypt($table, "AES-128-ECB","SECRET");
//$_SESSION['quizdelta']=$table2;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>Classregister - Quiz</title>
<meta name="robots" content="noindex, nofollow"/>
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=ABeeZee">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Abhaya+Libre">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Actor">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Aguafina+Script">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Alegreya+Sans">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Alex+Brush">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Almendra+SC">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Amita">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Bree+Serif">
<link rel="stylesheet" href="assets/fonts/ionicons.min.css">
<!-- <link rel="stylesheet" href="assets/css/Footer-Basic.css">
!--><!--<link rel="stylesheet" href="assets/css/Footer-Dark.css">
!--><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<link rel="stylesheet" href="assets/css/Login-Form-Clean-1.css">
<link rel="stylesheet" href="assets/css/Login-Form-Clean-2.css">
<link rel="stylesheet" href="assets/css/Login-Form-Clean.css">
<link rel="stylesheet" href="assets/css/Navigation-Clean.css">
<link rel="stylesheet" href="assets/css/Navigation-with-Button.css">
<link rel="stylesheet" href="assets/css/styles.css">
<link rel="stylesheet" href="assets/css/untitled.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<style type="text/css">
#quizcontainer1 {
background: linear-gradient(0.99deg, #FFFFFF 5%, #85B7F2 68.76%);
}
#scq {
margin-top: 20px;
margin-bottom: 10px;
}
#mcq {
margin-bottom: 10px;
}
#quizcontainer2 {
margin-top: 20px;
}
#share {
margin-left: 100px;
}
#quizcontainer3{
margin: auto;
width: 80%;
padding: 10px;
}
.f{
margin: auto;
width: 80%;
border-radius: 5px;
background: #FFFFFF;
border-left: 7px solid #9900cc;
border-top: 2px solid #cccccc;
padding: 10px;
box-shadow: 1px 1px 1px #cccccc;
}
.add-option{
background-color: var(--blue);
border:solid #FFFFFF;
color: #FFFFFF;
border-radius: 5px;
}
.delete-question{
background-color: var(--blue);
border:solid #FFFFFF;
color: #FFFFFF;
border-radius: 5px
}
.cross{
background-color: transparent;
border:solid #FFFFFF;
}
.point{
margin: 0 10%;
width: 10%;
outline: 0;
border-width: 0 0 2px;
}
.point:focus{
border-color: purple;
}
.question{
outline: 0;
border-width: 0 0 2px;
width: 70%;
}
.question:focus{
border-color: purple;
}
.text{
outline: 0;
border-width: 0 0 2px;
width: 70%;
}
.text:focus{
border-color: purple;
}
input{
outline: 0;
border-width: 0 0 2px;
}
input:focus{
border-color: purple;
}
.option:focus{
border-color: purple;
}
.redundant{
font-size: 18px;
border-width: 0 0 0px;
}
@media only screen and (max-width: 600px) {
.f{
width:100%;
}
#viewresponses{
margin-top:15px;
}
}
</style>
<script type="text/javascript">
function symbols(a){
var y=a.value;
if(a.value.includes("ROOT")){
a.value=a.value.replace("ROOT","√");
}
if(a.value.includes("DEG")){
a.value=a.value.replace("DEG","°");
}
if(a.value.includes("TRIANGLE")){
a.value=a.value.replace("TRIANGLE","△");
}
if(a.value.includes("CONGRUENT")){
a.value=a.value.replace("CONGRUENT","≅");
}
if(a.value.includes("SIMILAR")){
a.value=a.value.replace("SIMILAR","∼");
}
if(a.value.includes("THETA")){
a.value=a.value.replace("THETA","θ");
}
if(a.value.includes("-PI-")){
a.value=a.value.replace("-PI-","π");
}
if(a.value.includes("DIVISION")){
a.value=a.value.replace("DIVISION","÷");
}
if(a.value.includes("SIGMA")){
a.value=a.value.replace("SIGMA","Σ");
}
if(a.value.includes("ANGLE")){
a.value=a.value.replace("ANGLE","∠");
}
if(a.value.includes("INTEGRAL")){
a.value=a.value.replace("INTEGRAL","∫");
}
if(a.value.includes("NOTEQUAL")){
a.value=a.value.replace("NOTEQUAL","≠");
}
if(a.value.includes("INFINITY")){
a.value=a.value.replace("INFINITY","∞");
}
if(a.value.includes("GREATER-E")){
a.value=a.value.replace("GREATER-E","≥");
}
if(a.value.includes("LESS-E")){
a.value=a.value.replace("LESS-E","≤");
}
if(a.value.includes("BELONGS")){
a.value=a.value.replace("BELONGS","∈");
}
if(a.value.includes("FORALL")){
a.value=a.value.replace("FORALL","∀");
}
if(a.value.includes("NOTBELONG")){
a.value=a.value.replace("NOTBELONG","∉");
}
}
</script>
<script>
$(document).ready(function(){
$(document).on("click", ".add-option",function(){
//var quesid= $(this).prev().find(".question")[0].id;
var quesid= $(this).parent().find(".question")[0].id;
//alert(quesid);
var str="";
var type="";
//var options=$(this).prev().find(".options");
var options=$(this).parent().find(".option");
var optid="";
var textid="";
var l=options.length;
if(l==0){
if((document.getElementById("selector_1")).checked){
type="radio";
optid="1";
textid="t1";
}
else if((document.getElementById("selector_2")).checked){
type="checkbox";
optid="1";
textid="t1";
}
else{
swal("Please Select the type of Question");
}
}
else{
//type=$(this).prev().find(".options")[l-1].type;
//optid=$(this).prev().find(".options")[l-1].id;
type=$(this).parent().find(".option")[l-1].type;
optid=$(this).parent().find(".option")[l-1].id;
optid= +optid + +1;
textid="t"+optid;
//alert(type);
}
str='<div><input type="'+type+'" name="'+quesid+'[]" class="option" id="'+optid+'" onchange="setval(this)" /><textarea maxlength="200" name="Q_'+quesid+'[]" class="text" id="'+textid+'" rows="1" cols="70" placeholder="Option" onkeydown="new do_resize(this);" onkeyup="symbols(this)" style="resize: none;" ></textarea><input type="button" class="cross" value="X"><br><br></div>';
//alert("str is "+str);
//$(".container").append(str);
//$(str).insertBefore($(this).prev().find(".delete-question"));
$(str).insertBefore($(this));
str="";
});
$(document).on("click", ".delete-question",function(){
$(this).parent().next(".add-option").remove();
$(this).parent().parent().remove();
});
$(document).on("click",".cross", function(){
$(this).parent().remove();
});
/*$(document).on("click", "#save", function(){
var textoptions= document.getElementsByName("Q_1[]");
var i=0;
var b=$("[name=Q_1[1]]").val();
alert( "ans is"+ b);
});
*/
});
</script>
<script type="text/javascript">
function appendtext(){
var questions= document.getElementsByClassName("question");
var options=document.getElementsByClassName("option");
var optid="";
var pointsname="";
var radioname="";
var textname="";
var newid="";
var textid="";
if(questions.length==0){
pointsname="Q_1_POINTS";
radioname="1";
textname="Q_1[]";
newid="1";
optid="1"
textid="t1";
//alert("passed if");
}
else{
var id=questions[questions.length-1].id;
optid=options[options.length-1].id;
optid= +optid + +1;
textid="t"+optid;
newid= +id + +1;
pointsname= "Q_"+newid+"_POINTS";
radioname=newid;
textname="Q_"+newid+"[]";
//alert("passed else");
}
var str="";
if((document.getElementById("selector_1")).checked){
str='<div><br><div class="f"><textarea name="question[]" class="question" id="'+newid+'" maxlength="400" rows="1" cols="50" placeholder="Question" style="resize:none;" onkeyup="symbols(this)" onkeydown="new do_resize(this);"></textarea><input type="number" class="point" name="'+pointsname+'" placeholder="0"/><br><br><div><input type="radio" name="'+newid+'[]" class="option" id="'+optid+'" onchange="setval(this)"/><textarea rows="1" cols="70" placeholder="Option" name="'+textname+'" maxlength="200" class="text" onkeyup="symbols(this)" onkeydown="new do_resize(this);" id="'+textid+'" style="resize:none;"></textarea><input type="button" class="cross" value="X"><br><br></div><input type="button" class="add-option" value="Add Option"><input type="button" class="delete-question" value="Delete question"></div></div>';
}
else if((document.getElementById("selector_2")).checked){
str='<div><br><div class="f"><br><textarea name="question[]" class="question" id="'+newid+'" maxlength="400" rows="1" cols="50" onkeyup="symbols(this)" onkeydown="new do_resize(this);" placeholder="Question" style="resize:none;"></textarea><input class="point" type="number" name="'+pointsname+'" placeholder="0"/><br><br><div><input type="checkbox" name="'+newid+'[]" class="option" id="'+optid+'" onchange="setval(this)"/><textarea onkeyup="symbols(this)" onkeydown="new do_resize(this);" rows="1" cols="70" maxlength="200" name="'+textname+'" class="text" id="'+textid+'" placeholder="Option" style="resize:none;"></textarea><input type="button" class="cross" value="X"><br><br></div><input type="button" class="add-option" value="Add Option"><input type="button" class="delete-question" value="Delete question"></div></div>';
}
else{
swal("Please Select the type of Question","","info");
}
//alert(str);
$(str).insertBefore($("form").find("#save"));
str="";
//$("form").append(str);
}
function setval(bf){
//alert("type is "+bf.type);
var id= bf.id;
var b="t"+id;
var text1 = bf.checked ? document.getElementById(b).value : '';
//alert("text1 is "+text1);
bf.value=text1;
}
/*function addblank(){
var s='<br><div><input type="text" name="other[]" placeholder="Add a title"><br><input type="text" readonly><br><button class="delete-question">Delete Question</button></div><br>';
$(s).insertAfter($(document.getElementsByClassName("name")).parent());
}
*/
function myfun(){
document.getElementsByClassName("point").defaultValue=0;
var t=document.getElementById("titled").value;
if(t==""){
swal("Please add a title", "", "info");
}
else{
var quesid=$('textarea[name="question[]"]').map(function(){
return this.id;
}).get();
var question = $('textarea[name="question[]"]').map(function(){
return this.value;
}).get();
//alert("ques is "+question);
var alloptions={};
var correct={};
var points={};
var i=0;
while(i<quesid.length){
var s="Q_"+quesid[i];
alloptions[s]=$('textarea[name="'+s+'[]"]').map(function(){
return this.value;
}).get();
i=i+1;
//alert("all "+alloptions[s]);
}
var j=0;
while(j<quesid.length){
var s=""+quesid[j];
correct[s]=$.map($('input[name="'+s+'[]"]:checked'), function(c){return c.value; })
//alert(correct[s]);
j=j+1;
}
var k=0;
while(k<quesid.length){
var s="Q_"+quesid[k]+"_POINTS";
points[s]=$('input[name="'+s+'"]').map(function(){
if(this.value==""){
return 0;
}
else{
return this.value;
}
}).get();
k=k+1;
//alert("correct "+correct[s][1]);
}
var bk=window.location.href;
var fk=bk.indexOf("quizcode.php?q=");
var link=bk.substr(+fk + +15);
//alert(link);
window.location.href= "quiz-processing-2.php?question[]="+encodeURIComponent(question)+"&alloptions="+encodeURIComponent(alloptions)+"&correct="+encodeURIComponent(correct)+'&titledetail=testing'+'&points='+encodeURIComponent(points)+'&q='+encodeURIComponent(link);
/* $.ajax({
url : 'quiz-processing-2.php',
type : 'POST',
data : {'question[]':question,'alloptions':alloptions,'correct':correct,'titledetail':t,'points':points,'q':link},
success : function(result){
//if(result!=""){
//swal("Something went wrong","Please check whether you have at least one question and selected at least one option for every question","info");
//}
if(result.includes("Please enter only alphabets and numbers in the title")){
swal(result,"","info");
}
else if(result==""){
swal("Quiz saved successfully!","","success");
}
else{
swal("Something went wrong","Please make sure you have added at least one question and selected at least one option in every question","warning");
}
}
});
*/
}
}
</script>
</head>
<script type="text/javascript">
function do_resize(textbox) {
var maxrows=5;
var txt=textbox.value;
var cols=textbox.cols;
var arraytxt=txt.split('\n');
var rows=arraytxt.length;
for (i=0;i<arraytxt.length;i++)
rows+=parseInt(arraytxt[i].length/cols);
textbox.rows=rows;
//if (rows>maxrows) textbox.rows=maxrows;
//else
}
function share(){
var b=window.location.href;
var f=b.indexOf("quizcode.php?q=");
var g=b.substr(0,+f);
var d=b.substr(+f + +15);
var link=g+'quizforstudents.php?q='+d;
{
swal("Share","Link: "+link,"");
}
}
</script>
<body style="height: 900px;">
<!-- Start: Navigation Clean -->
<nav class="navbar navbar-light navbar-expand-md border rounded-0 navigation-clean-button">
<div class="container"><a class="navbar-brand" href="#" style="font-family: Amita, cursive;font-size: 22px;">classregister</a><button data-toggle="collapse" class="navbar-toggler" data-target="#navcol-1"><span class="sr-only">Toggle navigation</span><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navcol-1">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a class="nav-link" href="Homepage.php" style="font-family: Amita, cursive;color: var(--dark);">Home</a></li>
<li class="nav-item"><a class="nav-link" href="Myrecords.php" style="font-family: Amita, cursive;color: var(--dark);">My Records</a></li>
<li class="nav-item"><a class="nav-link" href="myaccount.php" style="font-family: Amita, cursive;color: var(--dark);">My Account</a></li>
<li class="nav-item"><a class="nav-link" href="signout.php" style="font-family: Amita, cursive;color: var(--purple);background: transparent;"><strong>Sign Out</strong></a></li>
</ul>
</div>
</div>
</nav><!-- End: Navigation Clean -->
<div class="container" id="quizcontainer1">
<h3 style="font-family: Actor, sans-serif;">Instructions</h3>
<p style="font-size: 18px;">1. Select the right options while making the quiz to add the answer key. Also, there's no need to type anything in Name and Section cards.</p>
<p style="font-size: 18px;">2. If in a More than One Correct type question, there's only one option correct, the question will be displayed as Single Choice Correct to the students.</p>
<p style="font-size: 18px;">3. Type the following to get the required symbols:</p>
<p style="font-size: 18px;">ROOT: √ , DEG : °, TRIANGLE : △,CONGRUENT : ≅, SIMILAR : ~, THETA : θ,-PI- : π, DIVISION : ÷, SIGMA : ∑ , ANGLE : ∠,INTEGRAL : ∫, NOTEQUAL: ≠, INFINITY :, GREATER-E : ≥, LESS-E : ≤,BELONGS : ∈, FORALL : ∀ , NOTBELONG : ∉ </p>
</div>
<br>
<div class="container" id="quizcontainer2">
<div class="form-check" id="scq" style="width: 200px;"><input class="form-check-input" type="radio" id="selector_1" name="selector"><label class="form-check-label" for="formCheck-1">Single Choice Correct</label></div>
<div class="form-check" id="mcq" style="width: 200px;"><input class="form-check-input" type="radio" id="selector_2" name="selector"><label class="form-check-label" for="formCheck-1">More than One Correct</label></div><button class="btn btn-primary" type="button" id="add-question" onclick="appendtext()">Add Question</button><button class="btn btn-primary" name="share" id="share" onclick="share()">Share</button>
<a class="float-right" href="<?php echo 'formviewresponses.php?q='.$table; ?>" id="viewresponses">View Responses</a>
<br>
<br>
</div>
<br>
<br>
<div class="container" id="quizcontainer3" style="text-align: left;">
<form>
<div class="f">
<input type="text" class="redundant" name="title" id="title" value="Title" readonly>
<br><br>
<input type="text" class="ti" name="titledetail" id="titled" maxlength="20" required>
<br>
</div><br>
<br>
<div class="f">
<input type="text" value="Name" class="redundant" readonly><br><br>
<input type="text" class="name" readonly><br>
</div><br>
<div class="f">
<input type="text" value="Section" class="redundant" readonly><br><br>
<input type="text" class="name" readonly><br>
</div>
<div>
<br>
<div class="f">
<textarea rows="1" name="question[]" class="question" id="1" maxlength="400" placeholder="Question" onkeyup="symbols(this)" onkeydown="new do_resize(this);" style=" resize: none;"></textarea><input type="number" name="Q_1_POINTS" class="point" placeholder="0" /><br>
<br>
<div>
<input type="radio" name="1[]" class="option" id="1" onchange="setval(this)" /><textarea name="Q_1[]" rows="1" placeholder="Option" class="text" maxlength="200" id="t1" onkeyup="symbols(this)" onkeydown="new do_resize(this);" style="resize: none;"></textarea><input type="button" value="X" class="cross"><br><br>
</div>
<div>
<input type="radio" name="1[]" class="option" id="2" onchange="setval(this)" /><textarea name="Q_1[]" rows="1" cols="70" class="text" maxlength="200" id="t2" placeholder="Option" onkeyup="symbols(this)" onkeydown="new do_resize(this);" style="resize: none;"></textarea><button class="cross">X</button><br><br>
</div>
<input type="button" class="add-option" value="Add Option" />
<button class="delete-question">Delete Question</button>
</div>
</div>
<input type="button" name="save" class="btn btn-primary" id="save" value="Save" onclick="myfun()" style="margin-top: 15px;"/>
</form>
</div>
<p class="copyright" style="margin-top:20px;text-align: center;color: var(--gray);">classregister © 2021. All rights are reserved.</p>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/bs-init.js"></script>
</body>
</html>