-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowquestions.php
193 lines (126 loc) · 4.24 KB
/
showquestions.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
<?php
include 'config.php';
session_start();
$con= mysqli_connect("$db_host","$db_user","$db_pass");
mysqli_select_db($con,"$db_name");
// if($con)
// {
// echo "connection succesful";
// }
// else
// {
// echo "connection failed";
// }
$quizname=$_POST['quizcode'];
$_SESSION['qcode']=$quizname;
$qq= "select * from quizs where qcode='$quizname' ";
$query = mysqli_query($con, $qq);
$rr = mysqli_fetch_array($query);
$timelimit = $rr['qtimelimit'];
$_SESSION['refreshstatus']=1;
?>
<!DOCTYPE html>
<html>
<head>
<title>
participate in quiz
</title>
<style type="text/css">
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<style type="text/css">
.upstick{
position: fixed;
left: 4px;
top: 20px;
z-index: 1000;
}
</style>
<script>
var timelimit = <?php echo $timelimit; ?>;
var countdown = timelimit * 60 * 1000;
var timerId = setInterval(function(){
countdown -= 1000;
var min = Math.floor(countdown / (60 * 1000));
//var sec = Math.floor(countdown - (min * 60 * 1000)); // wrong
var sec = Math.floor((countdown - (min * 60 * 1000)) / 1000); //correct
if (countdown <= 0) {
alert("quiz finished submit your answers");
clearInterval(timerId);
//doSomething();
} else {
document.getElementById('timer').innerHTML=min+":"+sec;
}
}, 1000); //1000ms. = 1sec
</script>
</head>
<body >
<div class="container border rounded-pill shadow p-3 mb-5 bg-success rounded " style="margin-top:30px " >
<h1 class="text-center text-dark">welcome <?php echo $_SESSION['username']; ?></h1>
</div>
<div class="container border rounded-lg bg-light">
<!--
<div class=" text-center shadow upstick" >
<h3 style="padding: 20px" > Time Left: <span id='timer'></span></h3>
</div> -->
<?php
$qans = $quizname."ans";
$q=" select * from $quizname";
$query = mysqli_query($con,$q);
$num= mysqli_num_rows($query);
?>
<div class="shadow text-center" >
<h3 style="padding: 20px" > Time Left: <span id='timer'></span></h3>
</div>
<form action="checkanswers.php" method="post">
<?php
$i=1;
while ($rows = mysqli_fetch_array($query)) {
?>
<div class="card shadow-sm p-3 mb-5 bg-white rounded ">
<h3 class="card-header"><?php echo "Q.".$rows['qid']." ".$rows['qtext']; ?></h3>
<?php
$ss=(int)($i/10);
$qy = " select * from $qans where qid= $i";
$quer = mysqli_query($con,$qy);
while ($row = mysqli_fetch_array($quer)) {
?>
<div class="card-body">
<input type="radio" name="quizcheck[<?php echo $rows['qid'] ?>]" value="<?php echo $row['ansid'] ?>">
<?php
echo $row['cans'];
?>
</div>
<?php
}
?>
</div>
<?php
$i++;
}
?>
<br>
<div class="text-center text-primary " style="margin: 10px">
<input type="submit" name="submit" value="submit your answers" class="btn btn-primary btn-lg btn-block shadow p-3 mb-5 bg">
</div>
</form>
</div>
</body>
</html>