diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml index 0d9afcc..b631df8 100644 --- a/.idea/material_theme_project_new.xml +++ b/.idea/material_theme_project_new.xml @@ -3,7 +3,9 @@ - + + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 882bd96..d977ec5 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,19 +5,12 @@ - + + - - - - - - - - - - + + @@ -82,23 +75,23 @@ - { + "keyToString": { + "RunOnceActivity.ShowReadmeOnStart": "true", + "git-widget-placeholder": "master", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "vue.rearranger.settings.migration": "true" }, - "keyToStringList": { - "DatabaseDriversLRU": [ - "postgresql" + "keyToStringList": { + "DatabaseDriversLRU": [ + "postgresql" ] } -}]]> +} @@ -121,7 +114,7 @@ 1730794293135 - + diff --git a/index.php b/index.php index bebf483..400e2ef 100644 --- a/index.php +++ b/index.php @@ -19,11 +19,10 @@ $twig = new \Twig\Environment($loader, [ 'cache' => 'cache', ]); +$num = 0; + $cont = new Controleur\FrontControler($co); -session_unset(); -session_destroy(); -$_SESSION = array(); ?> \ No newline at end of file diff --git a/src/Controleur/QuizController.php b/src/Controleur/QuizController.php index 3b81996..65fe758 100644 --- a/src/Controleur/QuizController.php +++ b/src/Controleur/QuizController.php @@ -1,5 +1,6 @@ co = $co; $this -> gw = new QuestionGateway($this->co); $this -> mdl = new QuestionModel($this->gw); - - $loader = new FilesystemLoader('vue/templates'); + global $num; + global $loader; $action = $_REQUEST['action'] ?? null; @@ -46,13 +48,12 @@ class QuizController switch ($action) { case 'canswer': - if ($this->CorrectAnswer()) echo "Bonne réponse"; else echo "Mauvaise réponse"; - $this->no_question ++; - echo $this->no_question; - $this->showQuestion($id, $this->no_question); + $_SESSION['no_question'] = isset($_SESSION['no_question']) ? ($_SESSION['no_question'] + 1) : 1; + + header("Location: http://localhost:8000/quiz/$id"); break; default: switch($id) @@ -61,7 +62,7 @@ class QuizController // page erreur break; default: - $this->showQuestion($id, $this->no_question); + $this->showQuestion($id, $_SESSION['no_question'] ?? 0); break; } } @@ -103,42 +104,36 @@ class QuizController return $mdl->getAllQuestionByQuiz($id, $this->co); } + public function RunQuiz(int $idQuiz) + { + + } + /** * @throws RuntimeError * @throws SyntaxError * @throws LoaderError */ - public function showQuestion(int $id, int $no) : void + public function showQuestion(int $id, int $num) : void { global $twig; + echo $num; $q = $this->GetQuestion($id); - $question = $q[$no]; - + $question = $q[$num]; $idquestion = $question->getIdQuestion(); echo $twig->render('quiz.html.twig', ['question' => $question,'id'=>$idquestion]); - } - - public function getNumberOfQuestion() : int - { - $gw = new QuizGateway($this->co); - $mdl = new QuizModel($gw); - return 0; + //else + //page resultat } -} - -/* -getUrl() ?>> = $new->getTitle() ?> + $gw = new QuizGateway($this->co); + $mdl = new QuizModel($gw); + return $mdl->getQuiz($id)->getNbQuestions(); } -?> - - -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/src/Model/QuizModel.php b/src/Model/QuizModel.php index 728d516..155a512 100644 --- a/src/Model/QuizModel.php +++ b/src/Model/QuizModel.php @@ -24,8 +24,8 @@ class QuizModel { $q = $this -> gateway -> findQuizById($id_quiz); if ($q) { return new quizEntity( - $q['id_quiz'], - $q['nb_questions'], + $q[0]['id_quiz'], + $q[0]['nb_quest'] ); } return null; diff --git a/vue/templates/quiz.html.twig b/vue/templates/quiz.html.twig index f78dd54..b53270d 100644 --- a/vue/templates/quiz.html.twig +++ b/vue/templates/quiz.html.twig @@ -9,7 +9,7 @@ - - - - - - - - - - - - - - + {{ include "bandeau.html.twig" }} ▶ Quiz ◀ {{ question.question }} - 300 seconds left .. + 10 seconds left .. @@ -59,7 +46,7 @@ {{ question.answerd }} - +