-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresultat.php
More file actions
90 lines (55 loc) · 1.75 KB
/
resultat.php
File metadata and controls
90 lines (55 loc) · 1.75 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
<?php require __DIR__ . '/data.php'; ?>
<?php require __DIR__ . '/functions.php'; ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Ditt resultat</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="page-wrap">
<h1>resultat</h1>
<?php
// load answers from questions.php into indexed array $answer[]
for ($i = 1; $i < 7; $i++) {
$answer[$i] = $_POST["question-$i-answers"];
}
// echo $answer[]
// for ($k = 1; $k < 7; $k++) {
// echo $answer[$k];
// }
// bulid $correctI[] array
for ($j = 1; $j < 7; $j++) {
if ($answer[$j] == $correctAnswer[($j - 1)]) {
$totalCorrect++;
$correctI[$j] = true;
}
}
// main feedback loop
for ($k = 1; $k < 7; $k++) {
if ($correctI[$k] == true) {
echo "<br>Du svarade RÄTT på fråga nummer $k:<br>";
echo $feedback[($k - 1)]['right'];
echo "<br>";
} else {
echo "<br>Du svarade FEL på fråga nummer $k:<br>";
echo $feedback[($k - 1)]['wrong'];
echo "<br>";
}
}
// PRINT TOTAL CORRECT ANSWERS
echo "<br>";
echo "<br>";
echo "<div id='results'>$totalCorrect poäng av 6 möjliga</div>";
echo "<br>";
$procent = percentage($totalCorrect, 6);
echo "Det innebär procentuellt: $procent %";
echo "<br>";
echo "<br>Dagens matte citat =<br>";
$randIndex = getRandomIndex($mathQuotes);
echo $mathQuotes[$randIndex];
?>
</div>
</body>
</html>