From 638b7e9acac2dd8d2af91fcb2846002771df5882 Mon Sep 17 00:00:00 2001 From: "anthony.richard" Date: Mon, 27 Nov 2023 16:19:15 +0100 Subject: [PATCH 1/2] =?UTF-8?q?fix=20student=20qui=20a=20acc=C3=A8s=20?= =?UTF-8?q?=C3=A0=20toutes=20les=20listes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/php/controller/StudentController.php | 2 +- Project/php/model/MdlStudent.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Project/php/controller/StudentController.php b/Project/php/controller/StudentController.php index e6efe62..e79c5b6 100755 --- a/Project/php/controller/StudentController.php +++ b/Project/php/controller/StudentController.php @@ -22,7 +22,7 @@ class StudentController extends UserController global $user; $jeu = $_POST['jeu']; $model = new MdlStudent(); - $voc = $model->getAll(); + $voc = $model->getVocByGroup($user->getGroup()); echo $twig->render('vocabList.html', ['jeu' => $jeu, 'vocabularies' => $voc, 'userID' => $user->getId(), 'userRole' => $user->getRoles()]); } diff --git a/Project/php/model/MdlStudent.php b/Project/php/model/MdlStudent.php index fc113be..fef1550 100755 --- a/Project/php/model/MdlStudent.php +++ b/Project/php/model/MdlStudent.php @@ -19,6 +19,11 @@ class MdlStudent extends MdlUser return $res; } + public function getVocByGroup(int $group): array{ + $gtw = new VocabularyListGateway(); + return $gtw->findByGroup($group); + } + public function is(string $login, array $roles): ?User { $gtw = new UserGateway(); From 083cdb1f435ae6db72f05575e088e2abfa0c3768 Mon Sep 17 00:00:00 2001 From: "anthony.richard" Date: Mon, 27 Nov 2023 16:37:14 +0100 Subject: [PATCH 2/2] fix appel gateway dans les controllers --- Project/php/controller/VisitorController.php | 8 ++++---- Project/php/model/MdlStudent.php | 5 +++++ Project/php/model/MdlTeacher.php | 13 +------------ 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/Project/php/controller/VisitorController.php b/Project/php/controller/VisitorController.php index b6c646a..505b195 100755 --- a/Project/php/controller/VisitorController.php +++ b/Project/php/controller/VisitorController.php @@ -5,7 +5,8 @@ namespace controller; use config\Validation; use gateway\TranslationGateway; use gateway\VocabularyListGateway; -use http\Message; +use model\MdlStudent; +use model\MdlTeacher; use model\MdlUser; use Exception; @@ -17,11 +18,10 @@ class VisitorController try{ $idVoc = Validation::filter_int($_POST['idVoc'] ?? 4); - $wordList = (new \gateway\TranslationGateway())->findByIdVoc($idVoc); - $name = ((new \gateway\VocabularyListGateway())->findById($idVoc))->getName(); + $wordList = (new MdlTeacher())->findByIdVoc($idVoc); + $name = ((new MdlStudent())->getVocabById($idVoc))->getName(); $wordShuffle = array(); - shuffle($wordList); $pairs = []; $maxWords = 28; diff --git a/Project/php/model/MdlStudent.php b/Project/php/model/MdlStudent.php index fef1550..659e12e 100755 --- a/Project/php/model/MdlStudent.php +++ b/Project/php/model/MdlStudent.php @@ -24,6 +24,11 @@ class MdlStudent extends MdlUser return $gtw->findByGroup($group); } + public function getVocabById(int $id): VocabularyList { + $gtw = new VocabularyListGateway(); + return $gtw->findById($id); + } + public function is(string $login, array $roles): ?User { $gtw = new UserGateway(); diff --git a/Project/php/model/MdlTeacher.php b/Project/php/model/MdlTeacher.php index 2ca23cc..661afda 100755 --- a/Project/php/model/MdlTeacher.php +++ b/Project/php/model/MdlTeacher.php @@ -20,26 +20,15 @@ class MdlTeacher extends MdlUser return $gtw->findAll(); } - public function getAllStudent():array { - $gtw = new UserGateway(); - return $gtw->findAll(); - } public function findByUser($id):array { $gtw = new VocabularyListGateway(); return $gtw->findByUser($id); - } - - - public function getVocabByName(string $name):array{ - $gtw = new VocabularyListGateway(); - $res = $gtw->findByName($name); - return $res; } + public function findByIdVoc($id):array { $gtw = new TranslationGateway(); return $gtw->findByIdVoc($id); - } public function removeVocabFromGroup(int $vocabID, int $groupID): void{