From 7de862d0c4bebf8a91fb8b86cb4f61378a408512 Mon Sep 17 00:00:00 2001 From: Jeremy DUCOURTHIAL Date: Thu, 9 Nov 2023 15:21:44 +0100 Subject: [PATCH] feat : model + controller + gateway fix --- ...85934e5c3eddee1052de5e2ecf10e156219e2b.php | 136 ---------- ...6fe5919e8685e374b516e7f56df9d25c13c67f.php | 148 ----------- ...97648a7e4b30290a5341fa0151ef490a532206.php | 105 -------- ...947dbce722c56faec3b1e728b787873ffa938a.php | 152 ----------- ...faccfdb77da719ebedd504693256c911a170a3.php | 145 ---------- ...63147e79c8be196c8f83c1ad6a3a7b0014acfa.php | 121 --------- ...4518c2907ce9eecc5ae2c54be3aa1799e9bd4e.php | 250 ------------------ ...0bf9078df9e09e730bbdced5a971926714b55a.php | 111 -------- ...b600105fb3225296e06aa63c58bbcc6e276d08.php | 152 ----------- ...77d7929c7dfc90e98d4f6294055f986785e719.php | 101 ------- ...07eefb8bf76bb5053c141d59fa798f5b57f2ba.php | 190 ------------- Website/{models => class}/Administrator.php | 0 Website/{models => class}/Answer.php | 0 Website/{models => class}/Chapter.php | 0 Website/{models => class}/Lobby.php | 0 Website/{models => class}/Player.php | 0 Website/{models => class}/Question.php | 0 Website/controllers/ControllerAccueil.php | 43 --- .../ControllerAdminAdministrators.php | 26 +- .../controllers/ControllerAdminChapters.php | 26 +- .../controllers/ControllerAdminQuestions.php | 121 +++++---- Website/controllers/ControllerLoginAdmin.php | 48 ---- Website/controllers/ControllerMulti.php | 43 --- Website/controllers/ControllerSolo.php | 42 --- Website/controllers/ControllerUser.php | 85 ++++++ Website/controllers/FrontController.php | 29 +- Website/gateways/GatewayAdministrator.php | 17 +- Website/gateways/GatewayAnswer.php | 11 +- Website/gateways/GatewayChapter.php | 9 +- Website/gateways/GatewayLobby.php | 13 +- Website/gateways/GatewayPlayer.php | 17 +- Website/gateways/GatewayQuestion.php | 24 +- Website/index.php | 3 +- Website/models/ModelAdministrator.php | 44 +++ Website/models/ModelAnswer.php | 28 ++ Website/models/ModelChapter.php | 38 +++ Website/models/ModelLobby.php | 22 ++ Website/models/ModelPlayer.php | 32 +++ Website/models/ModelQuestion.php | 39 +++ Website/templates/adminAdministrators.twig | 4 +- Website/templates/adminChapters.twig | 4 +- Website/templates/adminQuestions.twig | 14 +- Website/templates/adminQuestionsModal.twig | 10 +- Website/templates/{accueil.twig => home.twig} | 4 +- Website/templates/loginAdmin.twig | 2 +- .../{multijoueur.twig => multiplayer.twig} | 0 .../{solo.twig => singleplayer.twig} | 0 Website/usages/Config.php | 6 +- 48 files changed, 468 insertions(+), 1947 deletions(-) delete mode 100644 Website/cache/13/1347f3db213e1bf75451b4cc3885934e5c3eddee1052de5e2ecf10e156219e2b.php delete mode 100644 Website/cache/1f/1fc7d8dc401f74d1d06b95bd6b6fe5919e8685e374b516e7f56df9d25c13c67f.php delete mode 100644 Website/cache/28/2874fd11e8ba4e8aedc291f0ea97648a7e4b30290a5341fa0151ef490a532206.php delete mode 100644 Website/cache/4f/4f9c74e337511dff24e627b10b947dbce722c56faec3b1e728b787873ffa938a.php delete mode 100644 Website/cache/55/55b0aca05d3256711284e44b0cfaccfdb77da719ebedd504693256c911a170a3.php delete mode 100644 Website/cache/5a/5a1baa02496b99a752bfec79c963147e79c8be196c8f83c1ad6a3a7b0014acfa.php delete mode 100644 Website/cache/a2/a23149f73c48985414ea7a4dd74518c2907ce9eecc5ae2c54be3aa1799e9bd4e.php delete mode 100644 Website/cache/b2/b2674317b6db9744dcd4652e8f0bf9078df9e09e730bbdced5a971926714b55a.php delete mode 100644 Website/cache/bb/bba6790b934a511ee44ce677aeb600105fb3225296e06aa63c58bbcc6e276d08.php delete mode 100644 Website/cache/bb/bbb94270b2cc50f8b189cc0bb277d7929c7dfc90e98d4f6294055f986785e719.php delete mode 100644 Website/cache/bb/bbf848822c23cc3555010da96607eefb8bf76bb5053c141d59fa798f5b57f2ba.php rename Website/{models => class}/Administrator.php (100%) mode change 100755 => 100644 rename Website/{models => class}/Answer.php (100%) mode change 100755 => 100644 rename Website/{models => class}/Chapter.php (100%) mode change 100755 => 100644 rename Website/{models => class}/Lobby.php (100%) mode change 100755 => 100644 rename Website/{models => class}/Player.php (100%) mode change 100755 => 100644 rename Website/{models => class}/Question.php (100%) mode change 100755 => 100644 delete mode 100644 Website/controllers/ControllerAccueil.php delete mode 100644 Website/controllers/ControllerLoginAdmin.php delete mode 100644 Website/controllers/ControllerMulti.php delete mode 100644 Website/controllers/ControllerSolo.php create mode 100644 Website/controllers/ControllerUser.php create mode 100644 Website/models/ModelAdministrator.php create mode 100644 Website/models/ModelAnswer.php create mode 100644 Website/models/ModelChapter.php create mode 100644 Website/models/ModelLobby.php create mode 100644 Website/models/ModelPlayer.php create mode 100644 Website/models/ModelQuestion.php rename Website/templates/{accueil.twig => home.twig} (75%) rename Website/templates/{multijoueur.twig => multiplayer.twig} (100%) rename Website/templates/{solo.twig => singleplayer.twig} (100%) diff --git a/Website/cache/13/1347f3db213e1bf75451b4cc3885934e5c3eddee1052de5e2ecf10e156219e2b.php b/Website/cache/13/1347f3db213e1bf75451b4cc3885934e5c3eddee1052de5e2ecf10e156219e2b.php deleted file mode 100644 index 1f17a9b..0000000 --- a/Website/cache/13/1347f3db213e1bf75451b4cc3885934e5c3eddee1052de5e2ecf10e156219e2b.php +++ /dev/null @@ -1,136 +0,0 @@ -source = $this->getSourceContext(); - - $this->parent = false; - - $this->blocks = [ - ]; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - // line 1 - echo " - - - Maths Educ - - - - - - - - - -
-
-
-
-
modifier un Chapter
-
-
-
-
- -
-
- - -
-
-
- - -
-
-
-
-
- - - - - - -"; - } - - public function getTemplateName() - { - return "adminChaptersModal.twig"; - } - - public function isTraitable() - { - return false; - } - - public function getDebugInfo() - { - return array ( 105 => 61, 101 => 60, 89 => 51, 37 => 1,); - } - - public function getSourceContext() - { - return new Source("", "adminChaptersModal.twig", "C:\\MAMP\\htdocs\\3.01-QCM_MuscuMaths\\Website\\templates\\adminChaptersModal.twig"); - } -} diff --git a/Website/cache/1f/1fc7d8dc401f74d1d06b95bd6b6fe5919e8685e374b516e7f56df9d25c13c67f.php b/Website/cache/1f/1fc7d8dc401f74d1d06b95bd6b6fe5919e8685e374b516e7f56df9d25c13c67f.php deleted file mode 100644 index b0004f2..0000000 --- a/Website/cache/1f/1fc7d8dc401f74d1d06b95bd6b6fe5919e8685e374b516e7f56df9d25c13c67f.php +++ /dev/null @@ -1,148 +0,0 @@ -source = $this->getSourceContext(); - - $this->parent = false; - - $this->blocks = [ - ]; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - // line 1 - echo " - - - Maths Educ - - - - - - - - - -
-

Liste des chapitres

- -
-
- -
- D - Retour - G -
-
- - - -
-
-
-
-
Ajouter un chapitre
-
-
-
-
- - -
-
-
- - -
-
-
-
-
- - -"; - } - - public function getTemplateName() - { - return "adminChapters.twig"; - } - - public function isTraitable() - { - return false; - } - - public function getDebugInfo() - { - return array ( 90 => 35, 80 => 31, 76 => 30, 71 => 28, 68 => 27, 64 => 26, 37 => 1,); - } - - public function getSourceContext() - { - return new Source("", "adminChapters.twig", "C:\\MAMP\\htdocs\\3.01-QCM_MuscuMaths\\Website\\templates\\adminChapters.twig"); - } -} diff --git a/Website/cache/28/2874fd11e8ba4e8aedc291f0ea97648a7e4b30290a5341fa0151ef490a532206.php b/Website/cache/28/2874fd11e8ba4e8aedc291f0ea97648a7e4b30290a5341fa0151ef490a532206.php deleted file mode 100644 index 135a3c9..0000000 --- a/Website/cache/28/2874fd11e8ba4e8aedc291f0ea97648a7e4b30290a5341fa0151ef490a532206.php +++ /dev/null @@ -1,105 +0,0 @@ -source = $this->getSourceContext(); - - $this->parent = false; - - $this->blocks = [ - ]; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - // line 1 - echo " - - - - Math'Educ - Connexion - - - - -
-
-
-
-
-

Connexion

-
-
- - -
-
- - -
- -

"; - // line 35 - echo twig_escape_filter($this->env, ($context["error"] ?? null), "html", null, true); - echo "

-
-
-
-
-
-
- - -"; - } - - public function getTemplateName() - { - return "loginAdmin.twig"; - } - - public function isTraitable() - { - return false; - } - - public function getDebugInfo() - { - return array ( 73 => 35, 37 => 1,); - } - - public function getSourceContext() - { - return new Source("", "loginAdmin.twig", "C:\\MAMP\\htdocs\\3.01-QCM_MuscuMaths\\Website\\templates\\loginAdmin.twig"); - } -} diff --git a/Website/cache/4f/4f9c74e337511dff24e627b10b947dbce722c56faec3b1e728b787873ffa938a.php b/Website/cache/4f/4f9c74e337511dff24e627b10b947dbce722c56faec3b1e728b787873ffa938a.php deleted file mode 100644 index 2070def..0000000 --- a/Website/cache/4f/4f9c74e337511dff24e627b10b947dbce722c56faec3b1e728b787873ffa938a.php +++ /dev/null @@ -1,152 +0,0 @@ -source = $this->getSourceContext(); - - $this->parent = false; - - $this->blocks = [ - ]; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - // line 1 - echo " - - - Maths Educ - - - - - - - - - -
-

Liste des administrators

- -
-
- -
- D - Retour - G -
-
- - - -
-
-
-
-
Ajouter un administrateur
-
-
-
-
- - -
-
- - -
-
-
- - -
-
-
-
-
- - -"; - } - - public function getTemplateName() - { - return "adminAdministrators.twig"; - } - - public function isTraitable() - { - return false; - } - - public function getDebugInfo() - { - return array ( 90 => 35, 80 => 31, 76 => 30, 71 => 28, 68 => 27, 64 => 26, 37 => 1,); - } - - public function getSourceContext() - { - return new Source("", "adminAdministrators.twig", "C:\\MAMP\\htdocs\\3.01-QCM_MuscuMaths\\Website\\templates\\adminAdministrators.twig"); - } -} diff --git a/Website/cache/55/55b0aca05d3256711284e44b0cfaccfdb77da719ebedd504693256c911a170a3.php b/Website/cache/55/55b0aca05d3256711284e44b0cfaccfdb77da719ebedd504693256c911a170a3.php deleted file mode 100644 index 3b10d76..0000000 --- a/Website/cache/55/55b0aca05d3256711284e44b0cfaccfdb77da719ebedd504693256c911a170a3.php +++ /dev/null @@ -1,145 +0,0 @@ -source = $this->getSourceContext(); - - $this->parent = false; - - $this->blocks = [ - ]; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - // line 1 - echo " - - - Maths Educ - - - - - - - - - -
-
-
-
-
Modifier un administrateur
-
-
-
-
- -
-
- - -
-
- - -
-
-
- - -
-
-
-
-
- - - - - - -"; - } - - public function getTemplateName() - { - return "adminAdministratorsModal.twig"; - } - - public function isTraitable() - { - return false; - } - - public function getDebugInfo() - { - return array ( 114 => 67, 110 => 66, 106 => 65, 93 => 55, 37 => 1,); - } - - public function getSourceContext() - { - return new Source("", "adminAdministratorsModal.twig", "C:\\MAMP\\htdocs\\3.01-QCM_MuscuMaths\\Website\\templates\\adminAdministratorsModal.twig"); - } -} diff --git a/Website/cache/5a/5a1baa02496b99a752bfec79c963147e79c8be196c8f83c1ad6a3a7b0014acfa.php b/Website/cache/5a/5a1baa02496b99a752bfec79c963147e79c8be196c8f83c1ad6a3a7b0014acfa.php deleted file mode 100644 index 2c15b5e..0000000 --- a/Website/cache/5a/5a1baa02496b99a752bfec79c963147e79c8be196c8f83c1ad6a3a7b0014acfa.php +++ /dev/null @@ -1,121 +0,0 @@ -source = $this->getSourceContext(); - - $this->parent = false; - - $this->blocks = [ - ]; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - // line 1 - echo " - - - - - - Math'Educ - - - - - -
-
-

- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident fuga cum soluta iure libero! Ullam, expedita excepturi! Odio distinctio quos quasi commodi libero ratione corrupti, unde iste explicabo suscipit consequatur ipsum! Id beatae corrupti ipsa totam deserunt, vel tenetur, iusto quaerat asperiores veritatis quidem! Vel dolorem recusandae necessitatibus ullam laborum! - -

-
-
-
- - -
-
- - -
-
-
-"; - } - - public function getTemplateName() - { - return "multijoueur.twig"; - } - - public function getDebugInfo() - { - return array ( 37 => 1,); - } - - public function getSourceContext() - { - return new Source("", "multijoueur.twig", "C:\\MAMP\\htdocs\\3.01-QCM_MuscuMaths\\Website\\templates\\multijoueur.twig"); - } -} diff --git a/Website/cache/a2/a23149f73c48985414ea7a4dd74518c2907ce9eecc5ae2c54be3aa1799e9bd4e.php b/Website/cache/a2/a23149f73c48985414ea7a4dd74518c2907ce9eecc5ae2c54be3aa1799e9bd4e.php deleted file mode 100644 index aa8ef68..0000000 --- a/Website/cache/a2/a23149f73c48985414ea7a4dd74518c2907ce9eecc5ae2c54be3aa1799e9bd4e.php +++ /dev/null @@ -1,250 +0,0 @@ -source = $this->getSourceContext(); - - $this->parent = false; - - $this->blocks = [ - ]; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - // line 1 - echo " - - - Maths Educ - - - - - - - - - -
-
-
-
-
Ajouter un chapitre
-
-
-
-
- -
-
- - -
-
- - -
-
- - - - env, $this->source, ($context["question"] ?? null), "idanswergood", [], "any", false, false, false, 50) == twig_get_attribute($this->env, $this->source, (($__internal_compile_0 = ($context["answers"] ?? null)) && is_array($__internal_compile_0) || $__internal_compile_0 instanceof ArrayAccess ? ($__internal_compile_0[0] ?? null) : null), "id", [], "any", false, false, false, 50))) { - echo "checked=\"checked\""; - } - echo " value=\"1\"> Correct -
-
- - - - env, $this->source, ($context["question"] ?? null), "idanswergood", [], "any", false, false, false, 56) == twig_get_attribute($this->env, $this->source, (($__internal_compile_1 = ($context["answers"] ?? null)) && is_array($__internal_compile_1) || $__internal_compile_1 instanceof ArrayAccess ? ($__internal_compile_1[1] ?? null) : null), "id", [], "any", false, false, false, 56))) { - echo "checked=\"checked\""; - } - echo " value=\"2\"> Correct -
-
- - - - env, $this->source, ($context["question"] ?? null), "idanswergood", [], "any", false, false, false, 62) == twig_get_attribute($this->env, $this->source, (($__internal_compile_2 = ($context["answers"] ?? null)) && is_array($__internal_compile_2) || $__internal_compile_2 instanceof ArrayAccess ? ($__internal_compile_2[2] ?? null) : null), "id", [], "any", false, false, false, 62))) { - echo "checked=\"checked\""; - } - echo " value=\"3\"> Correct -
-
- - - - env, $this->source, ($context["question"] ?? null), "idanswergood", [], "any", false, false, false, 68) == twig_get_attribute($this->env, $this->source, (($__internal_compile_3 = ($context["answers"] ?? null)) && is_array($__internal_compile_3) || $__internal_compile_3 instanceof ArrayAccess ? ($__internal_compile_3[3] ?? null) : null), "id", [], "any", false, false, false, 68))) { - echo "checked=\"checked\""; - } - echo " value=\"4\"> Correct -
-
-
- - -
-
-
-
-
- - - - - - -"; - } - - public function getTemplateName() - { - return "adminQuestionsModal.twig"; - } - - public function isTraitable() - { - return false; - } - - public function getDebugInfo() - { - return array ( 219 => 113, 215 => 112, 211 => 111, 207 => 110, 202 => 108, 198 => 107, 194 => 106, 190 => 105, 185 => 103, 181 => 102, 159 => 83, 139 => 68, 128 => 62, 117 => 56, 106 => 50, 98 => 44, 83 => 42, 79 => 41, 37 => 1,); - } - - public function getSourceContext() - { - return new Source("", "adminQuestionsModal.twig", "C:\\MAMP\\htdocs\\3.01-QCM_MuscuMaths\\Website\\templates\\adminQuestionsModal.twig"); - } -} diff --git a/Website/cache/b2/b2674317b6db9744dcd4652e8f0bf9078df9e09e730bbdced5a971926714b55a.php b/Website/cache/b2/b2674317b6db9744dcd4652e8f0bf9078df9e09e730bbdced5a971926714b55a.php deleted file mode 100644 index dd1b060..0000000 --- a/Website/cache/b2/b2674317b6db9744dcd4652e8f0bf9078df9e09e730bbdced5a971926714b55a.php +++ /dev/null @@ -1,111 +0,0 @@ -source = $this->getSourceContext(); - - $this->parent = false; - - $this->blocks = [ - ]; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - // line 1 - echo " - - - - - - Math'Educ - - - - - -
-
-

- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident fuga cum soluta iure libero! Ullam, expedita excepturi! Odio distinctio quos quasi commodi libero ratione corrupti, unde iste explicabo suscipit consequatur ipsum! Id beatae corrupti ipsa totam deserunt, vel tenetur, iusto quaerat asperiores veritatis quidem! Vel dolorem recusandae necessitatibus ullam laborum! - -

-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-"; - } - - public function getTemplateName() - { - return "solo.twig"; - } - - public function getDebugInfo() - { - return array ( 37 => 1,); - } - - public function getSourceContext() - { - return new Source("", "solo.twig", "C:\\MAMP\\htdocs\\3.01-QCM_MuscuMaths\\Website\\templates\\solo.twig"); - } -} diff --git a/Website/cache/bb/bba6790b934a511ee44ce677aeb600105fb3225296e06aa63c58bbcc6e276d08.php b/Website/cache/bb/bba6790b934a511ee44ce677aeb600105fb3225296e06aa63c58bbcc6e276d08.php deleted file mode 100644 index 41219b3..0000000 --- a/Website/cache/bb/bba6790b934a511ee44ce677aeb600105fb3225296e06aa63c58bbcc6e276d08.php +++ /dev/null @@ -1,152 +0,0 @@ -source = $this->getSourceContext(); - - $this->parent = false; - - $this->blocks = [ - ]; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - // line 1 - echo " - - - Maths Educ - - - - - - - - - -
-

Liste des Administrateurs

- -
-
- -
- D - Retour - G -
-
- -
-
-
-
-
Ajouter une question
- -
-
-
- -
- - -
- -
-
-
- - -
-
-
-
- - -"; - } - - public function getTemplateName() - { - return "adminPlayers.twig"; - } - - public function isTraitable() - { - return false; - } - - public function getDebugInfo() - { - return array ( 91 => 36, 81 => 32, 77 => 31, 72 => 29, 69 => 28, 65 => 27, 37 => 1,); - } - - public function getSourceContext() - { - return new Source("", "adminPlayers.twig", "C:\\MAMP\\htdocs\\3.01-QCM_MuscuMaths\\Website\\templates\\adminPlayers.twig"); - } -} diff --git a/Website/cache/bb/bbb94270b2cc50f8b189cc0bb277d7929c7dfc90e98d4f6294055f986785e719.php b/Website/cache/bb/bbb94270b2cc50f8b189cc0bb277d7929c7dfc90e98d4f6294055f986785e719.php deleted file mode 100644 index bc5068d..0000000 --- a/Website/cache/bb/bbb94270b2cc50f8b189cc0bb277d7929c7dfc90e98d4f6294055f986785e719.php +++ /dev/null @@ -1,101 +0,0 @@ -source = $this->getSourceContext(); - - $this->parent = false; - - $this->blocks = [ - ]; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - // line 1 - echo " - - - - - - Math'Educ - - - - - -
- - -
-

- SOLO -

-
-
- -
-

- MULTIJOUEUR -

-
-
- -
-

- ADMINISTRATION -

-
-
-
- - -"; - } - - public function getTemplateName() - { - return "accueil.twig"; - } - - public function getDebugInfo() - { - return array ( 37 => 1,); - } - - public function getSourceContext() - { - return new Source("", "accueil.twig", "C:\\MAMP\\htdocs\\3.01-QCM_MuscuMaths\\Website\\templates\\accueil.twig"); - } -} diff --git a/Website/cache/bb/bbf848822c23cc3555010da96607eefb8bf76bb5053c141d59fa798f5b57f2ba.php b/Website/cache/bb/bbf848822c23cc3555010da96607eefb8bf76bb5053c141d59fa798f5b57f2ba.php deleted file mode 100644 index 8167818..0000000 --- a/Website/cache/bb/bbf848822c23cc3555010da96607eefb8bf76bb5053c141d59fa798f5b57f2ba.php +++ /dev/null @@ -1,190 +0,0 @@ -source = $this->getSourceContext(); - - $this->parent = false; - - $this->blocks = [ - ]; - } - - protected function doDisplay(array $context, array $blocks = []) - { - $macros = $this->macros; - // line 1 - echo " - - - Maths Educ - - - - - - - - - -
-

Liste des questions

- -
-
- -
- D - Retour - G -
-
- - - -
-
-
-
-
Ajouter un chapitre
-
-
-
-
- - -
-
- - -
-
- - - Correct -
-
- - - Correct -
-
- - - Correct -
-
- - - Correct -
-
-
- - -
-
-
-
-
- - -"; - } - - public function getTemplateName() - { - return "adminQuestions.twig"; - } - - public function isTraitable() - { - return false; - } - - public function getDebugInfo() - { - return array ( 135 => 66, 124 => 64, 120 => 63, 90 => 35, 80 => 31, 76 => 30, 71 => 28, 68 => 27, 64 => 26, 37 => 1,); - } - - public function getSourceContext() - { - return new Source("", "adminQuestions.twig", "C:\\MAMP\\htdocs\\3.01-QCM_MuscuMaths\\Website\\templates\\adminQuestions.twig"); - } -} diff --git a/Website/models/Administrator.php b/Website/class/Administrator.php old mode 100755 new mode 100644 similarity index 100% rename from Website/models/Administrator.php rename to Website/class/Administrator.php diff --git a/Website/models/Answer.php b/Website/class/Answer.php old mode 100755 new mode 100644 similarity index 100% rename from Website/models/Answer.php rename to Website/class/Answer.php diff --git a/Website/models/Chapter.php b/Website/class/Chapter.php old mode 100755 new mode 100644 similarity index 100% rename from Website/models/Chapter.php rename to Website/class/Chapter.php diff --git a/Website/models/Lobby.php b/Website/class/Lobby.php old mode 100755 new mode 100644 similarity index 100% rename from Website/models/Lobby.php rename to Website/class/Lobby.php diff --git a/Website/models/Player.php b/Website/class/Player.php old mode 100755 new mode 100644 similarity index 100% rename from Website/models/Player.php rename to Website/class/Player.php diff --git a/Website/models/Question.php b/Website/class/Question.php old mode 100755 new mode 100644 similarity index 100% rename from Website/models/Question.php rename to Website/class/Question.php diff --git a/Website/controllers/ControllerAccueil.php b/Website/controllers/ControllerAccueil.php deleted file mode 100644 index e0dea2d..0000000 --- a/Website/controllers/ControllerAccueil.php +++ /dev/null @@ -1,43 +0,0 @@ -render($vues["accueil"]); - - /* - switch ($action) { - case "goToSolo": - require($vues['Solo']); - break; - case "goToMulti": - require($vues['Multi']); - break; - case "goToAdmin": - break; - default: - require($vues["Accueil"]); - break; - } - */ - } catch (PDOException $e) { - // $dataVueEreur[] = "Erreur inattendue!!! "; - // require(__DIR__.'/../vues/erreur.php'); - } catch (Exception $e2) { - // $dataVueEreur[] = "Erreur inattendue!!! "; - // require ($rep.$vues['erreur']); - } - } -} diff --git a/Website/controllers/ControllerAdminAdministrators.php b/Website/controllers/ControllerAdminAdministrators.php index d994571..1f6b0b3 100644 --- a/Website/controllers/ControllerAdminAdministrators.php +++ b/Website/controllers/ControllerAdminAdministrators.php @@ -2,7 +2,7 @@ class ControllerAdminAdministrators { - private $gatewayAdministrator; + private $mdAdministrator; private $twig; private $vues; @@ -17,11 +17,9 @@ class ControllerAdminAdministrators $this->twig =$twig; $this->vues = $vues; - $con = new Connection($dns, $user, $pass); + $this->mdAdministrator = new ModelAdministrator(); - $this->gatewayAdministrator = new GatewayAdministrator($con); - - $administrators = $this->gatewayAdministrator->getAdministrators(); + $administrators = $this->mdAdministrator->getAdministrators(); echo $twig->render($vues["adminAdministrators"], [ 'administrators' => $administrators, @@ -38,7 +36,7 @@ class ControllerAdminAdministrators } function delete($param) { - $this->gatewayAdministrator->deleteAdministratorByID($param["id"]); + $this->mdAdministrator->deleteAdministratorByID($param["id"]); header("Location:/admin/administrators"); } @@ -47,16 +45,19 @@ class ControllerAdminAdministrators $username = $_POST['username']; $password = $_POST['password']; - $Admin = new Administrator($username, $password); + $Admin = [ + 'username' => $username, + 'password' => $password, + ]; - $this->gatewayAdministrator->addAdministrator($Admin); + $this->mdAdministrator->addAdministrator($Admin); header("Location:/admin/administrators"); } function updatemodal($param) { - $administrator = $this->gatewayAdministrator->getAdministratorByID($param["id"]); + $administrator = $this->mdAdministrator->getAdministratorByID($param["id"]); echo $this->twig->render($this->vues["adminAdministratorsModal"], [ 'administrator' => $administrator, @@ -69,9 +70,12 @@ class ControllerAdminAdministrators $username = $_POST['username']; $password = $_POST['password']; - $Admin = new Administrator($username, $password); + $Admin = [ + 'username' => $username, + 'password' => $password, + ]; - $this->gatewayAdministrator->updateAdministrator($id,$Admin); + $this->mdAdministrator->updateAdministrator($id,$Admin); header("Location:/admin/administrators"); } diff --git a/Website/controllers/ControllerAdminChapters.php b/Website/controllers/ControllerAdminChapters.php index e4c99c9..43beeed 100644 --- a/Website/controllers/ControllerAdminChapters.php +++ b/Website/controllers/ControllerAdminChapters.php @@ -2,7 +2,7 @@ class ControllerAdminChapters { - private $gatewayChapter; + private $mdChapter; private $twig; private $vues; @@ -15,12 +15,10 @@ class ControllerAdminChapters if($_SESSION["idAdminConnected"] != null){ $this->twig =$twig; $this->vues = $vues; + + $this->mdChapter = new ModelChapter(); - $con = new Connection($dns, $user, $pass); - - $this->gatewayChapter = new GatewayChapter($con); - - $chapters = $this->gatewayChapter->getChapters(); + $chapters = $this->mdChapter->getChapters(); echo $twig->render($vues["adminChapters"], [ 'chapters' => $chapters, @@ -37,7 +35,7 @@ class ControllerAdminChapters } function delete($param) { - $this->gatewayChapter->deleteChapter($param["id"]); + $this->mdChapter->deleteChapter($param["id"]); header("Location:/admin/chapters"); } @@ -45,16 +43,18 @@ class ControllerAdminChapters $name = $_POST['name']; - $Chapter = new Chapter($name); + $Chapter = [ + 'name' => $name, + ]; - $this->gatewayChapter->addChapter($Chapter); + $this->mdChapter->addChapter($Chapter); header("Location:/admin/chapters"); } function updatemodal($param) { - $chapter = $this->gatewayChapter->getChapterByID($param["id"]); + $chapter = $this->mdChapter->getChapterByID($param["id"]); echo $this->twig->render($this->vues["adminChaptersModal"], [ 'chapter' => $chapter, @@ -66,9 +66,11 @@ class ControllerAdminChapters $id = $_POST['id']; $name = $_POST['name']; - $Chapter = new Chapter($name); + $Chapter = [ + 'name' => $name, + ]; - $this->gatewayChapter->updateChapter($id,$Chapter); + $this->mdChapter->updateChapter($id,$Chapter); header("Location:/admin/chapters"); } diff --git a/Website/controllers/ControllerAdminQuestions.php b/Website/controllers/ControllerAdminQuestions.php index 84fa36a..baf4193 100644 --- a/Website/controllers/ControllerAdminQuestions.php +++ b/Website/controllers/ControllerAdminQuestions.php @@ -2,9 +2,9 @@ class ControllerAdminQuestions { - private $gatewayQuestion; - private $gatewayChapter; - private $gatewayAnswer; + private $mdQuestion; + private $mdChapter; + private $mdAnswer; private $twig; private $vues; @@ -18,14 +18,12 @@ class ControllerAdminQuestions $this->twig =$twig; $this->vues = $vues; - $con = new Connection($dns, $user, $pass); + $this->mdQuestion = new ModelQuestion(); + $this->mdAnswer = new ModelAnswer(); + $this->mdChapter = new ModelChapter(); - $this->gatewayQuestion = new GatewayQuestion($con); - $this->gatewayAnswer = new GatewayAnswer($con); - $this->gatewayChapter = new GatewayChapter($con); - - $questions = $this->gatewayQuestion->getQuestions(); - $chapters = $this->gatewayChapter->getChapters(); + $questions = $this->mdQuestion->getQuestions(); + $chapters = $this->mdChapter->getChapters(); echo $twig->render($vues["adminQuestions"], [ 'questions' => $questions, @@ -43,7 +41,7 @@ class ControllerAdminQuestions } function delete($param) { - $this->gatewayQuestion->deleteQuestionByID($param["id"]); + $this->mdQuestion->deleteQuestionByID($param["id"]); header("Location:/admin/questions"); } @@ -51,43 +49,55 @@ class ControllerAdminQuestions $content = $_POST['content']; $idChapter = intval($_POST['idChapter']); $AnswersPost = array(); - $AnswersPost[1] = $_POST['answer1']; - $AnswersPost[2] = $_POST['answer2']; - $AnswersPost[3] = $_POST['answer3']; - $AnswersPost[4] = $_POST['answer4']; + $AnswersPost[0] = $_POST['answer1']; + $AnswersPost[1] = $_POST['answer2']; + $AnswersPost[2] = $_POST['answer3']; + $AnswersPost[3] = $_POST['answer4']; $correctAnswer = intval($_POST['correctAnswer']); - $Question = new Question($content,$idChapter); + $Question = [ + 'content' => $content, + 'idchapter' => $idChapter, + 'difficulty' => 1, + 'nbfails' => 0, + ]; + + $idquestion = intval($this->mdQuestion->addQuestion($Question)); - $questionId = intval($this->gatewayQuestion->addQuestion($Question)); + for ($i = 0; $i <= 3; $i++) { + $Answers[] = [ + 'content' => $AnswersPost[$i], + 'idquestion' => $idquestion, + ]; + } - $Answers = array(); - $Answer[1] = new Answer($AnswersPost[1],$questionId); - $Answer[2] = new Answer($AnswersPost[2],$questionId); - $Answer[3] = new Answer($AnswersPost[3],$questionId); - $Answer[4] = new Answer($AnswersPost[4],$questionId); $answersId = array(); - $answersId[1] = $this->gatewayAnswer->addAnswer($Answer[1]); - $answersId[2] = $this->gatewayAnswer->addAnswer($Answer[2]); - $answersId[3] = $this->gatewayAnswer->addAnswer($Answer[3]); - $answersId[4] = $this->gatewayAnswer->addAnswer($Answer[4]); + for ($i = 0; $i <= 3; $i++) { + $answersId[$i] = $this->mdAnswer->addAnswer($Answers[$i]); + } - $Question = new Question($content,$idChapter,$answersId[$correctAnswer]); + $Question = [ + 'content' => $content, + 'idchapter' => $idChapter, + 'difficulty' => 1, + 'nbfails' => 0, + 'idanswergood' => $answersId[$correctAnswer], + ]; - $this->gatewayQuestion->updateQuestion($questionId,$Question); + $this->mdQuestion->updateQuestion($idquestion,$Question); header("Location:/admin/questions"); } function updatemodal($param) { - $question = $this->gatewayQuestion->getQuestionByID($param["id"]); + $question = $this->mdQuestion->getQuestionByID($param["id"]); $answers = array(); - $answers = $this->gatewayAnswer->getAnswersByIDQuestions($param["id"]); + $answers = $this->mdAnswer->getAnswersByIDQuestions($param["id"]); - $chapters = $this->gatewayChapter->getChapters(); + $chapters = $this->mdChapter->getChapters(); echo $this->twig->render($this->vues["adminQuestionsModal"], [ 'question' => $question, @@ -105,31 +115,36 @@ class ControllerAdminQuestions $correctAnswer = intval($_POST['correctAnswer']); $answersId = array(); - $answersId[1] = intval($_POST['IdAnswer1']); - $answersId[2] = intval($_POST['IdAnswer2']); - $answersId[3] = intval($_POST['IdAnswer3']); - $answersId[4] = intval($_POST['IdAnswer4']); + $answersId[0] = intval($_POST['IdAnswer1']); + $answersId[1] = intval($_POST['IdAnswer2']); + $answersId[2] = intval($_POST['IdAnswer3']); + $answersId[3] = intval($_POST['IdAnswer4']); $answers = array(); - $answers[1] = $_POST['answer1']; - $answers[2] = $_POST['answer2']; - $answers[3] = $_POST['answer3']; - $answers[4] = $_POST['answer4']; - - $Question = new Question($content, $idChapter, $answersId[$correctAnswer]); - - $this->gatewayQuestion->updateQuestion($id, $Question); - - $Answer1 = new Answer($answers[1],$id); - $Answer2 = new Answer($answers[2],$id); - $Answer3 = new Answer($answers[3],$id); - $Answer4 = new Answer($answers[4],$id); + $answers[0] = $_POST['answer1']; + $answers[1] = $_POST['answer2']; + $answers[2] = $_POST['answer3']; + $answers[3] = $_POST['answer4']; + + $Question = [ + 'content' => $content, + 'idchapter' => $idChapter, + 'idanswergood' => $answersId[$correctAnswer], + ]; + + $this->mdQuestion->updateQuestion($id, $Question); + + for ($i = 0; $i <= 3; $i++) { + $Answers[] = [ + 'content' => $answers[$i], + 'id' => $id, + ]; + } - $this->gatewayAnswer->updateAnswer($answersId[1],$Answer1); - $this->gatewayAnswer->updateAnswer($answersId[2],$Answer2); - $this->gatewayAnswer->updateAnswer($answersId[3],$Answer3); - $this->gatewayAnswer->updateAnswer($answersId[4],$Answer4); + for ($i = 0; $i <= 3; $i++) { + $this->mdAnswer->updateAnswer($answersId[$i],$Answers[$i]); + } header("Location:/admin/questions"); } -} +} \ No newline at end of file diff --git a/Website/controllers/ControllerLoginAdmin.php b/Website/controllers/ControllerLoginAdmin.php deleted file mode 100644 index ec0dcc2..0000000 --- a/Website/controllers/ControllerLoginAdmin.php +++ /dev/null @@ -1,48 +0,0 @@ -gatewayAdministrator = new GatewayAdministrator($con); - - echo $twig->render($vues["loginAdmin"], [ - 'error' => $_SESSION["error"], - ]); - - $_SESSION["error"]=""; - - } catch (PDOException $e) { - // $dataVueEreur[] = "Erreur inattendue!!! "; - // require(__DIR__.'/../vues/erreur.php'); - } catch (Exception $e2) { - // $dataVueEreur[] = "Erreur inattendue!!! "; - // require ($rep.$vues['erreur']); - } - } - - function verify(){ - $username = $_POST['username']; - $password = $_POST['password']; - - $Administrator = new Administrator($username, $password); - - $AdministratorIsOk = $this->gatewayAdministrator->verifyAdministrator($Administrator); - if($AdministratorIsOk != null) { - $_SESSION["idAdminConnected"]=$AdministratorIsOk; - header("Location:/admin/administrators"); - } - else { - $_SESSION["error"]="utilisateur introuvable."; - header("Location:/login"); - } - } -} diff --git a/Website/controllers/ControllerMulti.php b/Website/controllers/ControllerMulti.php deleted file mode 100644 index ae30c9e..0000000 --- a/Website/controllers/ControllerMulti.php +++ /dev/null @@ -1,43 +0,0 @@ -render($vues["multi"]); - - /* - $action = ""; - if (isset($_REQUEST['action'])) { - $action = $_REQUEST['action']; - } - - switch ($action) { - case "goToLobby": - //require($vues['Solo']); - break; - case "CreateLobby": - //require($vues['Multi']); - break; - case "goToAcceuil": - require($vues['Accueil']); - break; - default: - require($vues['Multi']); - break; - } - */ - } catch (PDOException $e) { - // $dataVueEreur[] = "Erreur inattendue!!! "; - // require(__DIR__.'/../vues/erreur.php'); - } catch (Exception $e2) { - // $dataVueEreur[] = "Erreur inattendue!!! "; - // require ($rep.$vues['erreur']); - } - } -} diff --git a/Website/controllers/ControllerSolo.php b/Website/controllers/ControllerSolo.php deleted file mode 100644 index 7c84657..0000000 --- a/Website/controllers/ControllerSolo.php +++ /dev/null @@ -1,42 +0,0 @@ -render($vues["solo"]); - - /* - $action = ""; - if (isset($_REQUEST['action'])) { - $action = $_REQUEST['action']; - } - - switch ($action) { - case "goToLobby": - //require($vues['Solo']); - break; - case "CreateLobby": - //require($vues['Multi']); - break; - case "goToAcceuil": - require($vues['Accueil']); - break; - default: - break; - } - */ - } catch (PDOException $e) { - // $dataVueEreur[] = "Erreur inattendue!!! "; - // require(__DIR__.'/../vues/erreur.php'); - } catch (Exception $e2) { - // $dataVueEreur[] = "Erreur inattendue!!! "; - // require ($rep.$vues['erreur']); - } - } -} diff --git a/Website/controllers/ControllerUser.php b/Website/controllers/ControllerUser.php new file mode 100644 index 0000000..bbfa92a --- /dev/null +++ b/Website/controllers/ControllerUser.php @@ -0,0 +1,85 @@ +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() + { + var_dump('tot'); + echo $this->twig->render($this->vues["home"]); + } + + 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); + var_dump($AdministratorIsOk); + if($AdministratorIsOk != null) { + $_SESSION["idAdminConnected"]=$AdministratorIsOk; + header("Location:/admin/administrators"); + } + else { + $_SESSION["error"]="utilisateur introuvable."; + header("Location:/login"); + } + } +} diff --git a/Website/controllers/FrontController.php b/Website/controllers/FrontController.php index a5f94cd..46e6140 100755 --- a/Website/controllers/FrontController.php +++ b/Website/controllers/FrontController.php @@ -30,26 +30,18 @@ class FrontController function __construct() { global $dsn, $user, $pass, $vues; - $listeAction_Acceuil = array('goToSolo', 'goToMulti', 'goToAdmin'); try { - $action = ""; - if (isset($_REQUEST['action'])) { - $action = $_REQUEST['action']; - } - // Initialize AltoRouter $router = new AltoRouter(); //$router->setBasePath('/'); // Define routes - $router->map('GET', '/', 'ControllerAccueil'); // Route pour la page d'accueil - $router->map('GET', '/solo', 'ControllerSolo'); - $router->map('GET', '/multi', 'ControllerMulti'); - $router->map('GET', '/admin', 'ControllerAdminAdministrators'); - $router->map('GET', '/login', 'ControllerLoginAdmin'); - $router->map('POST', '/login/[a:action]', 'ControllerLoginAdmin'); + $router->map('GET', '/', 'ControllerUser#home'); // Route pour la page d'accueil + $router->map('GET', '/[a:action]', 'ControllerUser'); + //$router->map('GET', '/admin', 'ControllerAdminAdministrators'); + $router->map('POST', '/login/[a:action]', 'ControllerUser'); $router->map('GET', '/admin/chapters', 'ControllerAdminChapters'); $router->map('POST', '/admin/chapters/[a:action]', 'ControllerAdminChapters'); $router->map('GET', '/admin/chapters/[a:action]/[i:id]', 'ControllerAdminChapters'); @@ -71,12 +63,15 @@ class FrontController if ($match) { $controller = $match['target']; - $action=$match['params']['action']; - $id=$match['params']['id']; - + if (strpos($controller, "#") !== false) { + list($controller,$action)=explode("#",$controller); + } + else { + $action=$match['params']['action']; + $id=$match['params']['id']; + } $controller = new $controller; - - if (is_callable(array($controller, $action))) { + if (is_callable(array($controller, $action))) { call_user_func_array(array($controller, $action), array($match['params'])); } } diff --git a/Website/gateways/GatewayAdministrator.php b/Website/gateways/GatewayAdministrator.php index cc78368..6fa15eb 100755 --- a/Website/gateways/GatewayAdministrator.php +++ b/Website/gateways/GatewayAdministrator.php @@ -4,9 +4,10 @@ class GatewayAdministrator { private $con; - public function __construct($con) + public function __construct() { - $this->con = $con; + global $dns, $user, $pass; + $this->con = new Connection($dns, $user, $pass); } public function addAdministrator($administrator) @@ -15,8 +16,8 @@ class GatewayAdministrator $this->con->executeQuery( $query, array( - ':username' => array($administrator->getUsername(), PDO::PARAM_STR), - ':password' => array($administrator->getHashedPassword(), PDO::PARAM_STR) + ':username' => array($administrator['username'], PDO::PARAM_STR), + ':password' => array(md5($administrator['password']), PDO::PARAM_STR) ) ); } @@ -57,8 +58,8 @@ class GatewayAdministrator $query, array( ':id' => array($id, PDO::PARAM_INT), - ':username' => array($administrator->getUsername(), PDO::PARAM_STR), - ':password' => array($administrator->getHashedPassword(), PDO::PARAM_STR) + ':username' => array($administrator['username'], PDO::PARAM_STR), + ':password' => array(md5($administrator['password']), PDO::PARAM_STR) ) ); } @@ -75,8 +76,8 @@ class GatewayAdministrator $this->con->executeQuery( $query, array( - ':username' => array($administrator->getUsername(), PDO::PARAM_STR), - ':password' => array($administrator->getHashedPassword(), PDO::PARAM_STR) + ':username' => array($administrator['username'], PDO::PARAM_STR), + ':password' => array(md5($administrator['password']), PDO::PARAM_STR) ) ); $results = $this->con->getResults(); diff --git a/Website/gateways/GatewayAnswer.php b/Website/gateways/GatewayAnswer.php index 3ffeeab..37cac35 100755 --- a/Website/gateways/GatewayAnswer.php +++ b/Website/gateways/GatewayAnswer.php @@ -4,9 +4,10 @@ class GatewayAnswer { private $con; - public function __construct($con) + public function __construct() { - $this->con = $con; + global $dns, $user, $pass; + $this->con = new Connection($dns, $user, $pass); } public function addAnswer($answer) @@ -15,8 +16,8 @@ class GatewayAnswer $this->con->executeQuery( $query, array( - ':content' => array($answer->getContent(), PDO::PARAM_STR), - ':idquestion' => array($answer->getIdQuestion(), PDO::PARAM_INT), + ':content' => array($answer['content'], PDO::PARAM_STR), + ':idquestion' => array($answer['idquestion'], PDO::PARAM_INT), ) ); $answerId = $this->con->lastInsertId(); @@ -44,7 +45,7 @@ class GatewayAnswer $query, array( ':id' => array($id, PDO::PARAM_INT), - ':content' => array($answer->getContent(), PDO::PARAM_STR) + ':content' => array($answer['content'], PDO::PARAM_STR) ) ); } diff --git a/Website/gateways/GatewayChapter.php b/Website/gateways/GatewayChapter.php index 545fabc..ffc3e7a 100755 --- a/Website/gateways/GatewayChapter.php +++ b/Website/gateways/GatewayChapter.php @@ -4,9 +4,10 @@ class GatewayChapter { private $con; - public function __construct($con) + public function __construct() { - $this->con = $con; + global $dns, $user, $pass; + $this->con = new Connection($dns, $user, $pass); } public function addChapter($chapter) @@ -15,7 +16,7 @@ class GatewayChapter $this->con->executeQuery( $query, array( - ':name' => array($chapter->getName(), PDO::PARAM_STR) + ':name' => array($chapter['name'], PDO::PARAM_STR) ) ); } @@ -45,7 +46,7 @@ class GatewayChapter $query, array( ':id' => array($id, PDO::PARAM_INT), - ':name' => array($chapter->getName(), PDO::PARAM_STR) + ':name' => array($chapter['name'], PDO::PARAM_STR) ) ); } diff --git a/Website/gateways/GatewayLobby.php b/Website/gateways/GatewayLobby.php index 82a3f12..d54eef0 100755 --- a/Website/gateways/GatewayLobby.php +++ b/Website/gateways/GatewayLobby.php @@ -4,14 +4,15 @@ class GatewayLobby { private $con; - public function __construct($con) + public function __construct() { - $this->con = $con; + global $dns, $user, $pass; + $this->con = new Connection($dns, $user, $pass); } public function addLobby($lobby) { - $query = "insert into Lobby(id,name,password,nbPlayer) values (:id,:name,:password,:nbPlayer);"; + $query = "insert into Lobbies(id,name,password,nbPlayer) values (:id,:name,:password,:nbPlayer);"; $this->con->executeQuery( $query, array( @@ -25,7 +26,7 @@ class GatewayLobby public function getLobbys() { - $query = "SELECT * FROM Lobby;"; + $query = "SELECT * FROM Lobbies;"; $this->con->executeQuery($query); $results = $this->con->getResults(); if ($results == NULL) { @@ -40,7 +41,7 @@ class GatewayLobby public function getLobbyByName($name) { - $query = "SELECT * FROM Lobby WHERE name = :name;"; + $query = "SELECT * FROM Lobbies WHERE name = :name;"; $this->con->executeQuery($query, array(':name' => array($name, PDO::PARAM_STR))); $results = $this->con->getResults(); if ($results == NULL) { @@ -52,7 +53,7 @@ class GatewayLobby public function deleteLobby($id) { - $query = "DELETE FROM Lobby WHERE id = :id;"; + $query = "DELETE FROM Lobbies WHERE id = :id;"; $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); } diff --git a/Website/gateways/GatewayPlayer.php b/Website/gateways/GatewayPlayer.php index a5f8d44..57a61cb 100755 --- a/Website/gateways/GatewayPlayer.php +++ b/Website/gateways/GatewayPlayer.php @@ -4,9 +4,10 @@ class GatewayPlayer { private $con; - public function __construct($con) + public function __construct() { - $this->con = $con; + global $dns, $user, $pass; + $this->con = new Connection($dns, $user, $pass); } public function addPlayer($player) @@ -16,8 +17,8 @@ class GatewayPlayer $query, array( ':id' => array($player->getId(), PDO::PARAM_INT), - ':nickname' => array($player->getNickname(), PDO::PARAM_STR), - ':hashedPassword' => array($player->getHashedPassword(), PDO::PARAM_STR) + ':nickname' => array($player['nickname'], PDO::PARAM_STR), + ':hashedPassword' => array($player['hashedPassword'], PDO::PARAM_STR) ) ); } @@ -60,8 +61,8 @@ class GatewayPlayer $query, array( ':id' => array($player->getId(), PDO::PARAM_INT), - ':nickname' => array($player->getNickname(), PDO::PARAM_STR), - ':hashedPassword' => array($player->getHashedPassword(), PDO::PARAM_STR) + ':nickname' => array($player['nickname'], PDO::PARAM_STR), + ':hashedPassword' => array($player['hashedPassword'], PDO::PARAM_STR) ) ); } @@ -83,8 +84,8 @@ class GatewayPlayer $this->con->executeQuery( $query, array( - ':nickname' => array($player->getUsername(), PDO::PARAM_STR), - ':password' => array($player->getHashedPassword(), PDO::PARAM_STR) + ':nickname' => array($player['nickname'], PDO::PARAM_STR), + ':password' => array($player['password'], PDO::PARAM_STR) ) ); $results = $this->con->getResults(); diff --git a/Website/gateways/GatewayQuestion.php b/Website/gateways/GatewayQuestion.php index 86a68f2..4754373 100755 --- a/Website/gateways/GatewayQuestion.php +++ b/Website/gateways/GatewayQuestion.php @@ -4,21 +4,23 @@ class GatewayQuestion { private $con; - public function __construct($con) + public function __construct() { - $this->con = $con; + global $dns, $user, $pass; + $this->con = new Connection($dns, $user, $pass); } public function addQuestion($question) { + var_dump($question); $query = "insert into questions(content,idchapter,difficulty,nbfails) values (:content,:idchapter,:difficulty,:nbfails);"; $this->con->executeQuery( $query, array( - ':content' => array($question->getContent(), PDO::PARAM_STR), - ':idchapter' => array($question->getIdChapter(), PDO::PARAM_INT), - ':difficulty' => array($question->getDifficulty(), PDO::PARAM_INT), - ':nbfails' => array($question->getNbFails(), PDO::PARAM_INT) + ':content' => array($question['content'], PDO::PARAM_STR), + ':idchapter' => array($question['idchapter'], PDO::PARAM_INT), + ':difficulty' => array(intval($question['difficulty']), PDO::PARAM_INT), + ':nbfails' => array(intval($question['nbfails']), PDO::PARAM_INT) ) ); $questionId = $this->con->lastInsertId(); @@ -45,15 +47,13 @@ class GatewayQuestion public function updateQuestion($id,$question) { - $query = "UPDATE questions SET content = :content, idchapter = :idchapter, idanswergood = :idanswergood, difficulty = :difficulty, nbfails = :nbfails WHERE id = :id;"; + $query = "UPDATE questions SET content = :content, idchapter = :idchapter, idanswergood = :idanswergood WHERE id = :id;"; $this->con->executeQuery( $query, array( - ':content' => array($question->getContent(), PDO::PARAM_STR), - ':idchapter' => array($question->getIdChapter(), PDO::PARAM_INT), - ':idanswergood' => array($question->getIdAnswerGood(), PDO::PARAM_INT), - ':difficulty' => array($question->getDifficulty(), PDO::PARAM_INT), - ':nbfails' => array($question->getNbFails(), PDO::PARAM_INT), + ':content' => array($question['content'], PDO::PARAM_STR), + ':idchapter' => array($question['idchapter'], PDO::PARAM_INT), + ':idanswergood' => array($question['idanswergood'], PDO::PARAM_INT), ':id' => array($id, PDO::PARAM_INT), ) ); diff --git a/Website/index.php b/Website/index.php index 711ec86..76806ae 100755 --- a/Website/index.php +++ b/Website/index.php @@ -13,8 +13,7 @@ Autoload::charger(); //twig $loader = new \Twig\Loader\FilesystemLoader('templates'); $twig = new \Twig\Environment($loader, [ - 'cache' => 'cache', - 'auto_reload' => true, + 'cache' => false, ]); $controller = new FrontController(); diff --git a/Website/models/ModelAdministrator.php b/Website/models/ModelAdministrator.php new file mode 100644 index 0000000..d4f16e8 --- /dev/null +++ b/Website/models/ModelAdministrator.php @@ -0,0 +1,44 @@ +gwAdministrator = new GatewayAdministrator(); + } + + public function addAdministrator($administrator) + { + $this->gwAdministrator->addAdministrator($administrator); + } + + public function getAdministratorByID($id) + { + $administrator = $this->gwAdministrator->getAdministratorByID($id); + return $administrator; + } + + public function getAdministrators() + { + $administrators = $this->gwAdministrator->getAdministrators(); + return $administrators; + } + + public function updateAdministrator($id,$administrator) + { + $this->gwAdministrator->updateAdministrator($id,$administrator); + } + + public function deleteAdministratorByID($id) + { + $this->gwAdministrator->deleteAdministratorByID($id); + } + + public function verifyAdministrator($Administrator) + { + $administratorsId = $this->gwAdministrator->verifyAdministrator($Administrator); + return $administratorsId; + } +} diff --git a/Website/models/ModelAnswer.php b/Website/models/ModelAnswer.php new file mode 100644 index 0000000..bdbe908 --- /dev/null +++ b/Website/models/ModelAnswer.php @@ -0,0 +1,28 @@ +gwAnswer = new GatewayAnswer(); + } + + function addAnswer($answer) + { + $answersId = $this->gwAnswer->addAnswer($answer); + return $answersId; + } + + function getAnswersByIDQuestions($id) + { + $answers = $this->gwAnswer->getAnswersByIDQuestions($id); + return $answers; + } + + function updateAnswer($answersId,$answer) + { + $this->gwAnswer->updateAnswer($answersId,$answer); + } +} diff --git a/Website/models/ModelChapter.php b/Website/models/ModelChapter.php new file mode 100644 index 0000000..24697af --- /dev/null +++ b/Website/models/ModelChapter.php @@ -0,0 +1,38 @@ +gwChapter = new GatewayChapter(); + } + + function getChapters() + { + $chapters = $this->gwChapter->getChapters(); + return $chapters; + } + + function deleteChapter($id) + { + $this->gwChapter->deleteChapter($id); + } + + function addChapter($chapter) + { + $this->gwChapter->addChapter($chapter); + } + + function getChapterByID($id) + { + $chapter = $this->gwChapter->getChapterByID($id); + return $chapter; + } + + function updateChapter($id,$Chapter) + { + $this->gwChapter->updateChapter($id,$Chapter); + } +} diff --git a/Website/models/ModelLobby.php b/Website/models/ModelLobby.php new file mode 100644 index 0000000..46202fc --- /dev/null +++ b/Website/models/ModelLobby.php @@ -0,0 +1,22 @@ +gwLobby = new GatewayLobby(); + } + + public function addLobby($lobby) + { + $this->gwLobby->addLobby($lobby); + } + + public function getlobbies() + { + $lobbies = $this->gwLobby->getlobbies(); + return $lobbies; + } +} diff --git a/Website/models/ModelPlayer.php b/Website/models/ModelPlayer.php new file mode 100644 index 0000000..e8ac028 --- /dev/null +++ b/Website/models/ModelPlayer.php @@ -0,0 +1,32 @@ +gwPlayer = new GatewayPlayer(); + } + + public function addPlayer($player) + { + $this->gwPlayer->addPlayer($player); + } + + public function getPlayerByID($id) + { + $player = $this->gwPlayer->getPlayerByID($id); + return $player; + } + + public function updatePlayer($id,$player) + { + $this->gwPlayer->updatePlayer($id,$player); + } + + public function deletePlayerByID($id) + { + $this->gwPlayer->deletePlayerByID($id); + } +} diff --git a/Website/models/ModelQuestion.php b/Website/models/ModelQuestion.php new file mode 100644 index 0000000..ae1cff3 --- /dev/null +++ b/Website/models/ModelQuestion.php @@ -0,0 +1,39 @@ +gwQuestion = new GatewayQuestion(); + } + + function getQuestions() + { + $questions = $this->gwQuestion->getQuestions(); + return $questions; + } + + function deleteQuestionByID($id) + { + $this->gwQuestion->deleteQuestionByID($id); + } + + function addQuestion($Question) + { + $questionId = $this->gwQuestion->addQuestion($Question); + return $questionId; + } + + function getQuestionByID($id) { + + $question = $this->gwQuestion->getQuestionByID($id); + return $question; + } + + function updateQuestion($id, $Question) + { + $this->gwQuestion->updateQuestion($id, $Question); + } +} diff --git a/Website/templates/adminAdministrators.twig b/Website/templates/adminAdministrators.twig index e4288d0..8573692 100644 --- a/Website/templates/adminAdministrators.twig +++ b/Website/templates/adminAdministrators.twig @@ -27,9 +27,9 @@
diff --git a/Website/templates/adminChapters.twig b/Website/templates/adminChapters.twig index 013d936..34b8e7a 100644 --- a/Website/templates/adminChapters.twig +++ b/Website/templates/adminChapters.twig @@ -27,9 +27,9 @@
diff --git a/Website/templates/adminQuestions.twig b/Website/templates/adminQuestions.twig index 9afa012..f634257 100644 --- a/Website/templates/adminQuestions.twig +++ b/Website/templates/adminQuestions.twig @@ -27,9 +27,9 @@
@@ -39,7 +39,7 @@