-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewEmptyPHP.php
More file actions
115 lines (93 loc) · 3.59 KB
/
newEmptyPHP.php
File metadata and controls
115 lines (93 loc) · 3.59 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
<?php
#session_start(); str_ireplace(); - case insensitive
include 'system.php';
System::getPageHeader();
if (isset($_SESSION['is_logged']) === true) {
System::db_init();
$questionsDataQuery = System::run_mysql_query('SELECT id, question, question_type FROM os_exam_questions WHERE question_type = "Отворен" AND exam_type = "Контролна";');
$examsDataQuery = System::run_mysql_query('SELECT id, time, question_type, question_count FROM exams WHERE exam_name = "Операционни Системи - Тест 1"');
?>
<article id="main_content_body">
<header>
<div id="main_content_title">Контролна - ОС</div>
</header>
<?php
if (isset($_POST['form_submit']) == 1) {
foreach ($questionsArray as $value){
$answersArray[$index] = array('id' => $value['id'], 'answer' => $_POST['answer'.$value['id']]);
$index++;
}
foreach ($answersArray as $value) {
System::run_mysql_query('INSERT INTO students_exam_results (user_id, exam_id, question_id, student_answer) VALUES ("'.$userID.'", "'.$examID.'", "'.$value['id'].'", "'.$value['answer'].'");');
}
} else {
$userID = $_SESSION['user_info']['id'];
$examInfo = mysql_fetch_assoc($examsDataQuery);
$examID = $examInfo['id'];
$questionCount = $examInfo['question_count'];
$examTime = $examInfo['time'];
$index = 0;
$questionsArray = null;
$answersArray = null;
//if ($output2['question_type'] === "Отворени") {
while($questionInfo = mysql_fetch_assoc($questionsDataQuery)){
if ($questionInfo['question_type'] === "Отворен") {
//if ($index < $questionCount) {
$questionsArray[$index] = array('id' => $questionInfo['id'], 'question' => $questionInfo['question']);
$index++;
//} else;
}
}
$index = 0;
shuffle($questionsArray);
?>
<div class="clock" style="margin:20px 120px; border: 1px solid black; width: 460px;"></div>
<div class="message"></div>
<form action="started-exam.php" method="POST">
<table class="custom-table" border="0">
<tbody>
<?php
foreach ($questionsArray as $value) {
echo '<tr>'
. '<td class="left">'.$value['question'].' - <input name="answer'.$value['id'].'" type="text" /></td>'
. '</tr>';
}
}
?>
<tr>
<td><input type="hidden" name="form_submit" value="1" /></td>
</tr>
<tr>
<td><input type="submit" id="sub" name="submit" value="Завърши теста" /></td>
</tr>
</tbody>
</table>
</form>
<footer>
</footer>
</article>
<script type="text/javascript">
var time = <?php echo json_encode($examTime); ?>;
var clock;
$(document).ready(function() {
clock = $('.clock').FlipClock(2, {
clockFace: 'HourlyCounter', countdown: true, callbacks: {
stop: function() {
$('.message').html('Game Over!');
$('.message').html(clock.getTime().time);
}
}
});
});
</script>
<?php
} else {
echo'
<center>
<div id="main_content_body">
<div id="main_content_title">Грешка</div>
<p><img src="img/fail.png" width="24" heigh="24" /> <span style="bottom:7px; position:relative;">За да използваш библиотеката трябва да си регистриран потребител и да си влязъл в системата.</span></p>
</div>
</center>';
}
System::getPageFooter();