+
";
+ // line 44
+ yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, ($context["question"] ?? null), "question", [], "any", false, false, false, 44), "html", null, true);
+ yield "
+
300 seconds left ..
+
+
+
+
+
+";
+ yield from [];
+ }
+
+ /**
+ * @codeCoverageIgnore
+ */
+ public function getTemplateName(): string
+ {
+ return "quiz.html.twig";
+ }
+
+ /**
+ * @codeCoverageIgnore
+ */
+ public function isTraitable(): bool
+ {
+ return false;
+ }
+
+ /**
+ * @codeCoverageIgnore
+ */
+ public function getDebugInfo(): array
+ {
+ return array ( 126 => 59, 122 => 58, 117 => 56, 113 => 55, 108 => 53, 104 => 52, 99 => 50, 95 => 49, 87 => 44, 42 => 1,);
+ }
+
+ public function getSourceContext(): Source
+ {
+ return new Source("", "quiz.html.twig", "/Users/kiem/Documents/WikiFantasy/WF-Website/vue/templates/quiz.html.twig");
+ }
+}
diff --git a/composer.json b/composer.json
index fce1394..a2369e3 100644
--- a/composer.json
+++ b/composer.json
@@ -8,6 +8,7 @@
"psr-4": {
"Controleur\\": "src/Controleur/",
"Model\\": "src/Model/",
+ "Gateway\\": "src/Gateway/",
"Entity\\": "src/Entity/"
}
}
diff --git a/index.php b/index.php
index 9f00e91..bebf483 100644
--- a/index.php
+++ b/index.php
@@ -11,6 +11,7 @@ require_once __DIR__ . '/config/config.php';
require __DIR__ . '/vendor/autoload.php';
+$co = new \Gateway\Connection('pgsql:host=localhost;dbname=dbwikifantasy;', 'kiem', '');
//twig
$loader = new \Twig\Loader\FilesystemLoader('vue/templates');
@@ -19,7 +20,7 @@ $twig = new \Twig\Environment($loader, [
]);
-$cont = new Controleur\FrontControler();
+$cont = new Controleur\FrontControler($co);
session_unset();
session_destroy();
diff --git a/src/Controleur/QuizController.php b/src/Controleur/QuizController.php
index 0a21fad..3b81996 100644
--- a/src/Controleur/QuizController.php
+++ b/src/Controleur/QuizController.php
@@ -1,9 +1,14 @@
co = $co;
+ $this -> gw = new QuestionGateway($this->co);
+ $this -> mdl = new QuestionModel($this->gw);
+
$loader = new FilesystemLoader('vue/templates');
- $this->twig = new \Twig\Environment($loader, [
- 'cache' => false,
- ]);
$action = $_REQUEST['action'] ?? null;
- $id = explode('-', $_SERVER['REQUEST_URI'])[1] ?? null;
+ $id = (int) explode('/', $_SERVER['REQUEST_URI'])[2] ?? null;
+
+ switch ($action) {
+ case 'canswer':
- switch($id)
- {
- case null:
- // page erreur
+ 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);
break;
default:
- $this->showQuestion($id);
- break;
+ switch($id)
+ {
+ case null:
+ // page erreur
+ break;
+ default:
+ $this->showQuestion($id, $this->no_question);
+ break;
+ }
}
+
}
+ public function CorrectAnswer() : bool
+ {
+ $answera = $_POST['answera'] ?? null;
+ $answerb = $_POST['answerb'] ?? null;
+ $answerc = $_POST['answerc'] ?? null;
+ $answerd = $_POST['answerd'] ?? null;
+
+ $id= null;
+ $answer = null;
+
+ if ($answera) {
+ $answer = explode('-', $answera)[0];
+ $id = (int) explode('-', $answera)[1];
+ } elseif ($answerb) {
+ $answer = explode('-', $answerb)[0];
+ $id = (int) explode('-', $answerb)[1];
+ } elseif ($answerc) {
+ $answer = explode('-', $answerc)[0];
+ $id = (int) explode('-', $answerc)[1];
+ } elseif ($answerd) {
+ $answer = explode('-', $answerd)[0];
+ $id = (int) explode('-', $answerd)[1];
+ }
+
+ $res = $this->mdl->getQuestion($id);
+ return $answer == $res->getCanswer();
+ }
public function GetQuestion(int $id): array
{
$gw = new QuizQuestionGateway($this->co);
- $quizModel = new QuizQuestionModel($gw);
- return $quizModel->getAllQuestionByQuiz($id, $this->co);
+ $mdl = new QuizQuestionModel($gw);
+ return $mdl->getAllQuestionByQuiz($id, $this->co);
}
/**
@@ -59,13 +108,37 @@ class QuizController
* @throws SyntaxError
* @throws LoaderError
*/
- public function showQuestion(int $id) : void
+ public function showQuestion(int $id, int $no) : void
{
+ global $twig;
$q = $this->GetQuestion($id);
- $i = 0;
- // en fonction du nb de question restante et du answer submit changer le i
- $q = $q[$i];
+ $question = $q[$no];
- echo $this->twig->render('quiz.html.twig', ['question' => $q]);
+ $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;
+
+ }
+
+}
+
+/*
+
+