From 6b01bcf4a1424e02a598b9d355fa4d31b533f48d Mon Sep 17 00:00:00 2001 From: "anthony.richard" Date: Tue, 21 Nov 2023 11:35:04 +0100 Subject: [PATCH] vocablist --- Project/php/controller/StudentController.php | 26 ------------------- Project/php/controller/TeacherController.php | 26 ++----------------- Project/php/model/MdlTeacher.php | 6 +++++ Project/php/templates/groupContainer.twig | 16 ++++++++++++ .../php/templates/manageVocabListView.html | 17 ++++++++++-- 5 files changed, 39 insertions(+), 52 deletions(-) diff --git a/Project/php/controller/StudentController.php b/Project/php/controller/StudentController.php index 1e716d7..30f09bb 100755 --- a/Project/php/controller/StudentController.php +++ b/Project/php/controller/StudentController.php @@ -8,31 +8,5 @@ use Exception; class StudentController extends UserController { - public function affAllVocab(): void - { - global $twig; - $mdl = new MdlStudent(); - $voc = $mdl->getAll(); - echo $twig->render('manageVocabListView.html', ['vocabularies' => $voc]); - } - - - public function affAllStudent(): void - { - global $twig; - $mdl = new MdlStudent(); - $student = $mdl->getAll(); - echo $twig->render('usersView.html', ['users' => $student]); - - } - - public function getByName(): void - { - global $twig; - $mdl = new MdlStudent(); - $name = Validation::filter_str_simple($_GET['listName'] ?? null); - $vocab = $mdl->getVocabByName($name); - echo $twig->render('manageVocabView.html', ['vocabularies' => $vocab]); - } } \ No newline at end of file diff --git a/Project/php/controller/TeacherController.php b/Project/php/controller/TeacherController.php index 95244c1..729f6e3 100755 --- a/Project/php/controller/TeacherController.php +++ b/Project/php/controller/TeacherController.php @@ -9,36 +9,14 @@ use model\MdlUser; class TeacherController extends UserController { - public function affAllStudent(): void - { - global $twig; - global $user; - $mdl = new MdlTeacher(); - $student = $mdl->getAllStudent(); - echo $twig->render('usersView.html', ['users' => $student, 'userID' => $user->getId(), 'userRole' => $user->getRoles()]); - - } - public function affAllVocab(): void { global $twig; global $user; - $id = $user->getId(); $mdl = new MdlTeacher(); $vocabularies = $mdl->getAll(); - echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocabularies, 'userID' => $user->getId(), 'userRole' => $user->getRoles()]); - } - - public function getByName(): void - { - global $twig; - global $user; - $mdl = new MdlTeacher(); - $id = $user->getId(); - $name = Validation::filter_str_simple($_GET['listName'] ?? null); - $vocab = $mdl->getVocabByName($name); - echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocab, 'selectedName' => $name, 'userID' => $user->getId(), 'userRole' => $user->getRoles() ]); - + $groups = $mdl->getAllGroups(); + echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocabularies, 'groups' => $groups, 'userID' => $user->getId(), 'userRole' => $user->getRoles()]); } public function DelById():void{ diff --git a/Project/php/model/MdlTeacher.php b/Project/php/model/MdlTeacher.php index dd0d273..786f8d6 100755 --- a/Project/php/model/MdlTeacher.php +++ b/Project/php/model/MdlTeacher.php @@ -2,6 +2,7 @@ namespace model; +use gateway\GroupGateway; use gateway\TranslationGateway; use gateway\UserGateway; use gateway\VocabularyGateway; @@ -14,6 +15,11 @@ class MdlTeacher extends MdlUser return $gtw->findAll(); } + public function getAllGroups(): array { + $gtw = new GroupGateway(); + return $gtw->findAll(); + } + public function getAllStudent():array { $gtw = new UserGateway(); return $gtw->findAll(); diff --git a/Project/php/templates/groupContainer.twig b/Project/php/templates/groupContainer.twig index 411f51a..45cb379 100755 --- a/Project/php/templates/groupContainer.twig +++ b/Project/php/templates/groupContainer.twig @@ -35,6 +35,22 @@ {% endif %} + {% if 'removeVocabFromGroup' in actions %} + + + + + + {% endif %} + + {% if 'addVocabToGroup' in actions %} + + + + + + {% endif %} + {% endif %} {% endfor %} diff --git a/Project/php/templates/manageVocabListView.html b/Project/php/templates/manageVocabListView.html index c46d76c..ec80ecf 100755 --- a/Project/php/templates/manageVocabListView.html +++ b/Project/php/templates/manageVocabListView.html @@ -34,12 +34,25 @@

Content

{% if content is defined %} + + + + + + {% for trad in content %} + + + + + {% endfor %} +
French wordEnglish word
trad.word1trad.word2
{% endif %} - //for ou ça affiche chaque traduction french - english [remove]

Groups

- //la liste des groupes [ajouter] ou [retirer] + {% if groups is defined %} + {% include 'groupContainer.twig' with {'actions' : ['addVocabToGroup', 'removeVocabFromGroup'] } %} + {% endif %}