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{