-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-permanent-exam.php
425 lines (346 loc) · 17.9 KB
/
start-permanent-exam.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
<?php
// if(!isset($_SESSION['username'])){
// header("Location: login.php");
// }
?>
<?php require_once("backend/config.php"); ?>
<?php
// student session start
$username = $_SESSION['username'];
$select_student=query("SELECT * FROM `students` where email='$username' ");
$fetch_student=fetch_array($select_student);
$std_row=$fetch_student['id'];
// student session end
?>
<?php
$examID = $_GET['examID'];
$query = query("SELECT * FROM `exam` WHERE action='SHOW' AND id='$examID'");
confirm($query);
$rowOfExam = fetch_array($query);
$exName = $rowOfExam['name'];
$examTime = $rowOfExam['examTime'];
$scheduleDate = $rowOfExam['scheduleDate'];
$scheduleTime = $rowOfExam['scheduleTime'];
$total_mark = $rowOfExam['total_mark'];
$passed_mark = $rowOfExam['passed_mark'];
$maxQuestionNum = $rowOfExam['maxQuestionNum'];
?>
<!doctype html>
<html lang="en">
<!-- Mirrored from preview.colorlib.com/theme/etrain/index.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 23 Dec 2020 08:16:20 GMT -->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>MarchForwardBD</title>
<link rel="icon" href="media/fav.png">
<link rel="stylesheet" href="quize/css/bootstrap.min.css">
<link rel="stylesheet" href="quize/css/animate.css">
<link rel="stylesheet" href="quize/css/owl.carousel.min.css">
<link rel="stylesheet" href="quize/css/themify-icons.css">
<link rel="stylesheet" href="quize/css/flaticon.css">
<link rel="stylesheet" href="quize/css/magnific-popup.css">
<link rel="stylesheet" href="quize/css/slick.css">
<link rel="stylesheet" href="quize/css/style.css">
</head>
<style>
@media only screen and (min-width: 825px) {
#ExtremedemoCARD{
margin-top: -90px !important;
}
#questionTable{
margin-top: -50px !important;
}
}
@media only screen and (max-width: 824px) {
#examMainStart{
margin-top: 90px;
}
#Extremedemo{
font-size: 30px !important;
}
#display{
font-size: 20px !important;
}
#questionTable{
margin-top: -50px !important;
}
}
</style>
<body>
<header class="main_menu home_menu">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-12">
<nav class="navbar navbar-expand-lg navbar-light">
<a class="navbar-brand" href="index.php"> <img src="quize/img/er-1.png" alt="logo" style="width: 188px;"> </a>
<div class="ml-auto" style="border: 2px solid white; border-radius: 10px;"><span id="display" style="color:#FFf;font-size:36px"></span></div>
<div class="ml-auto"><span id="submitted" style="color:#FF0000;font-size:36px"></span></div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse main-menu-item justify-content-end" id="navbarSupportedContent">
<ul class="navbar-nav align-items-center">
<li class="nav-item active">
<a class="nav-link" href="home.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="all-exam-for-student.php">Live Exam</a>
</li>
<li class="nav-item">
<a class="nav-link" href="students-permanent-exam.php">Test Your Skills</a>
</li>
<li class="nav-item">
<a class="nav-link" href="batch.php">Batch</a>
</li>
<li class="d-none d-lg-block nav-item dropdown">
<a class="btn_1 dropdown-toggle" id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="">Profile</a>
<div class="card dropdown-menu" aria-labelledby="navbarDropdown" style="width: 15rem;">
<ul class="list-group list-group-flush">
<li class="list-group-item"><a class="nav-link" href="#"><?php echo $fetch_student['name'];?></a></li>
<li class="list-group-item"><a class="nav-link" href="#">Edit Profile</a></li>
<li class="list-group-item"><a class="nav-link" href="logout.php">Logout</a></li>
</ul>
</div>
</li>
</ul>
</div>
</nav>
</div>
</div>
</div>
</header>
<section class="advance_feature" id="examMainStart">
<div class="container">
<div class="row align-items-sm-center align-items-xl-stretch">
<div class="col-md-6 col-lg-6">
<div class="learning_member_text">
<h5>Exam Name</h5>
<h2><?php echo $exName; ?></h2>
<div class="row">
<div class="col-sm-6 col-md-12 col-lg-6 col-6">
<div class="learning_member_text_iner">
<h5>Time: <?php echo $examTime; ?> min</h5>
</div>
</div>
<div class="col-sm-6 col-md-12 col-lg-6 col-6">
<div class="learning_member_text_iner">
<h5>Mark: <?php echo $total_mark; ?></h5>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-md-12 col-lg-6 col-6">
<div class="learning_member_text_iner">
<h5>Total Ques: <?php echo $maxQuestionNum; ?></h5>
</div>
</div>
<div class="col-sm-6 col-md-12 col-lg-6 col-6">
<div class="learning_member_text_iner">
<h5>Passed Mark: <?php echo $passed_mark; ?></h5>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="learning_img">
<img src="img/advance_feature_img.png" alt="">
</div>
</div>
</div>
</div>
</section>
<!-- Main content -->
<section class="content">
<div class="container-fluid">
<div class="row" id="questionTable">
<div class="col-12">
<div class="card" >
<!-- /.card-header -->
<div class="card-body">
<form method="POST" action="" name="MCQuestion">
<div class="row">
<?php
$Stquery = query("SELECT * FROM students WHERE email = '" . $_SESSION['username'] . "'");
confirm($Stquery);
$row_of_st = fetch_array($Stquery);
$studentID = $row_of_st['id'];
$examID = $_GET['examID'];
//select course
// $select_course=query("SELECT * FROM `course`");
// $fetch_course=fetch_array($select_course);
// $course_id=$fetch_course['id'];
// course select end
// exam start
$query_exam=query("SELECT * FROM `exam` WHERE action='SHOW' AND id='$examID' AND examStatus='Permanent'");
$row_exam=fetch_array($query_exam);
$exam_id=$row_exam['id'];
$exam_status=$row_exam['examStatus'];
$courseID=$row_exam['courseID'];
// exam end
$query_question=query("select * from questions where examID='$exam_id' ");
$rows = mysqli_num_rows($query_question);
if($rows > 0)
{
$i = 0;
while($question_row=fetch_array($query_question))
{
$i +=1;
?>
<div class="col-md-12">
<div class="card shadow p-3 mb-5 bg-white rounded">
<div class="card-header">
<div class="row">
<div class="col-1 col-md-1">
<h4><b><?php echo $question_row['question_number']?></b></h4>
</div>
<div class="col-11 col-md-11">
<h4><b><?php echo $question_row['questionName']?></b></h4>
</div>
</div>
</div>
<div class="card-body">
<input type="hidden" value="<?php echo $i?>" name="count">
<input type="hidden" value="<?php echo $question_row['mark']?>" name="mark[<?php echo $i;?>]">
<input type="hidden" value="<?php echo $question_row['negativeMark']?>" name="negativeMark[<?php echo $i;?>]">
<input type="hidden" value="<?php echo $question_row['rightAns']?>" name="rightAns[<?php echo $i;?>]">
<input type="hidden" value="<?php echo $question_row['id']?>" name="questionID[<?php echo $i;?>]">
<input type="hidden" value=" <?php echo $exam_id?>" name="exam_id[<?php echo $i;?>]">
<input type="hidden" value=" <?php echo $studentID?>" name="studentID[<?php echo $i;?>]">
<input type="hidden" value=" <?php echo $question_row['question_number']?>" name="quesNumber[<?php echo $i;?>]">
<input id="firstOption[<?php echo $i;?>]" type="radio" name="selectedOption[<?php echo $i;?>]" value="1"> <label for="firstOption[<?php echo $i;?>]"><p style="margin-top: 7px; font-size: 18px; text-align:justify; color: #000;"><b style="background-color: #fff; border: 2px solid #512B8B; padding: 6px; color: #000; border-radius: 30%;">A</b> <?php echo $question_row['firstOptn']?></p></label><br/>
<input id="secondOption[<?php echo $i;?>]" type="radio" name="selectedOption[<?php echo $i;?>]" value="2"> <label for="secondOption[<?php echo $i;?>]"><p style="margin-top: 7px; font-size: 18px; text-align:justify; color: #000;"><b style="background-color: #fff; border: 2px solid #512B8B; padding: 6px; color: #000; border-radius: 30%;">B</b> <?php echo $question_row['secondOptn']?></p></label><br/>
<input id="thirdOption[<?php echo $i;?>]" type="radio" name="selectedOption[<?php echo $i;?>]" value="3"> <label for="thirdOption[<?php echo $i;?>]"><p style="margin-top: 7px; font-size: 18px; text-align:justify; color: #000;"><b style="background-color: #fff; border: 2px solid #512B8B; padding: 6px; color: #000; border-radius: 30%;">C</b> <?php echo $question_row['thirdOptn']?></p></label><br/>
<input id="fourthOption[<?php echo $i;?>]" type="radio" name="selectedOption[<?php echo $i;?>]" value="4"> <label for="fourthOption[<?php echo $i;?>]"><p style="margin-top: 7px; font-size: 18px; text-align:justify; color: #000;"><b style="background-color: #fff; border: 2px solid #512B8B; padding: 6px; color: #000; border-radius: 30%;">D</b> <?php echo $question_row['fourthOptn']?></p></label>
</div>
</div>
</div>
<?php
}
}
?>
</div>
</div>
<div class="row">
<div class="col-md-12">
<input type="submit" value="Complete Exam" class="btn btn-success form-control" id="MCQuestion" name="CompleteExam">
</div>
<!-- /.card-body -->
</div>
</form>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div>
<!-- /.container-fluid -->
</section>
<!-- /.content -->
</div>
<?php
?>
<!--FOOTER START HERE-->
<footer class="footer-area">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="copyright_part_text text-center">
<div class="row">
<div class="col-lg-12">
<p class="footer-text m-0">
Copyright ©<script data-cfasync="false" src="../../cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script>document.write(new Date().getFullYear());</script> This Software made with <i class="ti-heart" aria-hidden="true"></i> by <a href="https://faraitfusion.com/" target="_blank">FARA IT Fusion</a>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</footer>
<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<script>
$(function () {
$("#example1").DataTable({
"responsive": true,
"autoWidth": false,
});
$('#example2').DataTable({
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false,
"responsive": true,
});
});
</script>
<?php
$examID = $_GET['examID'];
$query = query("SELECT * FROM `exam` WHERE id='$examID'");
confirm($query);
$row = fetch_array($query);
$time = $row['examTime'];
$updateTime = $time*60;
?>
<script>
var div = document.getElementById('display');
var submitted = document.getElementById('submitted');
function CountDown(duration, display) {
var timer = duration, minutes, seconds;
var interVal= setInterval(function () {
minutes = parseInt(timer / 60, 10);
seconds = parseInt(timer % 60, 10);
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.innerHTML ="<b>" + minutes + "m : " + seconds + "s" + "</b>";
if (timer > 0) {
--timer;
}else{
clearInterval(interVal)
SubmitFunction();
}
},1000);
}
function SubmitFunction(){
submitted.innerHTML="Time is up!";
document.getElementById('MCQuestion').click();
}
CountDown(<?php echo $updateTime; ?>,div);
</script>
</body>
</html>
<?php
if(isset($_POST['CompleteExam'])){
$count = $_POST['count']+1;
$exam_id = $_POST['exam_id'];
$studentID = $_POST['studentID'];
$quesNumber = $_POST['quesNumber'];
$questionID = $_POST['questionID'];
$selectedOption = $_POST['selectedOption'];
$QuesMark = $_POST['mark'];
$negativeMark = $_POST['negativeMark'];
$rightAns = $_POST['rightAns'];
for($i=1; $i < $count; $i++){
$resultInsertQuery = query("INSERT INTO resultForPermanentExam(examID, studentID, questionID, selectedAns, questionNum, mark, negativeMark, rightAns) VALUES('$exam_id[$i]', '$studentID[$i]', '$questionID[$i]', '$selectedOption[$i]', '$quesNumber[$i]', '$QuesMark[$i]', '$negativeMark[$i]', '$rightAns[$i]')");
confirm($resultInsertQuery);
if($resultInsertQuery){
set_message('<h2 class="m-0 text-dark bg-success text-center" style="padding: 10px; border-radius: 20px;">Welcome, Your Exam is Complete</h2>');
redirect("result.php?examID=$exam_id[$i]");
}
}
}
?>