From 1e172fa9badc9fbe6746081d258b72b3332998fa Mon Sep 17 00:00:00 2001 From: "lucie.goigoux2" Date: Tue, 21 Nov 2023 13:36:45 +0100 Subject: [PATCH] Implementation de la demo + liens entre les pages --- Project/php/controller/FrontController.php | 2 +- Project/php/controller/VisitorController.php | 6 +-- Project/php/css/styles.css | 4 ++ Project/php/js/memory.js | 15 +++++++- Project/php/js/quiz.js | 17 ++++++++- Project/php/templates/home.html | 40 +++++++++++--------- Project/php/templates/navBar.twig | 8 ++-- 7 files changed, 64 insertions(+), 28 deletions(-) diff --git a/Project/php/controller/FrontController.php b/Project/php/controller/FrontController.php index 863ca81..bb203c7 100755 --- a/Project/php/controller/FrontController.php +++ b/Project/php/controller/FrontController.php @@ -23,7 +23,7 @@ class FrontController $router->map('GET|POST', '/admin/[i:id]/[a:action]?', 'Admin'); $router->map('GET|POST', '/teacher/[i:id]/[a:action]?', 'Teacher'); $router->map('GET|POST', '/student/[i:id]/[a:action]?', 'Student'); - $router->map('GET|POST', '/visitor/[a:action]/[i:id]?', 'Visitor'); + $router->map('GET|POST', '/visitor/[a:action]', 'Visitor'); $twig->addGlobal('base', $altorouterPath); diff --git a/Project/php/controller/VisitorController.php b/Project/php/controller/VisitorController.php index 61f42a5..9c78ebe 100755 --- a/Project/php/controller/VisitorController.php +++ b/Project/php/controller/VisitorController.php @@ -14,7 +14,7 @@ class VisitorController global $twig; try{ - $idVoc = Validation::filter_int($match['id'] ?? null); + $idVoc = Validation::filter_int($_POST['idVoc'] ?? 2); $wordList = (new \gateway\TranslationGateway())->findByIdVoc($idVoc); $name = ((new \gateway\VocabularyListGateway())->findById($idVoc))->getName(); $wordShuffle = array(); @@ -47,7 +47,7 @@ class VisitorController public function quiz($match): void { global $twig; - $vocabId = Validation::filter_int($match['id'] ?? null); + $vocabId = Validation::filter_int($_POST['idVoc'] ?? 4); $vocabList = (new VocabularyListGateway())->findById($vocabId) ?? null; if ($vocabList == null) throw new Exception("liste inconnue"); $mdl = new TranslationGateway(); @@ -115,7 +115,7 @@ class VisitorController public function resultatsJeux($match): void{ global $twig; - $score = Validation::filter_int($match['id']); + $score = $_POST['score']; echo $twig->render('resultatsJeux.html', ['points' => $score]); } } \ No newline at end of file diff --git a/Project/php/css/styles.css b/Project/php/css/styles.css index dc9fd35..635c9f2 100755 --- a/Project/php/css/styles.css +++ b/Project/php/css/styles.css @@ -11342,4 +11342,8 @@ body { .content{ padding : 12vh; +} + +.click-game{ + text-decoration: none; } \ No newline at end of file diff --git a/Project/php/js/memory.js b/Project/php/js/memory.js index 1a9ccf3..7f5112d 100755 --- a/Project/php/js/memory.js +++ b/Project/php/js/memory.js @@ -79,7 +79,20 @@ document.addEventListener('DOMContentLoaded', function () { function checkGameCompletion(){ if (document.querySelectorAll('.card.found').length === cards.length) { - window.location.href = '../resultatsJeux/' + score; + window.location.href = 'resultatsJeux'; + var form = document.createElement('form'); + form.method = 'post'; + form.action = 'resultatsJeux'; + + var input = document.createElement('input'); + input.type = 'hidden'; + input.name = 'score'; + input.value = score; + + form.appendChild(input); + document.body.appendChild(form); + + form.submit(); } } }); \ No newline at end of file diff --git a/Project/php/js/quiz.js b/Project/php/js/quiz.js index d6e2848..fff42a1 100755 --- a/Project/php/js/quiz.js +++ b/Project/php/js/quiz.js @@ -17,7 +17,22 @@ function nextQuestion() { var nextQuestionDiv = document.getElementById("question" + currentQuestion); nextQuestionDiv.style.display = "block"; } - else alert("Quiz terminé. Votre score est de " + score + "/" + len); + else{ + window.location.href = 'resultatsJeux'; + var form = document.createElement('form'); + form.method = 'post'; + form.action = 'resultatsJeux'; + + var input = document.createElement('input'); + input.type = 'hidden'; + input.name = 'score'; + input.value = score + '/20'; + + form.appendChild(input); + document.body.appendChild(form); + + form.submit(); + } } window.onload = function () { diff --git a/Project/php/templates/home.html b/Project/php/templates/home.html index 38284a5..1e00cc7 100755 --- a/Project/php/templates/home.html +++ b/Project/php/templates/home.html @@ -54,33 +54,37 @@
-
-
...
-
-
-
-
-

Quiz

-

Test your knowledge and study smarter!

+ +
+
...
+
+
+
+
+

Quiz

+

Test your knowledge and study smarter!

+
-
+ -
-
...
-
-
-
-
-

Memory

-

Have fun associating words to help your brain learn faster

+ +
+
...
+
+
+
+
+

Memory

+

Have fun associating words to help your brain learn faster

+
-
+
diff --git a/Project/php/templates/navBar.twig b/Project/php/templates/navBar.twig index 73a12af..8e6b6c7 100755 --- a/Project/php/templates/navBar.twig +++ b/Project/php/templates/navBar.twig @@ -1,6 +1,6 @@