forked from bdobry/hackathon2016
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquiz.php
More file actions
105 lines (74 loc) · 2.21 KB
/
quiz.php
File metadata and controls
105 lines (74 loc) · 2.21 KB
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
<?php
echo file_get_contents("head.php");
?>
<?php
echo file_get_contents("header.php");
?>
<?php include "db_conn.php"; ?>
<div class="container">
<!-- Jumbotron Header -->
<header class="jumbotron fp-jt">
<h1>PHP Quiz</h1>
<div class="col-sm-6 col-md-6 text-right">
<div class="btn-group inline" role="group">
<a href="manage.php" class="btn btn-primary">Edit quiz</a>
<a href="mainquiz.php" class="btn btn-danger">Go back</a>
</div>
</div>
</header>
<hr>
<!--Quiz -->
<div class="row">
<div class="col-lg-12">
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$rightAnswer = 0;
$wrongAnswer = 0;
require_once('functions.php');
require_once('setting.php');
if (isset($_POST['submit'])){
foreach($_POST['response'] as $key => $value){
if($correctAnswerArray[$key] == $value){
$rightAnswer++;
} else {
$wrongAnswer++;
}
}
}
?>
<!--Display form-->
<form action="result.php" method="post">
<?php
foreach($questions as $id => $question) {
echo "<div class=\"form-group\">";
echo "<h3> $question</h3>"."<ul class='radio radio-primary'>";//display the question
//Display multiple choices
$randomChoices = $choices[$id];
$randomChoices = shuffle_assoc($randomChoices);
foreach ($randomChoices as $key => $values){
echo '<li><input id="radio" type="radio" name="response['.$id.'] id="'.$id.'" value="' .$values.'"/>';
?>
<label for="question-<?php echo($id); ?>"><?php echo($values);?></label></li>
<?php
}
echo("</ul>");
}
?>
<input type="submit" name="submit" class="btn btn-primary" value="Submit Quiz" />
</form>
</div>
</div>
</div>
<!-- /.row -->
<!-- Quiz-->
<!-- /.row -->
<hr>
</div>
<!-- Footer -->
<?php
echo file_get_contents("pagefooter.php");
?>
<?php
echo file_get_contents("footer.php");
?>