|
|
@ -103,15 +103,14 @@ class ControllerUser
|
|
|
|
$chapterIsOk = FALSE;
|
|
|
|
$chapterIsOk = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($difficultyIsOk and $chapterIsOk) {
|
|
|
|
if ($difficultyIsOk and $chapterIsOk) {
|
|
|
|
$questions = $this->mdQuestion->getQuestionsByChapterAndDifficulty($chapter, $difficulty);
|
|
|
|
$_SESSION["Questions"] = $this->mdQuestion->getQuestionsByChapterAndDifficulty($chapter, $difficulty);
|
|
|
|
foreach ($questions as &$question) {
|
|
|
|
foreach ($_SESSION["Questions"] as &$question) {
|
|
|
|
$answers = $this->mdAnswer->getAnswersByIDQuestions($question['id']);
|
|
|
|
$answers = $this->mdAnswer->getAnswersByIDQuestions($question['id']);
|
|
|
|
$question['answers'] = $answers;
|
|
|
|
$question['answers'] = $answers;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo $this->twig->render($this->vues["singleplayer"], [
|
|
|
|
echo $this->twig->render($this->vues["singleplayer"], [
|
|
|
|
'questions' => $questions,
|
|
|
|
'questions' => $_SESSION["Questions"],
|
|
|
|
'numQuestion' => 0,
|
|
|
|
'numQuestion' => 0,
|
|
|
|
'jsonQuestions' => json_encode($questions),
|
|
|
|
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$_SESSION["error"] = "Valeur de choix de thème invalide";
|
|
|
|
$_SESSION["error"] = "Valeur de choix de thème invalide";
|
|
|
@ -124,23 +123,43 @@ class ControllerUser
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$answerNumber = $_POST["answer"];
|
|
|
|
$answerNumber = $_POST["answer"];
|
|
|
|
$numQuestion = $_POST["numQuestion"] + 1;
|
|
|
|
$numQuestion = $_POST["numQuestion"] + 1;
|
|
|
|
$questions = json_decode($_POST["questions"], true);
|
|
|
|
if ($answerNumber != 1 or $answerNumber != 2 or $answerNumber != 3 or $answerNumber != 4) {
|
|
|
|
|
|
|
|
$_SESSION["error"] = "Valeur de choix de réponse invalide";
|
|
|
|
|
|
|
|
echo $this->twig->render($this->vues["singleplayer"], [
|
|
|
|
|
|
|
|
'questions' => $_SESSION["Questions"],
|
|
|
|
|
|
|
|
'numQuestion' => $numQuestion,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if ($numQuestion > 9) {
|
|
|
|
|
|
|
|
echo $this->twig->render($this->vues["home"]);
|
|
|
|
|
|
|
|
//EN GROS IL FAUT AFFICHER LE SCORE (C'est copilot qui a fait ça, la fin du commentaire j'veux dire)
|
|
|
|
|
|
|
|
//Si faut paser un param score de page en page dittes le moi je le ferais dw
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if ($_SESSION["Questions"][$numQuestion - 1]['idanswergood'] == $_SESSION["Questions"][$numQuestion - 1]['answers'][$answerNumber]['id']) {
|
|
|
|
|
|
|
|
// Player won
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//Player lost
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $this->twig->render($this->vues["singleplayer"], [
|
|
|
|
|
|
|
|
'questions' => $_SESSION["Questions"],
|
|
|
|
|
|
|
|
'numQuestion' => $numQuestion,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function passer()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$numQuestion = $_POST["numQuestion"] + 1;
|
|
|
|
if ($numQuestion > 9) {
|
|
|
|
if ($numQuestion > 9) {
|
|
|
|
echo $this->twig->render($this->vues["home"]);
|
|
|
|
echo $this->twig->render($this->vues["home"]);
|
|
|
|
//EN GROS IL FAUT AFFICHER LE SCORE (C'est copilot qui a fait ça, la fin du commentaire j'veux dire)
|
|
|
|
//EN GROS IL FAUT AFFICHER LE SCORE (C'est copilot qui a fait ça, la fin du commentaire j'veux dire)
|
|
|
|
//Si faut paser un param score de page en page dittes le moi je le ferais dw
|
|
|
|
//Si faut paser un param score de page en page dittes le moi je le ferais dw
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
var_dump($_SESSION["Temps"]);
|
|
|
|
if ($questions[$numQuestion - 1]['idanswergood'] == $questions[$numQuestion - 1]['answers'][$answerNumber]['id']) {
|
|
|
|
// echo $this->twig->render($this->vues["singleplayer"], [
|
|
|
|
// Player won
|
|
|
|
// 'questions' => $_SESSION["Questions"],
|
|
|
|
} else {
|
|
|
|
// 'numQuestion' => $numQuestion,
|
|
|
|
//Player lost
|
|
|
|
// ]);
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $this->twig->render($this->vues["singleplayer"], [
|
|
|
|
|
|
|
|
'questions' => $questions,
|
|
|
|
|
|
|
|
'numQuestion' => $numQuestion,
|
|
|
|
|
|
|
|
'jsonQuestions' => json_encode($questions),
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|