From ef6b71e19be203af80e3245c799c42bf65a0d3f0 Mon Sep 17 00:00:00 2001 From: "patrick.brugiere" Date: Wed, 15 Nov 2023 15:30:17 +0100 Subject: [PATCH] travail sur la vue pour teacher --- Project/php/controller/FrontController.php | 3 ++ Project/php/controller/TeacherController.php | 27 +++++++++++++---- Project/php/model/MdlTeacher.php | 21 +++++++++---- .../php/templates/manageVocabListView.html | 30 +++++++++++++++++++ 4 files changed, 70 insertions(+), 11 deletions(-) create mode 100755 Project/php/templates/manageVocabListView.html diff --git a/Project/php/controller/FrontController.php b/Project/php/controller/FrontController.php index bfedbdb..1804d12 100755 --- a/Project/php/controller/FrontController.php +++ b/Project/php/controller/FrontController.php @@ -21,6 +21,9 @@ class FrontController ); private array $teacherActions = array( + 'showAllGroup', + 'showAllVocab', + 'getVocabByName' ); private array $studentActions = array( diff --git a/Project/php/controller/TeacherController.php b/Project/php/controller/TeacherController.php index e3124ec..0e17a9c 100755 --- a/Project/php/controller/TeacherController.php +++ b/Project/php/controller/TeacherController.php @@ -19,14 +19,18 @@ class TeacherController $this->affAllStudent(); break; - case 'allVocab': + case 'showAllVocab': $this->affAllVocab(); break; case 'getVocabByName': - $this->getByName($_REQUEST['name']); + $this->getByName(); break; case 'addVocab': break; + case 'showAllGroup': + $this->findAllGroup(); + break; + /* case 'delVoc': $this->delById($_REQUEST['id']); @@ -66,12 +70,16 @@ class TeacherController } - public function getByName($name): void + public function getByName(): void { global $twig; $mdl = new MdlTeacher(); - $vocab = $mdl->getVocabByName($name); - echo $twig->render('usersView.html', ['users' => $vocab]); + if (isset($_GET['name'])) { + // Get the 'name' parameter from the $_GET array + $name = $_GET['name']; + $vocab = $mdl->getVocabByName($name); + echo $twig->render('usersView.html', ['users' => $vocab,]); + } } @@ -79,10 +87,17 @@ class TeacherController global $twig; $mdl = new MdlTeacher(); $vocab = $mdl->removeVocById($id); - echo $twig->render('usersView.html', ['users' => $vocab]); + echo $twig->render('usersView.html', ['vocab' => $vocab]); } + public function findAllGroup(){ + global $twig; + $mdl = new MdlTeacher(); + $group = $mdl->getGroup(); + $user = $mdl->getUnassignedUsers(); + echo $twig->render('manageVocabListView.html', ['groups' => $group,'unassignedUsers' => $user]); + } } \ No newline at end of file diff --git a/Project/php/model/MdlTeacher.php b/Project/php/model/MdlTeacher.php index 6ccabe6..ae7231e 100755 --- a/Project/php/model/MdlTeacher.php +++ b/Project/php/model/MdlTeacher.php @@ -2,8 +2,9 @@ namespace model; +use gateway\GroupGateway; use gateway\UserGateway; -use gateway\VocabularyGateway; +use gateway\VocabularyListGateway; class MdlTeacher extends AbsModel { @@ -13,7 +14,7 @@ class MdlTeacher extends AbsModel } public function getAll():array{ - $gtw = new VocabularyGateway(); + $gtw = new VocabularyListGateway(); return $gtw->findAll(); } @@ -23,14 +24,24 @@ class MdlTeacher extends AbsModel } public function getVocabByName(string $name):array{ - $gtw = new VocabularyGateway(); + $gtw = new VocabularyListGateway(); $res = $gtw->findByName($name); return $res; } public function RemoveVocById(int $id):void{ - $gtw = new VocabularyGateway(); - $res = $gtw->remove($id); + $gtw = new VocabularyListGateway(); + $gtw->remove($id); + } + + public function getGroup():array{ + $gtw = new GroupGateway(); + return $gtw->findAll(); + } + + public function getUnassignedUsers(): array { + $gtw = new UserGateway(); + return $gtw->findUnassignedUsers(); } diff --git a/Project/php/templates/manageVocabListView.html b/Project/php/templates/manageVocabListView.html new file mode 100755 index 0000000..ff505ff --- /dev/null +++ b/Project/php/templates/manageVocabListView.html @@ -0,0 +1,30 @@ + + + + + Title + + +
+ +
+

Group list

+ {% include 'groupContainer.twig' with {'actions' : 'showAllGroup'} %} +
+ +
+

Users of the group

+ {% include 'userContainer.twig' with {'users' : teacher, 'action' : 'showAllVocab'} %} +
+
+

Add group

+ {% include 'addGroupForm.twig' %} +
+
+

Unassigned users

+ {% include 'userContainer.twig' with {'vocab' : teacher, 'action' : 'getVocabByName'} %} +
+
+ + + \ No newline at end of file