diff --git a/Project/php/assets/img/fond_quiz.jpg b/Project/php/assets/img/fond_quiz.jpg new file mode 100755 index 0000000..790c7ba Binary files /dev/null and b/Project/php/assets/img/fond_quiz.jpg differ diff --git a/Project/php/assets/img/night_new_york.jpg b/Project/php/assets/img/night_new_york.jpg new file mode 100755 index 0000000..e893257 Binary files /dev/null and b/Project/php/assets/img/night_new_york.jpg differ diff --git a/Project/php/assets/img/nnyc.jpeg b/Project/php/assets/img/nnyc.jpeg new file mode 100755 index 0000000..0b5dbcd Binary files /dev/null and b/Project/php/assets/img/nnyc.jpeg differ diff --git a/Project/php/assets/img/quiz2.jpg b/Project/php/assets/img/quiz2.jpg new file mode 100755 index 0000000..8aa2d9c Binary files /dev/null and b/Project/php/assets/img/quiz2.jpg differ diff --git a/Project/php/controller/StudentController.php b/Project/php/controller/StudentController.php index 2b5697a..a8eed32 100755 --- a/Project/php/controller/StudentController.php +++ b/Project/php/controller/StudentController.php @@ -36,12 +36,13 @@ class StudentController extends UserController echo $twig->render('manageVocabView.html', ['vocabularies' => $vocab]); } - public function memoryChoice(): void { + public function ListVocChoice(): void { global $twig; global $user; + $jeu = $_POST['jeu']; $model = new MdlStudent(); $voc = $model->getAll(); - echo $twig->render('vocabList.html', ['vocabularies' => $voc, 'userID' => $user->getId(), 'userRole' => $user->getRoles()]); + echo $twig->render('vocabList.html', ['jeu' => $jeu, 'vocabularies' => $voc, 'userID' => $user->getId(), 'userRole' => $user->getRoles()]); } public function gameChoice(): void { diff --git a/Project/php/controller/VisitorController.php b/Project/php/controller/VisitorController.php index 4df381a..8f155a3 100755 --- a/Project/php/controller/VisitorController.php +++ b/Project/php/controller/VisitorController.php @@ -12,6 +12,7 @@ class VisitorController { public function memory($match): void{ global $twig; + global $user; try{ $idVoc = Validation::filter_int($_POST['idVoc'] ?? 4); @@ -19,6 +20,7 @@ class VisitorController $name = ((new \gateway\VocabularyListGateway())->findById($idVoc))->getName(); $wordShuffle = array(); + shuffle($wordList); $pairs = []; $maxWords = 28; @@ -33,11 +35,22 @@ class VisitorController shuffle($wordShuffle); - echo $twig->render('memory.html', [ - 'wordShuffle' => $wordShuffle, - 'pairs' => json_encode($pairs), - 'name' => $name - ]); + if(isset($user)) { + echo $twig->render('memory.html', [ + 'wordShuffle' => $wordShuffle, + 'pairs' => json_encode($pairs), + 'name' => $name, + 'userID' => $user->getID(), + 'userRole' => $user->getRoles() + ]); + } + else{ + echo $twig->render('memory.html', [ + 'wordShuffle' => $wordShuffle, + 'pairs' => json_encode($pairs), + 'name' => $name + ]); + } } catch (Exception $e){ @@ -47,40 +60,60 @@ class VisitorController public function quiz($match): void { global $twig; - $vocabId = Validation::filter_int($_POST['idVoc'] ?? 4); - $vocabList = (new VocabularyListGateway())->findById($vocabId) ?? null; - if ($vocabList == null) throw new Exception("liste inconnue"); - $mdl = new TranslationGateway(); - $allTranslation = $mdl->findByIdVoc($vocabId); - $shuffle = $allTranslation; - shuffle($shuffle); - - $questions = array(); - $goodAnswers = array(); - $allEnglishWords = array(); - - foreach ($allTranslation as $translation) { - $questions[] = $translation->getWord1(); - $allEnglishWords[] = $translation->getWord2(); - $goodAnswers[] = $translation->getWord2(); - } + global $user; + try { + $vocabId = Validation::filter_int($_POST['idVoc'] ?? 4); + $vocabList = (new VocabularyListGateway())->findById($vocabId) ?? null; + if ($vocabList == null) throw new Exception("liste inconnue"); + $mdl = new TranslationGateway(); + $allTranslation = $mdl->findByIdVoc($vocabId); + $shuffle = $allTranslation; + shuffle($shuffle); + + $questions = array(); + $goodAnswers = array(); + $allEnglishWords = array(); + + foreach ($allTranslation as $translation) { + $questions[] = $translation->getWord1(); + $allEnglishWords[] = $translation->getWord2(); + $goodAnswers[] = $translation->getWord2(); + } - $answers = array(); + $answers = array(); - for($i=0 ; $i< count($questions) ; $i++) { - $correctAnswer = $allTranslation[$i]->getWord2(); - array_splice($allEnglishWords, array_search($correctAnswer, $allEnglishWords), 1); + for ($i = 0; $i < count($questions); $i++) { + $correctAnswer = $allTranslation[$i]->getWord2(); + array_splice($allEnglishWords, array_search($correctAnswer, $allEnglishWords), 1); - $tab = array_rand(array_flip($allEnglishWords), 3); + $tab = array_rand(array_flip($allEnglishWords), 3); - array_push($allEnglishWords, $correctAnswer); + array_push($allEnglishWords, $correctAnswer); - $tab[] = $correctAnswer; - shuffle($tab); - $answers[] = $tab; - } + $tab[] = $correctAnswer; + shuffle($tab); + $answers[] = $tab; + } - echo $twig->render('quizView.html', ['questions' => $questions, 'answers' => $answers, 'goodAnswers' => $goodAnswers, 'listName' => $vocabList->getName()]); + if (isset($user)) { + echo $twig->render('quizView.html', [ + 'questions' => $questions, + 'answers' => $answers, + 'goodAnswers' => $goodAnswers, + 'listName' => $vocabList->getName(), + 'userID' => $user->getID(), + 'userRole' => $user->getRoles()]); + } else { + echo $twig->render('quizView.html', [ + 'questions' => $questions, + 'answers' => $answers, + 'goodAnswers' => $goodAnswers, + 'listName' => $vocabList->getName()]); + } + } + catch (Exception $e){ + throw new Exception("Erreur"); + } } public function login(): void { diff --git a/Project/php/css/memory.css b/Project/php/css/memory.css index 2fbef9a..927d502 100755 --- a/Project/php/css/memory.css +++ b/Project/php/css/memory.css @@ -21,6 +21,8 @@ h1{ gap: 10px; margin: auto; perspective: 1000px; + min-width: 70vw; + max-height: 70vh; } .card { diff --git a/Project/php/css/styles.css b/Project/php/css/styles.css index abaed08..5a9b4c2 100755 --- a/Project/php/css/styles.css +++ b/Project/php/css/styles.css @@ -11338,6 +11338,7 @@ body { background-image: url("../assets/img/portrait_black.png"); } + .device[data-device=iPhoneX][data-orientation=portrait][data-color=black] .button { display: none; top: 0%; diff --git a/Project/php/js/memory.js b/Project/php/js/memory.js index 7f5112d..aa7e0e6 100755 --- a/Project/php/js/memory.js +++ b/Project/php/js/memory.js @@ -4,7 +4,7 @@ document.addEventListener('DOMContentLoaded', function () { var word1; var word2; var clickEnabled = true; - var score = 25; + var score = 500; cards.forEach(function (card) { card.addEventListener('click', function () { @@ -12,7 +12,6 @@ document.addEventListener('DOMContentLoaded', function () { return; } card.classList.toggle('flipped'); - nbCard += 1; if (nbCard === 1) { word1 = card.dataset.word; @@ -67,12 +66,11 @@ document.addEventListener('DOMContentLoaded', function () { (pair[0] === word1 && pair[1] === word2) || (pair[0] === word2 && pair[1] === word1) ) { - score+=10; return true; } } if(score !== 0){ - score-=1; + score-=5; } return false; } diff --git a/Project/php/templates/erreur.html b/Project/php/templates/erreur.html index f1a0af8..a3f9ccf 100755 --- a/Project/php/templates/erreur.html +++ b/Project/php/templates/erreur.html @@ -5,14 +5,62 @@
{{value}}
{% endfor %} {% endif %} +