twig = $twig; $this->vues = $vues; $this->mdQuestion = new ModelQuestion(); $this->mdAnswer = new ModelAnswer(); $this->mdChapter = new ModelChapter(); $this->mdPlayer = new ModelPlayer(); $this->mdLobby = new ModelLobby(); $this->mdAdministrator = new ModelAdministrator(); } catch (PDOException $e) { // $dataVueEreur[] = "Erreur inattendue!!! "; // require(__DIR__.'/../vues/erreur.php'); } catch (Exception $e2) { // $dataVueEreur[] = "Erreur inattendue!!! "; // require ($rep.$vues['erreur']); } } function home() { echo $this->twig->render($this->vues["home"]); } function themeChoice() { $chapters = $this->mdChapter->getChapters(); echo $this->twig->render($this->vues["themeChoice"], [ 'chapters' => $chapters, ]); } function singleplayer() { echo $this->twig->render($this->vues["singleplayer"]); } function multiplayer() { echo $this->twig->render($this->vues["multiplayer"]); } function login() { echo $this->twig->render($this->vues["loginAdmin"], [ 'error' => $_SESSION["error"], ]); $_SESSION["error"] = ""; } function verifyAdmin() { $username = $_POST['username']; $password = $_POST['password']; $Administrator = [ 'username' => $username, 'password' => $password, ]; $AdministratorIsOk = $this->mdAdministrator->verifyAdministrator($Administrator); if ($AdministratorIsOk != null) { $_SESSION["idAdminConnected"] = $AdministratorIsOk; header("Location:/admin/administrators"); } else { $_SESSION["error"] = "utilisateur introuvable."; header("Location:/login"); } } function verifySingleplayer() { $difficulty = $_POST['difficulty']; $chapter = $_POST['chapter']; $difficultyIsOk = TRUE; $chapterIsOk = TRUE; if (!($difficulty == 0 or $difficulty == 1 or $difficulty == 2)) { $_SESSION["error"] = "Valeur de difficulté invalide"; $difficultyIsOk = FALSE; } if ($this->mdChapter->verifyChapter($chapter) == NULL) { $_SESSION["error"] = "Valeur de chapitre invalide"; $chapterIsOk = FALSE; } if ($difficultyIsOk and $chapterIsOk) { $questions = $this->mdQuestion->getQuestionsByChapterAndDifficulty($chapter,$difficulty); var_dump($questions); echo $this->twig->render($this->vues["singleplayer"], [ 'questions' => $questions, 'numQuestion' => 0, ]); } else { $_SESSION["error"] = "Valeur de choix de thème invalide"; header("Location:/themeChoice"); } } }