-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.php
793 lines (685 loc) · 31.1 KB
/
game.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
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
<?php include 'config.php';
session_start();error_reporting(0);
if(!isset($_SESSION["uid"])) {
?>
<?php include 'head.php';?>
<!-- if user id is not assigned -->
<body>
<div class="container">
<h1>OOPS!</h1><br> <h3>Please go <a href="index.php">here</a> first</h3>
</div>
</body>
</html>
<?php
}
elseif(!isset($_SESSION["connect"])) {
?>
<?php include_once 'head.php';?>
<!-- if no connection to database -->
<body>
<div class="container">
<h1>OOPS!</h1><br> <h3>Please go <a href="connect.php">here</a> first</h3>
</div>
</body>
</html>
<?php }
else {
if($_SESSION['counter'] <1) {
$coun = 0;
} else{
$coun = $_SESSION['counter'];
}
$factor2 = $_SESSION['factor2'];
$q = $coun +1;
if($factor2 == '0' || $factor2 == 0){
$_SESSION['ques'] = $_SESSION['a'][$coun];
$ques = $_SESSION['a'][$coun];
$sender_a = "SELECT `sender_address` FROM `humang_new` WHERE `S.No.` = $ques";
$resultsa=mysqli_query($conn, $sender_a);
$rowsa=mysqli_fetch_array($resultsa,MYSQLI_ASSOC);
$_SESSION['sen_add'] = $rowsa["sender_address"];
$subj = "SELECT `Subject` FROM `humang_new` WHERE `S.No.` = '$ques'";
$resultsub=mysqli_query($conn, $subj);
$rowsub=mysqli_fetch_array($resultsub,MYSQLI_ASSOC);
$_SESSION['subj'] = $rowsub["Subject"];
$bod = "SELECT `Body` FROM `humang_new` WHERE `S.No.` = '$ques'";
$resultbody=mysqli_query($conn, $bod);
$rowbody=mysqli_fetch_array($resultbody,MYSQLI_ASSOC);
$_SESSION['body'] = $rowbody["Body"];
$phs = "SELECT `Phishing` FROM `humang_new` WHERE `S.No.` = '$ques'";
$resultphs=mysqli_query($conn, $phs);
$rowphs=mysqli_fetch_array($resultphs,MYSQLI_ASSOC);
$_SESSION['actual'] = $rowphs["Phishing"];
$date = "SELECT `Date` FROM `humang_new` WHERE `S.No.` = '$ques'";
$resultdate=mysqli_query($conn, $date);
$rowdate=mysqli_fetch_array($resultdate,MYSQLI_ASSOC);
$_SESSION['date'] = $rowdate["Date"];
$cognibia = "SELECT `Cognitive Bias` FROM `humang_new` WHERE `S.No.` = '$ques'";
$resultcb=mysqli_query($conn, $cognibia);
$rowcb=mysqli_fetch_array($resultcb,MYSQLI_ASSOC);
$_SESSION['cogbias'] = $rowcb["Cognitive Bias"];
$gen = "SELECT `Generation` FROM `humang_new` WHERE `S.No.` = '$ques'";
$resultgen=mysqli_query($conn, $gen);
$rowgen=mysqli_fetch_array($resultgen,MYSQLI_ASSOC);
$_SESSION['generation'] = $rowgen["Generation"];
} else if($factor2 == '1' || $factor2 == 1){
$_SESSION['ques'] = $_SESSION['a'][$coun];
$ques = $_SESSION['ques'];
$sender_a = "SELECT `sender_address` FROM `gpt0308g_new` WHERE `S.No.` = '$ques'";
$resultsa=mysqli_query($conn, $sender_a);
$rowsa=mysqli_fetch_array($resultsa,MYSQLI_ASSOC);
$_SESSION['sen_add'] = $rowsa["sender_address"];
$subj = "SELECT `Subject` FROM `gpt0308g_new` WHERE `S.No.` = '$ques'";
$resultsub=mysqli_query($conn, $subj);
$rowsub=mysqli_fetch_array($resultsub,MYSQLI_ASSOC);
$_SESSION['subj'] = $rowsub["Subject"];
$bod = "SELECT `Body` FROM `gpt0308g_new` WHERE `S.No.` = '$ques'";
$resultbody=mysqli_query($conn, $bod);
$rowbody=mysqli_fetch_array($resultbody,MYSQLI_ASSOC);
$_SESSION['body'] = $rowbody["Body"];
$phs = "SELECT `Phishing` FROM `gpt0308g_new` WHERE `S.No.` = '$ques'";
$resultphs=mysqli_query($conn, $phs);
$rowphs=mysqli_fetch_array($resultphs,MYSQLI_ASSOC);
$_SESSION['actual'] = $rowphs["Phishing"];
$date = "SELECT `Date` FROM `gpt0308g_new` WHERE `S.No.` = '$ques'";
$resultdate=mysqli_query($conn, $date);
$rowdate=mysqli_fetch_array($resultdate,MYSQLI_ASSOC);
$_SESSION['date'] = $rowdate["Date"];
$cognibia = "SELECT `Cognitive Bias` FROM `gpt0308g_new` WHERE `S.No.` = '$ques'";
$resultcb=mysqli_query($conn, $cognibia);
$rowcb=mysqli_fetch_array($resultcb,MYSQLI_ASSOC);
$_SESSION['cogbias'] = $rowcb["Cognitive Bias"];
$gen = "SELECT `Generation` FROM `gpt0308g_new` WHERE `S.No.` = '$ques'";
$resultgen=mysqli_query($conn, $gen);
$rowgen=mysqli_fetch_array($resultgen,MYSQLI_ASSOC);
$_SESSION['generation'] = $rowgen["Generation"];
} else if($factor2 == '2' || $factor2 == 2){
$ques = $_SESSION['ques'];
$sender_a = "SELECT `sender_address` FROM `gpt0308g_1` WHERE `S.No.` = '$ques'";
$resultsa=mysqli_query($conn, $sender_a);
$rowsa=mysqli_fetch_array($resultsa,MYSQLI_ASSOC);
$_SESSION['sen_add'] = $rowsa["sender_address"];
$subj = "SELECT `Subject` FROM `gpt0308g_1` WHERE `S.No.` = '$ques'";
$resultsub=mysqli_query($conn, $subj);
$rowsub=mysqli_fetch_array($resultsub,MYSQLI_ASSOC);
$_SESSION['subj'] = $rowsub["Subject"];
$bod = "SELECT `Body` FROM `gpt0308g_1` WHERE `S.No.` = '$ques'";
$resultbody=mysqli_query($conn, $bod);
$rowbody=mysqli_fetch_array($resultbody,MYSQLI_ASSOC);
$_SESSION['body'] = $rowbody["Body"];
$phs = "SELECT `Phishing` FROM `gpt0308g_1` WHERE `S.No.` = '$ques'";
$resultphs=mysqli_query($conn, $phs);
$rowphs=mysqli_fetch_array($resultphs,MYSQLI_ASSOC);
$_SESSION['actual'] = $rowphs["Phishing"];
}
// echo $ques.$sender_a.$subj.$bod.$phs.$cond;
$ran = rand(1,100);
$prob = $ran;
if($ran > 50){
if($_SESSION['actual'] == 0){
$actual = 'Genuine';
}
else if($_SESSION['actual'] == 1){
$actual = 'Phishing';
}
} else {
if($_SESSION['actual'] == 0){
$actual = 'Phishing';
} else if($_SESSION['actual'] == 1){
$actual = 'Genuine';
}
}
?>
<!-- main game page starts here -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Phishing Email Detection Game</title>
<link href="http://fonts.googleapis.com/css?family=Open+Sans:regular,semibold,italic,italicsemibold|PT+Sans:400,700,400italic,700italic|PT+Serif:400,700,400italic,700italic" rel="stylesheet" />
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<script src="js/jquery.min.js"></script>
<script src="js/highcharts.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- Eye Tracking Script -->
<script type="text/javascript" src="js/TobiiWeb_Client.js"></script>
<link rel="shortcut icon" href="21.png" />
<link rel="apple-touch-icon" href="apple-touch-icon.png" />
<style>
.container1{
width:400px;
.slidecontainer {
width: 90%;
}
.slider {
-webkit-appearance: none;
width: 90%;
height: 25px;
background: bisque;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
}
.slider:hover {
opacity: 1;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 25px;
height: 25px;
background: burlywood;
cursor: pointer;
}
.slider::-moz-range-thumb {
width: 20px;
height: 25px;
background: burlywood;
cursor: pointer;
}
body {
font-family: Arial;
color: white;
}
.text-center {
text-align: center;
}
textarea {
width: 100%;
height: 150px;
padding: 12px 20px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
background-color: #f8f8f8;
font-size: 16px;
resize: none;
}
.splitl {
height: 100%;
width: 60%;
position: fixed;
z-index: 1;
top: 0;
overflow-x: hidden;
padding-top: 20px;
}
div.bo {
border-style: solid;
border-color: burlywood;
}
.split {
height: 100%;
width: 40%;
position: fixed;
z-index: 1;
top: 0;
overflow-x: hidden;
padding-top: 20px;
}
.button {
border: none;
color: white;
padding: 16px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
transition-duration: 0.4s;
cursor: pointer;
}
.button1 {
background-color: floralwhite;
color: black;
border: 2px solid lightgreen;
}
.button1:hover {
background-color: lightgreen;
color: white;
}
.button2 {
background-color: floralwhite;
color: black;
border: 2px solid lightcoral;
}
.button2:hover {
background-color: lightcoral;
color: white;
}
.sub {
background-color: blanchedalmond;
color: black;
border: 2px solid burlywood;
}
.sub:hover {
background-color: burlywood;
color: black ;
}
.left {
left: 0;
background-color: white;
}
.right {
right: 0;
background-color: floralwhite;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
overflow: scroll;
}
.btn-group .co {
background-color: burlywood;
border: 1px solid ;
color: white;
padding: 5px 18px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
cursor: pointer;
float: left;
}
.btn-group .co:not(:last-child) {
border-right: none; /* Prevent double borders */
}
.btn-group .co:hover {
background-color: bisque;
}
.ema {
position: fixed;
top: 40%;
left: 35%;
transform: translate(-50%, -50%);
text-align: left;
overflow: scroll;
}
p {
font-size: 14px;
color:black;
}
h2 {
color:black;
}
#sa {
height: 20px;
border: solid 1px lightgray;
color:black;
width: 80%;
padding: 5px;
font-size: 14px;
}
#body {
height: 350px;
border: solid 1px lightgray;
color:black;
width: 80%;
padding: 5px;
font-size: 14px;
}
.centered img {
width: 150px;
border-radius: 50%;
}
.tab {
margin-left: 50px;
margin-right: 50px;
}
.tab2 {
margin-left: 80px;
margin-right: 50px;
}
}
</style>
</head>
<body>
<!-- BODY -->
<div class="container-fluid">
<!-- messages-->
<div class="row">
<div class="col-md-12"><div class="jumbotron">
<div class="row">
<div class = "row">
<div class="splitl left bo col-lg-7">
<div class="hint-container">
<h3>
<b><button id="hintButton" style=" color: white; border: none; cursor: pointer;width:130px;height:50px;font-size:100%;" class="btn btn-md btn-primary">Hint</button></b>
</h3>
<h3 id="hintText" style="display: none; color: black; margin-top: -6px; position: absolute;"> This seems to be <?php echo $actual;?> email.</h3>
</div>
<br>
<h3><b>Email <?php echo $q; ?>:</b></h3>
<!--<<h3><b>counter <?php echo $coun;?>:</b></h3>
div id="co" style="width:700px;height:70px;">
<h4>< ?php echo $_SESSION['cover']; ?></h4></div>-->
<div class="ema">
<!-- <h2>< ?php// echo $_SESSION['subj']; ?> </h2>-->
<div id="sa" style="width:700px;height:70px;padding:2px;border:1px solid #cccbcb;font-size:130%;"><b>From:</b> <?php echo $_SESSION['sen_add']; ?></div>
<div id="da" style="width:700px;height:70px;padding:2px;border:1px solid #cccbcb;font-size:130%;"><b>Date:</b> <?php echo $_SESSION['date']; ?> </div>
<div id="sub" style="width:700px;height:70px;padding:2px;border:1px solid #cccbcb;font-size:130%;"><b>Subject:</b> <?php echo $_SESSION['subj']; ?></div>
<!-- <div id="to" style="width:850px;height:35px;padding:2px;border:1px solid #cccbcb;font-size:130%;"><b>To:</b> You <[email protected]></div>-->
<div id ="body" style="width:700px;height:1000px;padding:8px;border:1px solid #cccbcb;font-size:130%;"><?php echo $_SESSION['body'] ?></div>
</div>
</div>
<div class="split right bo col-lg-auto">
<div style="color:black; margin-left: 10px;">
<div class="ema2">
<h3><b>Answer the following questions:</b></h3>
<h4>
<form role="form" id="form2" name="form2" method="post" onsubmit='return valthisformAndSaveData()' action="./process.php?id=<?php ?>&decision=true">
<!--<form method="POST">
<?php// echo $_SESSION['reaction'].$_SESSION['reason'].$_SESSION['myRange']; ?> -->
<!-- Q1 -->
<label for="ques">Q1. How likely do you think this email is genuine or phishing?</label><br><br>
<input type="range" isChanged="false" min="0" max="100" value="50" style="width:550px;" class="slider" id="ques" name = "ques" oninput="javascript:checkphish()" required = "true"/>
<label for="slider">Phishing</label>          <label for="slider">Neutral</label>          <label for="slider">Genuine</label>
<br><br><br>
<!--<label for="choice1">Phishing</label>
<input type="radio" id="phish" name="ques" value="phishing" onclick="javascript:Check1()" required/>
               
<label for="choice2">Genuine</label>
<input type="radio" id="genuine" name="ques" value="genuine" onclick="javascript:Check2()"/>
<!-- <input type="radio" id="phish" onclick="javascript:Check1();" name="phish" value="phish"/>Phishing                   
<input type="radio" id="genuine" onclick="javascript:Check2();" name="genuine" value="genuine"/>Genuine
<br><br><br>-->
<!-- Q2 -->
<label for="confidence">Q2. How confident are you on your answer in above question?<br>(1 = Not Confident at all; 100: Fully Confident)</label>
<br><br>
<input type="range" min="0" max="100" isChanged="false" value="" style="width:550px;" class="slider" id="myRange" name = "myRange" oninput="javascript:checkconfidence()" required="true"/>
<label for="range">1</label>                              <label for="range">100</label>
<br><br><br>
<!-- Q3 -->
<label for="reason">Q3. How did you make your decision in Q1 above?</label><br>
<!-- <input type="hidden" id = rea name="reason[]" value="" required/>-->
<div>
<input type="checkbox" id = rea1 name="reason[]" value="Based upon senders email address" onclick="javascript:checkreason()">
<label for="Reason1">Based upon sender's email address</label><br>
</div>
<div>
<input type="checkbox" id = rea3 name="reason[]" value="Based upon the subject line in the email" onclick="javascript:checkreason()">
<label for="Reason3">Based upon the subject line in the email</label>
</div>
<div>
<input type="checkbox" id = rea4 name="reason[]" value="Based upon the date in the email" onclick="javascript:checkreason()">
<label for="Reason4">Based upon the date in the email</label>
</div>
<div>
<input type="checkbox" id = rea2 name="reason[]" value="Based upon body of the email" onclick="javascript:checkreason()">
<label for="Reason2">Based upon body of the email</label><br>
</div>
<div>
<input type="checkbox" id = rea5 name="reason[]" value="Based upon the link/attachment in the email" onclick="javascript:checkreason()">
<label for="Reason5">Based upon the link/attachment in the email</label>
</div>
<div>
<input type="checkbox" id="other" name="reason[]" value="Based upon some other reason" onclick="javascript:openother()">
<label for="other">Based upon some other reason</label>
<input type="textarea" id="other1" name="reason[]" style="visibility:hidden" onclick="javascript:checkreason()">
</div>
<br><br><br>
<!-- Q4 -->
<label for="reaction">Q4. If you recieve this email, what will be your reaction?</label><br>
<!-- <input type="hidden" id = reac name="reaction[]" value="" required/>-->
<div>
<input type="checkbox" id = "reac6" name="reaction[]" value="Read the email and do nothing" onclick="javascript:checkreaction()">
<label for="Reaction6">Read the email and do nothing</label><br>
</div>
<div>
<input type="checkbox" id = "reac1" name="reaction[]" value="Respond to this email" onclick="javascript:checkreaction()">
<label for="Reaction1">Respond to this email</label><br>
</div>
<div>
<input type="checkbox" id = "reac2" name="reaction[]" value="Click link/ Open attachment" onclick="javascript:checkreaction()">
<label for="Reaction2">Click link/ Open attachment</label><br>
</div>
<div>
<input type="checkbox" id = "reac3" name="reaction[]" value="Move to spam" onclick="javascript:checkreaction()">
<label for="Reason3">Move to spam</label>
</div>
<div>
<input type="checkbox" id = reac4 name="reaction[]" value="Delete this email" onclick="javascript:checkreaction()">
<label for="Reason4">Delete this email</label>
</div>
<div>
<input type="checkbox" id = reac5 name="reaction[]" value="Report this email" onclick="javascript:checkreaction()">
<label for="Reason5">Report this email</label>
</div>
<input type="hidden" name="q1time" id="q1time" value='' />
<input type="hidden" name="q2time" id="q2time" value='' />
<input type="hidden" name="q3time" id="q3time" value='' />
<input type="hidden" name="q4time" id="q4time" value='' />
<input type="hidden" name="click_ques" id="click_ques" value='' />
<input type="hidden" name="click_id" id="click_id" value='' />
<input type="hidden" name="atnck2" id="atnck2" value='' />
<input type="hidden" name="atnck1" id="atnck1" value='' />
<!-- Probablity Logic -->
<input type="hidden" name="hint_time" id="hint_time" value='' />
<input type="hidden" name="hint_use" id="hint_use" value='' />
<input type="hidden" name="probability" id="probability" value='' />
<!-- to POST tracking data to be saved in database -->
<input type="hidden" name="trackingData" id="trackingData" value="">
</h4>
<div class="text-center">
<!--<input type="submit" class="button tab sub" value="Submit">-->
<h4>
<input type="submit" value="Submit" style="width:130px;height:50px;font-size:100%;" class="btn btn-md btn-primary" id="submitted" onclick = "javascript:valthisform()">
</h4>
</div>
</form>
</div>
</div>
</div>
</div>
<!--
<div class="form-group">
<div class=container2 id="ifYesPlan" style="visibility:hidden">
<input type="checkbox" onclick="javascript:Check1();" name="chk1" id="Checkbox1" > Yes, I would like to enroll into a health insurance plan for the next year (1173 EC/year).
<br>
<input type="checkbox" onclick="javascript:Check2();" name="chk2" id="Checkbox2" > Yes, I would like to enroll into a life insurance plan for the next year (488 EC/year).
<br>
<input type="checkbox" onclick="javascript:Check3();" name="chk3" id="Checkbox3" > Yes, I would like to enroll into a property insurance plan for the next year (1884 EC/year).
<br>
</div>
</div>
<input type="hidden" name="checkOne" id="checkOne" value=0 />
<input type="hidden" name="checkTwo" id="checkTwo" value=0 />
<input type="hidden" name="checkThree" id="checkThree" value=0 />
<input type="checkbox" onclick="javascript:mitigationChecked();" name="mitigation" id="mitigationCheck" > I would like to decide the investment for mitigating climate change myself for the next year.
<div class="form-group">
<div class=container1 id="ifNoPlan" style="visibility:hidden">
<label>
HELP MODAL BUTTON
</div>
</form> -->
<!-- Modal -->
</div>
</div>
</div>
<!-- Game Parameters -->
</div>
</div>
<script type="text/javascript">
function preventBack() {
window.history.forward();
}
setTimeout("preventBack()", 0);
window.onunload = function () { null };
var a = 'false';
var b = 'false';
function openother() {
if (document.getElementById('other').checked) {
document.getElementById('other1').style.visibility = 'visible';
} else{
document.getElementById('other1').style.visibility = 'hidden';
}
}
function func(k){
var qus = '<?php echo $_SESSION['ques'] ?>';
var mt_id = '<?php echo $_SESSION['mturk'] ?>';
document.getElementById('click_id').value = mt_id;
document.getElementById('click_ques').value = qus;
return false;
}
function checkphish(){
document.getElementById('q1time').value = Date();
document.getElementById("ques").setAttribute("ischanged", "true");
}
document.addEventListener("DOMContentLoaded", function () {
const hintButton = document.getElementById("hintButton");
const hintText = document.getElementById("hintText");
const submitbutton = document.getElementById("submitted");
document.getElementById('hint_use').value = "Not used";
// Get the unique identifier for the current question (replace with your logic)
const currentQuestion = "<?php echo $ques; ?>";// Replace with your logic
// Check if the hint has already been used for this question
const hintUsed = localStorage.getItem(currentQuestion + "_hintUsed");
// Function to show the hint
function showHint() {
// Check if the hint has already been used for this question
document.getElementById('hint_time').value = Date();
document.getElementById('hint_use').value = "Used";
document.getElementById('probability').value = "<?php echo $ran; ?>";
if (hintUsed !== "true") {
// Show the hint
hintText.style.display = "block";
// Disable the button
hintButton.disabled = true;
// Mark the hint as used for this question
localStorage.setItem(currentQuestion + "_hintUsed", "true");
// Hide the hint after 5 seconds
setTimeout(function () {
hintText.style.display = "none";
}, 5000); // 5000 milliseconds (5 seconds)
}
}
// If the hint has been used, disable the button
if (hintUsed === "true") {
hintButton.disabled = true;
}
hintButton.addEventListener("click", showHint);
submitbutton.addEventListener("click", function(){
localStorage.removeItem(currentQuestion + "_hintUsed");
});
});
function checkreaction(){
document.getElementById('q4time').value = Date();
var reacti = document.forms["form2"]["reaction"];
if (!empty(reacti)) {
return true;
}
}
function attentionCheck() {
var trial = '<?php echo $_SESSION['ques'] ?>';
var n1 = '<?php echo $my_id."_a1" ?>';
var n2 = '<?php echo $my_id."_a2" ?>';
console.log(n1);
if(!localStorage.getItem(n1) && !localStorage.getItem(n2)) {
localStorage.setItem(n1, "false");
localStorage.setItem(n2, "false");
}
if(trial == 2 && localStorage.getItem(n1)==="false"){
localStorage.setItem(n1, "true");
var question = "Which day is today?";
var response = prompt(question);
document.getElementById('atnck1').value = response;
}
if(trial == 20 && localStorage.getItem(n2)==="false"){
localStorage.setItem(n2, "true");
var question = "What was your response to Q1 in previous question";
document.getElementById('atnck2').value = response;
}
}
function checkconfidence(){
document.getElementById('q2time').value = Date();
document.getElementById("myRange").setAttribute("ischanged", "true");
}
function checkreason(){
document.getElementById('q3time').value = Date();
var reas = document.getElementById("rea");
if (reas == '') {
return false;
}
}
function valthisform() {
var quesChanged = document.getElementById("ques").getAttribute("ischanged");
var rangeChanged = document.getElementById("myRange").getAttribute("ischanged");
var reasonChecked = document.getElementsByName('reason[]');
if (quesChanged == "false"){
alert ("Please answer Question 1");
return false;
} else if (rangeChanged == "false"){
alert ("Please answer Question 2");
return false;
} else if(!(form2.rea1.checked || form2.rea2.checked || form2.rea3.checked || form2.rea4.checked || form2.rea5.checked || form2.other.checked)){
alert("Please answer Question 3");
return false;
} else if(!(form2.reac1.checked || form2.reac2.checked || form2.reac3.checked || form2.reac4.checked || form2.reac5.checked || form2.reac6.checked)){
alert("Please answer Question 4");
return false;
} else{
return true;
}
}
function valthisformAndSaveData(){
if(valthisform()){
const trackingDataInput = document.getElementById('trackingData');
trackingDataInput.value = JSON.stringify(trackingData);
// saveTrackingData();
} else{
return false;
}
}
// Eye Tracking Service Start
let trackingData = [];
function startTracking(){
TobiiWeb_Client.start({
enable_state_machine_logs : true,
use_filter : "mean",
services : [
{name : "GazeTracking_Service", page_url : window.location.href}
],
onMessage : {
"GazeTracking_Service" : GazeCoordinatesReceiver({
filter: "mean",
filter_size: 5,
onGazeCoordinates: function(x,y){
// console.log(x + ", " + y);
trackingData.push({ x_axis: x, y_axis: y, timestamp: new Date().getTime(), datetimestamp : new Date().toISOString() });
}
})
}
});
}
window.onload = startTracking;
function saveTrackingData() {
const trackingDataStr = trackingData.map(data =>
`${data.timestamp}, ${data.datetimestamp}, ${data.x_axis}, ${data.y_axis}`
).join('\n');
const blob = new Blob([trackingDataStr], { type: 'text/plain' });
const a = document.createElement('a');
var UID = '<?php echo $_SESSION["uid"]; ?>';
var questionNo = '<?php echo $ques; ?>';
a.download = UID + '_' + questionNo +'.txt';
// Create a URL for the blob and set it as the href attribute
a.href = window.URL.createObjectURL(blob);
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
// Eye Tracking Service Stop
// function stopTracking() {
// TobiiWeb_Client.stop()
// }
</script>
<!-- FOOTER without any links -->
<?php include 'footer.php';?>
</body>
</html>
<?php }
?>
<!-- scripts for charts -->