-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.php
127 lines (107 loc) · 3.49 KB
/
check.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
<?php
session_start();
$con = mysqli_connect('localhost','root');
mysqli_select_db($con,'quizdbase');
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<style type="text/css">
.animateuse{
animation: leelaanimate 0.5s infinite;
}
@keyframes leelaanimate{
0% { color: red },
10% { color: yellow },
20%{ color: blue }
40% {color: green },
50% { color: pink }
60% { color: orange },
80% { color: black },
100% { color: brown }
}
</style>
</head>
<body>
<div class="container text-center" >
<br><br>
<h1 class="text-center text-success text-uppercase animateuse" > ThapaTechnical Quiz </h1>
<br><br><br><br>
<table class="table text-center table-bordered table-hover">
<tr>
<th colspan="2" class="bg-dark"> <h1 class="text-white"> Results </h1></th>
</tr>
<tr>
<td>
Questions Attempted
</td>
<?php
// $counter = 0;
$Resultans = 0;
if(isset($_POST['submit'])){
if(!empty($_POST['quizcheck'])) {
// Counting number of checked checkboxes.
$checked_count = count($_POST['quizcheck']);
// print_r($_POST);
?>
<td>
<?php
echo "Out of 5, You have attempt ".$checked_count." option."; ?>
</td>
<?php
// Loop to store and display values of individual checked checkbox.
$selected = $_POST['quizcheck'];
$q1= " select * from questions ";
$ansresults = mysqli_query($con,$q1);
$i = 1;
while($rows = mysqli_fetch_array($ansresults)) {
$flag = $rows['ans_id'] == $selected[$i];
if($flag){
// echo "correct ans is ".$rows['ans']."<br>";
// $counter++;
$Resultans++;
// echo "Well Done! your ". $counter ." answer is correct <br><br>";
}else{
// $counter++;
// echo "Sorry! your ". $counter ." answer is innncorrect <br><br>";
}
$i++;
}
?>
<tr>
<td>
Your Total score
</td>
<td colspan="2">
<?php
echo " Your score is ". $Resultans.".";
}
else{
echo "<b>Please Select Atleast One Option.</b>";
}
}
?>
</td>
</tr>
<?php
$name = $_SESSION['username'];
$finalresult = " insert into usersession(username,u_q_id, u_a_id) values ('$name','5','$Resultans') ";
$queryresult= mysqli_query($con,$finalresult);
// if($queryresult){
// echo "successssss";
// }
?>
</table>
<a href="logout.php" class="btn btn-success"> LOGOUT </a>
</div>
</body>
</html>