-
Notifications
You must be signed in to change notification settings - Fork 0
/
u_play_test.php
175 lines (157 loc) · 6.35 KB
/
u_play_test.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
<?php
session_start();
include_once("db_functions.php");
if(isset($_POST['mavzu'])){
$query = "SELECT * FROM u_test_num where id=".$_POST['mavzu']." AND status='ACTIVE'";
$result = queryMysql($query);
if(mysqli_num_rows($result)<1){
echo "Siz kiritgan test raqami hozirda Faol emas";
exit();
}
$_SESSION['ism'] = Filter($_POST['ism']);
$_SESSION['familiya'] = Filter($_POST['familiya']);
$_SESSION['mavzu'] = Filter($_POST['mavzu']);
$start_time = date("d/m/Y")." | ".date("h:i:sa");
$query = "SELECT * FROM u_test_num where id=".$_POST['mavzu'];
$result = queryMysql($query);
$row = mysqli_fetch_assoc($result);
$mavzu_name = $row['name'];
$_SESSION['mavzu_name'] = $mavzu_name;
$query = "INSERT INTO u_user_taken_test(name,surname,test_name,start_time) VALUES('".$_SESSION['ism']."','".$_SESSION['familiya']."','".$mavzu_name."','".$start_time."')";
$result = queryMysql($query);
$s = "select count(id) from u_tests where test_num=".$_SESSION['mavzu'];
$res = queryMysql($s);
$i = $res->fetch_array(MYSQLI_ASSOC);
$_SESSION['soni'] = $i['count(id)']-1;
if($_SESSION['soni']==-1){
echo "<center><H1>Testga kirish kaliti noto'g'ri !!!</H1></center>";
echo "<center><a href='/index.php'>Ortga....</a></center>";
exit();
}
}else{
echo "Test mavzusi tanlanmadi !";
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test topshirish oynasi</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<script src="assets/js_new/jquery.min.js"></script>
<script src="assets/js_new/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h3><?php echo "Ism :".$_SESSION['ism']." | Familiya :".$_SESSION['familiya'] ; ?></h3>
<form method="POST" id="tekshirish" action="u_check.php">
<!-- Savol nomerlari bolimi -->
<input type="hidden" name="tekshir">
<ul class="nav nav-pills">
<?php
while ($e<=$_SESSION['soni']) {
$e++;
if($e==1){
echo '<li class="active"><a id='.$e.' data-toggle="pill" href="#item'.$e.'">'.$e.'</a></li>';
}else{
echo '<li ><a id='.$e.' data-toggle="pill" href="#item'.$e.'">'.$e.'</a></li>';
}
}
?>
</ul>
<!-- Savol nomerlari bolimi tugashi -->
<div class="tab-content">
<!-- Test javoblarini belgilash bo'limi -->
<?php
$query = 'select * from u_tests where test_num='.$_SESSION['mavzu'];
$result = queryMysql($query);
while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
$k++;
if($k==1){
echo '<div id="item'.$k.'" class="tab-pane fade in active"> ';
echo '<h3>'.$row['question'].'</h3>';
echo "<br>";
echo '<div class="radio">';
echo ' <label><input type="radio" group="a" value="1" name="answers'.$k.'">'.$row['item1'].'</label>';
echo '</div>';
echo "<br>";
echo '<div class="radio">';
echo ' <label><input type="radio" group="a" value="2" name="answers'.$k.'">'.$row['item2'].'</label>';
echo '</div>';
echo "<br>";
echo '<div class="radio">';
echo ' <label><input type="radio" group="a" value="3" name="answers'.$k.'">'.$row['item3'].'</label>';
echo '</div>';
echo '</div>';
}else{
echo '<div id="item'.$k.'" class="tab-pane fade"> ';
echo '<h3>'.$row['question'].'</h3>';
echo "<br>";
echo '<div class="radio">';
echo ' <label><input type="radio" value="1" name="answers'.$k.'">'.$row['item1'].'</label>';
echo '</div>';
echo "<br>";
echo '<div class="radio">';
echo ' <label><input type="radio" value="2" name="answers'.$k.'">'.$row['item2'].'</label>';
echo '</div>';
echo "<br>";
echo '<div class="radio">';
echo ' <label><input type="radio" value="3" name="answers'.$k.'">'.$row['item3'].'</label>';
echo '</div>';
echo '</div>';
}
}
?>
<!-- Test javoblarini belgilash bo'limi -->
<br>
<br>
<div class="btn-group btn-group-justified">
<div class="btn-group">
<button type="button" class="btn btn-primary" id="prev">oldingi</button>
</div>
<div class="btn-group">
<button type="button" class="btn btn-primary" id="next">keyingi</button>
</div>
</div>
<br>
<button name="submitt" type="button" class="btn btn-danger btn-lg btn-block" data-toggle="modal" data-target="#contact_dialog">Testni tugatish</button>
<script>
let next = document.getElementById('next');
let prev = document.getElementById('prev');
next.addEventListener('click',nextF);
function nextF(){
(document.getElementById(parseInt(document.querySelector('.nav-pills > .active').children[0].id)+1).click());
}
prev.addEventListener('click',prevF);
function prevF(){
(document.getElementById(parseInt(document.querySelector('.nav-pills > .active').children[0].id)-1).click());
}
</script>
</div>
</div>
</form>
<div class="modal fade" id="contact_dialog" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<h4 class="modal-title">Testni tugatmoqchimisiz ?</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Yo'q</button>
<button type="button" id="submitForm" class="btn btn-default">Ha</button>
</div>
</div>
</div>
</div>
<script>
$("#submitForm").on('click', function() {
$("#tekshirish").submit();
});
</script>
</body>
</html>