-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstarted-exam.php
More file actions
125 lines (102 loc) · 2.97 KB
/
started-exam.php
File metadata and controls
125 lines (102 loc) · 2.97 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
<?php
include './system.php';
include './database.php';
include './event.php';
include './modules/exam.php';
System::sessionStart();
if (filter_input(INPUT_GET, 'examName')) {
$examName = filter_input(INPUT_GET, 'examName');
$_SESSION['names'] = $examName;
} else;
if (isset($_SESSION['names'])) {
$title = $_SESSION['names'];
} else {
$title = 'Грешка';
}
System::setContentTitle($title);
System::getPageHeader();
System::setTimeZone("Europe/Sofia");
if (isset($_SESSION['isLogged']) === true) {
Database::setDatabaseConnection();
if (filter_input(INPUT_POST, 'formSubmit') == 1) {
$object = $_SESSION['objects'];
$object->submitAnswers();
$object->checkAnswers();
$object->calculatePoints();
$object->setScore();
Event::getExamAnswersSubmitSuccess();
} else {
$object = new Exam();
$_SESSION['objects'] = $object;
$userID = $_SESSION['userInfo']['id'];
$object->setUserID($userID);
/*
if (filter_input(INPUT_GET, 'examName')) {
$examName = filter_input(INPUT_GET, 'examName');
$_SESSION['names'] = $examName;
} else;*/
$object->setExamName($_SESSION['names']); //$examName;
$object->setExamQuery();
$object->setExamInfo();
//$object->initQuestions();
$examTime = 3600;
if ($object->verifyPassword()) {
//$object->initQuestions();
$object->setQuestions();
$object->getQuestions();
}
}
//
?>
<script type="text/javascript">
var hours;
var minutes;
var sec = 60;
function Countdown(options) {
var timer,
instance = this,
seconds = options.seconds || 10,
updateStatus = options.onUpdateStatus || function () {},
counterEnd = options.onCounterEnd || function () {};
function decrementCounter() {
updateStatus(seconds);
if (seconds === 0) {
counterEnd();
instance.stop();
}
if (sec == 0) {
sec = 60;
}
sec--;
//localStorage.setItem("someVarName", seconds);
seconds = localStorage.getItem("someVarName");
seconds--;
localStorage.setItem("someVarName", seconds);
}
this.start = function () {
clearInterval(timer);
timer = 0;
seconds = options.seconds;
timer = setInterval(decrementCounter, 1000);
};
this.stop = function () {
clearInterval(timer);
};
}
var myCounter = new Countdown({
seconds:localStorage.getItem("someVarName"), // number of seconds to count down
onUpdateStatus: function(seconds){
hours = parseInt(seconds / 3600);
minutes = parseInt(seconds / 60);
//sec = parseInt(sec);
$('.message').html("<strong>" + hours + " : " + minutes + " : " + sec + "</strong>" + localStorage.getItem("someVarName"));
}, // callback for each second - console.log(sec);
onCounterEnd: function(){ /*$('#questions').submit();*/} // final action - alert('counter ended!');
});
myCounter.start();
</script>
<?php
} else {
Event::getExamsLoginError();
}
System::getPageFooter();