|
|
@ -88,8 +88,8 @@ class ControllerUser
|
|
|
|
|
|
|
|
|
|
|
|
function verifySingleplayer()
|
|
|
|
function verifySingleplayer()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$_SESSION["Score"]=0;
|
|
|
|
$_SESSION["Score"] = 0;
|
|
|
|
$_SESSION["PrevTime"]= new DateTime('now');
|
|
|
|
$_SESSION["PrevTime"] = new DateTime('now');
|
|
|
|
$difficulty = $_POST['difficulty'];
|
|
|
|
$difficulty = $_POST['difficulty'];
|
|
|
|
$chapter = $_POST['chapter'];
|
|
|
|
$chapter = $_POST['chapter'];
|
|
|
|
$difficultyIsOk = TRUE;
|
|
|
|
$difficultyIsOk = TRUE;
|
|
|
@ -123,48 +123,60 @@ class ControllerUser
|
|
|
|
function verifQuestion()
|
|
|
|
function verifQuestion()
|
|
|
|
//Only Handdle solo game
|
|
|
|
//Only Handdle solo game
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$_SESSION["CurrTime"]= new DateTime('now');
|
|
|
|
$_SESSION["CurrTime"] = new DateTime('now');
|
|
|
|
$answerNumber = $_POST["answer"];
|
|
|
|
$answerNumber = $_POST["answer"];
|
|
|
|
$numQuestion = $_POST["numQuestion"] + 1;
|
|
|
|
$numQuestion = $_POST["numQuestion"];
|
|
|
|
if (!($answerNumber == 0 or $answerNumber == 1 or $answerNumber == 2 or $answerNumber == 3)) {
|
|
|
|
if (!($answerNumber == 0 or $answerNumber == 1 or $answerNumber == 2 or $answerNumber == 3)) {
|
|
|
|
$_SESSION["error"] = "Valeur de choix de réponse invalide";
|
|
|
|
$_SESSION["error"] = "Valeur de choix de réponse invalide";
|
|
|
|
echo $this->twig->render($this->vues["singleplayer"], [
|
|
|
|
echo $this->twig->render($this->vues["singleplayer"], [
|
|
|
|
'questions' => $_SESSION["Questions"],
|
|
|
|
'questions' => $_SESSION["Questions"],
|
|
|
|
'numQuestion' => $numQuestion-1,
|
|
|
|
'numQuestion' => $numQuestion,
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if ($numQuestion > 9) {
|
|
|
|
$answerContent = $_SESSION["Questions"][$numQuestion]['answers'][$answerNumber]['content'];
|
|
|
|
var_dump($_SESSION["Score"]);
|
|
|
|
$_SESSION["Questions"][$numQuestion]['playerAnswersContent'] = $answerContent;
|
|
|
|
/// echo $this->twig->render($this->vues["ViewScore"], [
|
|
|
|
if ($_SESSION["Questions"][$numQuestion]['idanswergood'] == $_SESSION["Questions"][$numQuestion]['answers'][$answerNumber]['id']) {
|
|
|
|
/// 'score' => $_SESSION["Score"],
|
|
|
|
$time = $_SESSION["PrevTime"]->diff($_SESSION["CurrTime"]);
|
|
|
|
/// ];
|
|
|
|
$_SESSION["Score"] = $_SESSION["Score"] + 80 + 40 * ((30 - $time->s) / 100 * 10 / 3);
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
var_dump($_SESSION["Questions"][$numQuestion - 1]['idanswergood']);
|
|
|
|
|
|
|
|
var_dump($_SESSION["Questions"][$numQuestion - 1]['answers'][$answerNumber]['id']);
|
|
|
|
if ($numQuestion <= 2) {
|
|
|
|
if ($_SESSION["Questions"][$numQuestion - 1]['idanswergood'] == $_SESSION["Questions"][$numQuestion - 1]['answers'][$answerNumber]['id']) {
|
|
|
|
|
|
|
|
$time = $_SESSION["PrevTime"]->diff($_SESSION["CurrTime"]);
|
|
|
|
|
|
|
|
$_SESSION["Score"]= $_SESSION["Score"] + 80 + 40*((30-$time->s)/100*10/3);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$_SESSION["PrevTime"] = $_SESSION["CurrTime"];
|
|
|
|
$_SESSION["PrevTime"] = $_SESSION["CurrTime"];
|
|
|
|
echo $this->twig->render($this->vues["singleplayer"], [
|
|
|
|
echo $this->twig->render($this->vues["singleplayer"], [
|
|
|
|
'questions' => $_SESSION["Questions"],
|
|
|
|
'questions' => $_SESSION["Questions"],
|
|
|
|
'numQuestion' => $numQuestion,
|
|
|
|
'numQuestion' => $numQuestion+1,
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
foreach ($_SESSION["Questions"] as &$question) {
|
|
|
|
|
|
|
|
$answer = $this->mdAnswer->getAnswerByID($question['idanswergood']);
|
|
|
|
|
|
|
|
$question['goodAnswersContent'] = $answer['content'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var_dump($_SESSION["Questions"]);
|
|
|
|
|
|
|
|
// echo $this->twig->render($this->vues["viewScore"], [
|
|
|
|
|
|
|
|
// 'score' => $_SESSION["Score"],
|
|
|
|
|
|
|
|
// 'questions' => $_SESSION["Questions"],
|
|
|
|
|
|
|
|
// ]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function passer()
|
|
|
|
function passer()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$numQuestion = $_POST["numQuestion"] + 1;
|
|
|
|
$numQuestion = $_POST["numQuestion"];
|
|
|
|
if ($numQuestion > 9) {
|
|
|
|
if ($numQuestion <= 9) {
|
|
|
|
echo $this->twig->render($this->vues["home"]);
|
|
|
|
$_SESSION["PrevTime"] = $_SESSION["CurrTime"];
|
|
|
|
//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 {
|
|
|
|
|
|
|
|
$_SESSION["PrevTime"] = $_SESSION["CurrTime"];
|
|
|
|
|
|
|
|
echo $this->twig->render($this->vues["singleplayer"], [
|
|
|
|
echo $this->twig->render($this->vues["singleplayer"], [
|
|
|
|
'questions' => $_SESSION["Questions"],
|
|
|
|
'questions' => $_SESSION["Questions"],
|
|
|
|
'numQuestion' => $numQuestion,
|
|
|
|
'numQuestion' => $numQuestion + 1,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
foreach ($_SESSION["Questions"] as &$question) {
|
|
|
|
|
|
|
|
$answer = $this->mdAnswer->getAnswerByID($question['idAnswerGood']);
|
|
|
|
|
|
|
|
$question['GoodAnswersContent'] = $answer['content'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $this->twig->render($this->vues["ViewScore"], [
|
|
|
|
|
|
|
|
'score' => $_SESSION["Score"],
|
|
|
|
|
|
|
|
'questions' => $_SESSION["Questions"],
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|