-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquiz_submitted.php
101 lines (85 loc) · 3.66 KB
/
quiz_submitted.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
<?php
if(isset($_POST['submit']))
{
session_start();
$no_of_questions = 20;
$registration_number = '19BCE1672';
$reg = $registration_number[strlen($registration_number)-1];
$mul_fact = pow(7,$reg%10);
// for($x=1;$x<=$no_of_questions;$x++){
// echo "Question number : ".((((($mul_fact*$x+$reg)%$no_of_questions))%$no_of_questions+1))."<br>";
// }
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "english";
//create connection
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
//connect to the server and select database
mysqli_connect("localhost","root","");
mysqli_select_db($conn,"submit");
$total_marks = 0;
$marks_scored = 0;
//Query the database for user
for($x=1;$x<=$no_of_questions;$x++){
$total_marks++;
$question = ((((($mul_fact*$x+$reg)%$no_of_questions))%$no_of_questions+1));
$result = mysqli_query($conn,"select * from q_bank where
id ='$question'")
or die("Failed to query database ".mysqli_error($conn));
$row = mysqli_fetch_array($result);
if($_POST['option'.$x]==$row['answer'])
{
$marks_scored++;
}
}
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha2/css/bootstrap.min.css" integrity="sha384-DhY6onE6f3zzKbjUPRc2hOzGAdEf4/Dz+WJwBvEYL/lkkIsI3ihufq9hk9K4lVoK" crossorigin="anonymous">
<link rel = "icon" href = "img/examon.png" type = "image/x-icon">
<title>ExamOn</title>
<style>
body{
overflow: hidden;
}
.container{
height: 100vh;
}
</style>
</head>
<body class="bg-dark bg-gradient">
<div class="container d-flex bg-white bg-gradient justify-content-center align-items-center">
<div class="row">
<div class="col-12 m-5 h1 text-success d-flex justify-content-center align-items-center">
Quiz Successfully Submitted!!
</div>
<div class="col-12 bg-success text-white h2 d-flex justify-content-center align-items-center">
Your Score: <?php echo $marks_scored.'/'.$total_marks;?>
</div>
</div>
</div>
<!-- Optional JavaScript; choose one of the two! -->
<!-- Option 1: Bootstrap Bundle with Popper.js -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha2/js/bootstrap.bundle.min.js" integrity="sha384-BOsAfwzjNJHrJ8cZidOg56tcQWfp6y72vEJ8xQ9w6Quywb24iOsW913URv1IS4GD" crossorigin="anonymous"></script>
<!-- Option 2: Separate Popper.js and Bootstrap JS
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha2/js/bootstrap.min.js" integrity="sha384-5h4UG+6GOuV9qXh6HqOLwZMY4mnLPraeTrjT5v07o347pj6IkfuoASuGBhfDsp3d" crossorigin="anonymous"></script>
-->
</body>
</html>
<?php
}
else{
echo 'Attempt not counted';
}
?>
<script>
setTimeout(function(){window.history.go(-3);
}, 3000);
</script>