-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
113 lines (99 loc) · 3.87 KB
/
test.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
<?php
session_start();
$_SESSION['reponses'] = [];
include("fonctions-questions.php");
include_once("questions.php");
$urlResultats = "Location:reponses-test.php";
$_SESSION['resultatsEnvoyes'] = false;
$dureeMinutesTest = 30;
$title = "Test";
$message_bienvenue = "<p>Bienvenue dans ce test.</p><p>Vous avez ".$dureeMinutesTest." minutes pour répondre aux 20 questions.</p><p>Aidez-vous du minuteur en bas de l'écran.</p><p>Bon courage !</p>";
$titre_header = "Test";
$message_bouton_valider = "Terminé !";
$message_chrono = "Temps restant :";
if(isset($_POST["submit"])) {
for($i = 0; $i < $_SESSION['nbQuestions']; $i++) {
array_push($_SESSION['reponses'], $_POST[strval($i)]);
}
// Redirection vers les réponses en fin de test
header($urlResultats);
exit;
}
?>
<!-- Contient tout le code HTML des pages de questions -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><?php echo $title ?></title>
<link type="text/css" rel="stylesheet" href="test.css"/>
<link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700">
<meta name="viewport" content="width=device-width" />
</head>
<!-- Pour le suivi Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-5338598-54', 'auto');
ga('send', 'pageview');
</script>
<body onload='loader()';>
<div id='loader' style='font-family: Arial'><?php echo $message_bienvenue ?>
<div id='loader-circle'></div>
</div>
<div id='test' style="display:none">
<div id="wrapper">
<div id="header">
<h1><?php echo $titre_header ?></h1>
</div>
<div id="main_content">
<form method="post">
<?php
// On affiche toutes les questions en mode "test", avec les cases à cocher (le paramètre 'solution' est à false)
for($i = 0; $i < $_SESSION['nbQuestions']; $i++){
echo ${"q".$i}->afficherQuestion(false, 1);
}
?>
<div><input type="submit" name="submit" value="<?php echo $message_bouton_valider ?>" id="submit"></div>
<br>
</form>
</div>
</div>
<div id="chrono">
<img src="chrono.png" style="max-width:20px; max-height:20px; margin-bottom:-2px;"> <?php echo $message_chrono ?>
<span id="minutes"><?php echo $dureeMinutesTest; ?></span> min <span id="secondes">1</span> sec
</div>
</div>
</body>
</html>
<?php
$message_temps_ecoule = "Temps écoulé !";
?>
<!-- Script du petit timer en bas de l'écran -->
<script type="text/javascript">
var attente;
function minutageGo(){
var secondes = window.document.getElementById("secondes").innerHTML;
secondes = parseInt(secondes) - 1;
window.document.getElementById("secondes").innerHTML = secondes;
attente = setTimeout("minutageGo()", 1000);
if(window.document.getElementById("secondes").innerHTML < 0){
window.document.getElementById("minutes").innerHTML = parseInt(window.document.getElementById("minutes").innerHTML) - 1;
window.document.getElementById("secondes").innerHTML = 59;
}
if(window.document.getElementById("minutes").innerHTML == 0 && window.document.getElementById("secondes").innerHTML == 0){
window.document.getElementById("chrono").innerHTML = "<span><strong><?php echo $message_temps_ecoule; ?></strong></span>";
clearTimeout(attente);
}
}
var consigne;
function loader() {
consigne = setTimeout(showPage, 1000);
}
function showPage() {
document.getElementById('loader').style.display = 'none';
document.getElementById('test').style.display = 'block';
minutageGo();
}
</script>