Implementation de la demo + liens entre les pages

php
Lucie GOIGOUX 1 year ago
parent 2960fae3a7
commit 1e172fa9ba

@ -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);

@ -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]);
}
}

@ -11342,4 +11342,8 @@ body {
.content{
padding : 12vh;
}
.click-game{
text-decoration: none;
}

@ -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();
}
}
});

@ -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 () {

@ -54,33 +54,37 @@
<section class="projects-section">
<div class="container px-4 px-lg-5" id="game">
<!-- Game One Row-->
<div class="row gx-0 mb-5 mb-lg-0 justify-content-center">
<div class="col-lg-6"><img class="img-fluid" src="{{base}}/assets/img/quizz.jpeg" alt="..." /></div>
<div class="col-lg-6">
<div class="bg-black text-center h-100 project">
<div class="d-flex h-100">
<div class="project-text w-100 my-auto text-center text-lg-left">
<h4 class="text-white">Quiz</h4>
<p class="mb-0 text-white-50">Test your knowledge and study smarter!</p>
<a class="click-game" href="{{base}}/visitor/quiz">
<div class="row gx-0 mb-5 mb-lg-0 justify-content-center">
<div class="col-lg-6"><img class="img-fluid" src="{{base}}/assets/img/quizz.jpeg" alt="..." /></div>
<div class="col-lg-6">
<div class="bg-black text-center h-100 project">
<div class="d-flex h-100">
<div class="project-text w-100 my-auto text-center text-lg-left">
<h4 class="text-white">Quiz</h4>
<p class="mb-0 text-white-50">Test your knowledge and study smarter!</p>
</div>
</div>
</div>
</div>
</div>
</div>
</a>
<!-- Game Two Row-->
<div class="row gx-0 justify-content-center">
<div class="col-lg-6"><img class="img-fluid" src="{{base}}/assets/img/memory.jpeg" alt="..." /></div>
<div class="col-lg-6 order-lg-first">
<div class="bg-black text-center h-100 project">
<div class="d-flex h-100">
<div class="project-text w-100 my-auto text-center text-lg-right">
<h4 class="text-white">Memory</h4>
<p class="mb-0 text-white-50">Have fun associating words to help your brain learn faster</p>
<a class="click-game" href="{{base}}/visitor/memory">
<div class="row gx-0 justify-content-center">
<div class="col-lg-6"><img class="img-fluid" src="{{base}}/assets/img/memory.jpeg" alt="..." /></div>
<div class="col-lg-6 order-lg-first">
<div class="bg-black text-center h-100 project">
<div class="d-flex h-100">
<div class="project-text w-100 my-auto text-center text-lg-right">
<h4 class="text-white">Memory</h4>
<p class="mb-0 text-white-50">Have fun associating words to help your brain learn faster</p>
</div>
</div>
</div>
</div>
</div>
</div>
</a>
<div class="row gx-5 align-items-center" id="download">
<div class="col-lg-6">

@ -1,6 +1,6 @@
<nav class="navbar navbar-expand-lg navbar-light fixed-top" id="secondNav">
<div class="container px-4 px-lg-5">
<a class="navbar-brand" href="{{base}}"><img class="logo" src="{{base}}/assets/img/logo.png"/></a>
<a class="navbar-brand" href="{{base}}/#page-top"><img class="logo" src="{{base}}/assets/img/logo.png"/></a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false"
aria-label="Toggle navigation">
@ -27,9 +27,9 @@
<li class="nav-item"><a class="nav-link" href="{{ base }}/teacher/{{ userID }}/showAccountInfos">My account</a></li>
{% endif %}
{% if userRole is empty %}
<li class="nav-item"><a class="nav-link" href="#game">Game</a></li>
<li class="nav-item"><a class="nav-link" href="#download">Download</a></li>
<li class="nav-item"><a class="nav-link" href="{{base}}/visitor/login">Login</a></li>
<li class="nav-item"><a class="nav-link" href="{{ base }}#game">Game</a></li>
<li class="nav-item"><a class="nav-link" href="{{ base }}#download">Download</a></li>
<li class="nav-item"><a class="nav-link" href="{{ base }}/visitor/login">Login</a></li>
{% else %}
<li class="nav-item"><a class="nav-link" href="{{ base }}/visitor/disconnect">Log out</a></li>
{% endif %}

Loading…
Cancel
Save