diff --git a/Website/controllers/ControllerUser.php b/Website/controllers/ControllerUser.php index 8a2edde..6c809b6 100644 --- a/Website/controllers/ControllerUser.php +++ b/Website/controllers/ControllerUser.php @@ -56,7 +56,16 @@ class ControllerUser echo $this->twig->render($this->vues["multiplayer"]); } - function login() + function loginAdmin() + { + echo $this->twig->render($this->vues["loginAdmin"], [ + 'error' => $_SESSION["error"], + ]); + + $_SESSION["error"] = ""; + } + + function loginPlayer() { echo $this->twig->render($this->vues["loginAdmin"], [ 'error' => $_SESSION["error"], diff --git a/Website/controllers/ControllerUserPlayers.php b/Website/controllers/ControllerUserPlayers.php new file mode 100644 index 0000000..14434cb --- /dev/null +++ b/Website/controllers/ControllerUserPlayers.php @@ -0,0 +1,76 @@ +twig =$twig; + $this->vues = $vues; + + $this->mdPlayer = new ModelPlayer(); + } + else { + header("Location:/login"); + } + } catch (PDOException $e) { + // Gérez les erreurs PDO ici + } catch (Exception $e2) { + // Gérez d'autres erreurs ici + } + } + + function delete($param) { + $this->mdPlayer->deleteAdministratorByID($param["id"]); + header("Location:/admin/administrators"); + } + + function add($param) { + + $username = $_POST['username']; + $password = $_POST['password']; + + $Player = [ + 'username' => $username, + 'password' => $password, + ]; + + $this->mdPlayer->addAdministrator($Player); + + header("Location:/loginPlayer"); + } + + function updatemodal($param) { + + $administrator = $this->mdPlayer->getAdministratorByID($param["id"]); + + echo $this->twig->render($this->vues["adminAdministratorsModal"], [ + 'administrator' => $administrator, + ]); + } + + function update($param) { + + $id = $_POST['id']; + $username = $_POST['username']; + $password = $_POST['password']; + + $Admin = [ + 'username' => $username, + 'password' => $password, + ]; + + $this->mdPlayer->updateAdministrator($id,$Admin); + + header("Location:/admin/administrators"); + } +} \ No newline at end of file diff --git a/Website/controllers/FrontController.php b/Website/controllers/FrontController.php index cc20a13..29e9166 100755 --- a/Website/controllers/FrontController.php +++ b/Website/controllers/FrontController.php @@ -25,6 +25,8 @@ class FrontController $router->map('GET', '/admin/questions', 'ControllerAdminQuestions'); $router->map('POST', '/admin/questions/[a:action]', 'ControllerAdminQuestions'); $router->map('GET', '/admin/questions/[a:action]/[i:id]', 'ControllerAdminQuestions'); + $router->map('POST', '/user/players/[a:action]', 'ControllerAdminQuestions'); + $router->map('GET', '/user/players/[a:action]/[i:id]', 'ControllerAdminQuestions'); // Match the current request $match = $router->match(); diff --git a/Website/gateways/GatewayQuestion.php b/Website/gateways/GatewayQuestion.php index 39b709d..6ee3749 100755 --- a/Website/gateways/GatewayQuestion.php +++ b/Website/gateways/GatewayQuestion.php @@ -65,7 +65,7 @@ class GatewayQuestion public function getQuestionsByChapterAndDifficulty($idChapter, $difficulty) { - $query = "SELECT * FROM questions WHERE idchapter = :idChapter AND difficulty = :difficulty;"; + $query = "SELECT * FROM questions WHERE idchapter = :idChapter AND difficulty = :difficulty ORDER BY RAND() LIMIT 10;"; $this->con->executeQuery( $query, array( diff --git a/Website/templates/home.twig b/Website/templates/home.twig index 2fe9194..eb61a11 100644 --- a/Website/templates/home.twig +++ b/Website/templates/home.twig @@ -10,6 +10,9 @@
+🏆 Score : 🏆
{{ score }}