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/controller/VisitorController.php b/Project/php/controller/VisitorController.php index 8d5da49..a4d0d61 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 fc113be..659e12e 100755 --- a/Project/php/model/MdlStudent.php +++ b/Project/php/model/MdlStudent.php @@ -19,6 +19,16 @@ class MdlStudent extends MdlUser return $res; } + public function getVocByGroup(int $group): array{ + $gtw = new VocabularyListGateway(); + 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{