From afe23287435b3c77478c8b6ee5b76028eed4b802 Mon Sep 17 00:00:00 2001 From: "patrick.brugiere" Date: Wed, 8 Nov 2023 14:26:41 +0100 Subject: [PATCH 1/5] finition du controller de student --- Project/php/controller/StudentController.php | 18 ++++++++++++++---- Project/php/gateway/VocabularyGateway.php | 2 +- Project/php/model/MdlStudent.php | 10 ++++++---- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Project/php/controller/StudentController.php b/Project/php/controller/StudentController.php index ce9b335..d5fadef 100755 --- a/Project/php/controller/StudentController.php +++ b/Project/php/controller/StudentController.php @@ -20,10 +20,11 @@ class StudentController try{ $action = $_REQUEST['action']?? null; switch($action) { - case NULL: + case "AllVocab": + affAllVocab(); break; - case "ajouter": - ajouter($_REQUEST['']); + case "getByName": + getByName(); break; default: @@ -43,7 +44,7 @@ class StudentController require($dataVueEreur['erreur']); } } - function AffAllStudent():void{ + public function affAllVocab():void{ global $twig; $mdl = new MdlStudent(); $student = $mdl->getAll(); @@ -51,5 +52,14 @@ class StudentController } + public function getByName($name):void{ + global $twig; + $mdl = new MdlStudent(); + $vocab = $mdl->getVocabByName($name); + echo $twig->render('usersView.html', ['users'=> $vocab]); + + } + + } diff --git a/Project/php/gateway/VocabularyGateway.php b/Project/php/gateway/VocabularyGateway.php index 1120b97..4aee47e 100755 --- a/Project/php/gateway/VocabularyGateway.php +++ b/Project/php/gateway/VocabularyGateway.php @@ -28,7 +28,7 @@ class VocabularyGateway extends AbsGateway } } - public function remove(array $id): void + public function remove(int $id): void { try{ $query = "DELETE FROM Vocabulary v WHERE v.id=:id "; diff --git a/Project/php/model/MdlStudent.php b/Project/php/model/MdlStudent.php index 4d7e482..d93b3c1 100755 --- a/Project/php/model/MdlStudent.php +++ b/Project/php/model/MdlStudent.php @@ -26,7 +26,7 @@ class MdlStudent extends AbsModel else return null; } */ - public function getAll(){ + public function getAll():array{ global $twig; $gtw = new VocabularyGateway(new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger')); return $gtw->findAll(); @@ -38,14 +38,16 @@ class MdlStudent extends AbsModel */ } - public function getById($id){ - $gtw = new VocabularyGateway(new Connection()); - $res = $gtw->getById($id); + public function getVocabByName($name):array{ + $gtw = new VocabularyGateway(new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger')); + $res = $gtw->findByName($name); return $res; } + + } From bda9ee44d725d3dbfc629c436e53b5a684b8eaa8 Mon Sep 17 00:00:00 2001 From: "lucie.goigoux2" Date: Wed, 8 Nov 2023 14:42:54 +0100 Subject: [PATCH 2/5] formulaire ajout user --- Project/php/templates/login.html | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/Project/php/templates/login.html b/Project/php/templates/login.html index 18edc4e..cc3b449 100755 --- a/Project/php/templates/login.html +++ b/Project/php/templates/login.html @@ -41,18 +41,34 @@

Sign Up

-
- + +
+ -
+
+ +
+ + +
+
- + + +
+ +
+ -
+
+
- +
+ + + submit
From 1c6a5c04d0aa28187ba2d69c5751dae33a9bc76e Mon Sep 17 00:00:00 2001 From: "lucie.goigoux2" Date: Wed, 8 Nov 2023 14:43:03 +0100 Subject: [PATCH 3/5] formulaire ajout user --- Project/php/templates/css/login.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project/php/templates/css/login.css b/Project/php/templates/css/login.css index 5fc2d1f..864b8c1 100755 --- a/Project/php/templates/css/login.css +++ b/Project/php/templates/css/login.css @@ -95,7 +95,7 @@ h6 span{ position: relative; width: 440px; max-width: 100%; - height: 400px; + height: 500px; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; perspective: 800px; From 0df1644b62ebe34af80f1db0ed5d7ce192cb77e3 Mon Sep 17 00:00:00 2001 From: "antoine.jourdain" Date: Wed, 8 Nov 2023 14:46:54 +0100 Subject: [PATCH 4/5] Ajout id et affichage role, extra time --- Project/php/templates/usersView.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Project/php/templates/usersView.html b/Project/php/templates/usersView.html index de764fe..2de6510 100755 --- a/Project/php/templates/usersView.html +++ b/Project/php/templates/usersView.html @@ -4,11 +4,12 @@ Users - +
+ @@ -20,13 +21,14 @@ {% if users is defined %} {% for row in users %} + - - + + {% endfor %} From e8c99b94130d1a60303663b368c902f42a1913c8 Mon Sep 17 00:00:00 2001 From: "patrick.brugiere" Date: Wed, 8 Nov 2023 15:24:28 +0100 Subject: [PATCH 5/5] "ajout du modele et du controleur de teacher" --- Project/php/controller/StudentController.php | 64 +++++++------- Project/php/controller/TeacherController.php | 89 ++++++++++++++++++++ Project/php/model/MdlTeacher.php | 48 +++++++++++ 3 files changed, 172 insertions(+), 29 deletions(-) create mode 100755 Project/php/controller/TeacherController.php create mode 100755 Project/php/model/MdlTeacher.php diff --git a/Project/php/controller/StudentController.php b/Project/php/controller/StudentController.php index d5fadef..088e314 100755 --- a/Project/php/controller/StudentController.php +++ b/Project/php/controller/StudentController.php @@ -8,23 +8,21 @@ use config\Connection; class StudentController { - public function __construct(){ + public function __construct() + { global $twig; - global $gtw; - global $con; - $con = new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger'); - $gtw = new UserGateway($con); - $actionList = ['showUsers']; - $dVueEreur= []; session_start(); - try{ - $action = $_REQUEST['action']?? null; - switch($action) { - case "AllVocab": - affAllVocab(); + $actionList = ['showVocab', 'getByName']; + $dVueEreur = []; + try { + $action = $_REQUEST['action'] ?? null; + switch ($action) { + case 'allVocab': + case null: + $this->affAllVocab(); break; - case "getByName": - getByName(); + case 'getByName': + $this->getByName($_REQUEST['nom']); break; default: @@ -32,33 +30,41 @@ class StudentController echo $twig->render('vuephp1.html', ['dVueEreur' => $dVueEreur]); break; } - } - catch(\PDOException $e){ - $dataVueEreur[]= "Erreur inattendue"; - $twig->render("vuephp1.html",['dVueErreur' =>$dataVueEreur]); + } catch (\PDOException $e) { + $dataVueEreur[] = "Erreur inattendue"; + $twig->render("vuephp1.html", ['dVueErreur' => $dataVueEreur]); - } - catch (Exception $e2) - { + } catch (Exception $e2) { $dataVueEreur[] = "Erreur inattendue!!! "; require($dataVueEreur['erreur']); } } - public function affAllVocab():void{ + public function affAllVocab(): void + { + global $twig; + $mdl = new MdlStudent(); + $student = $mdl->getAll(); + echo $twig->render('usersView.html', ['users' => $student]); + + } + + public function affAllStudent(): void + { global $twig; $mdl = new MdlStudent(); $student = $mdl->getAll(); - echo $twig->render('usersView.html', ['users'=> $student]); + echo $twig->render('usersView.html', ['users' => $student]); } - public function getByName($name):void{ - global $twig; - $mdl = new MdlStudent(); - $vocab = $mdl->getVocabByName($name); - echo $twig->render('usersView.html', ['users'=> $vocab]); + public function getByName($name): void + { + global $twig; + $mdl = new MdlStudent(); + $vocab = $mdl->getVocabByName($name); + echo $twig->render('usersView.html', ['users' => $vocab]); + } - } } diff --git a/Project/php/controller/TeacherController.php b/Project/php/controller/TeacherController.php new file mode 100755 index 0000000..e2dc9b0 --- /dev/null +++ b/Project/php/controller/TeacherController.php @@ -0,0 +1,89 @@ +affAllStudent(); + break; + + case 'allVocab': + $this->affAllVocab(); + break; + case 'getVocabByName': + $this->getByName($_REQUEST['name']); + break; + case 'addVocab': + break; + + /* case 'delVoc': + $this->delById($_REQUEST['id']); + break;*/ + + default: + $dVueEreur[] = "Erreur d'appel php"; + echo $twig->render('vuephp1.html', ['dVueEreur' => $dVueEreur]); + break; + } + } + catch (\PDOException $e) { + $dataVueEreur[] = "Erreur inattendue"; + $twig->render("vuephp1.html", ['dVueErreur' => $dataVueEreur]); + + } catch (Exception $e2) { + $dataVueEreur[] = "Erreur inattendue!!! "; + require($dataVueEreur['erreur']); + } + } + public function affAllStudent(): void + { + global $twig; + $mdl = new MdlTeacher(); + $student = $mdl->getAllStudent(); + echo $twig->render('usersView.html', ['users' => $student]); + + } + + + public function affAllVocab(): void + { + global $twig; + $mdl = new MdlTeacher(); + $student = $mdl->getAll(); + echo $twig->render('usersView.html', ['users' => $student]); + + } + + public function getByName($name): void + { + global $twig; + $mdl = new MdlTeacher(); + $vocab = $mdl->getVocabByName($name); + echo $twig->render('usersView.html', ['users' => $vocab]); + + } + + public function DelById($id):void{ + global $twig; + $mdl = new MdlTeacher(); + $vocab = $mdl->removeVocById($id); + echo $twig->render('usersView.html', ['users' => $vocab]); + + } + + + +} \ No newline at end of file diff --git a/Project/php/model/MdlTeacher.php b/Project/php/model/MdlTeacher.php new file mode 100755 index 0000000..8faa491 --- /dev/null +++ b/Project/php/model/MdlTeacher.php @@ -0,0 +1,48 @@ +findAll(); + /* + foreach ($data as $row){ + $AllStudent[] = User($row['id'],$row['password'],$row['email'],$row['name'],$row['surname'],$row['nickname'],$row['image'],$row['extraTime'],$row['group'],$row['roles']); + } + return $AllStudent; + */ + } + + public function getAllStudent():array { + $gtw = new UserGateway(new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger')); + return $gtw->findAll(); + } + + public function getVocabByName($name):array{ + $gtw = new VocabularyGateway(new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger')); + $res = $gtw->findByName($name); + return $res; + } + + public function RemoveVocById($id):void{ + $gtw = new VocabularyGateway(new Connection('mysql:host=localhost;dbname=dbanrichard7','anrichard7','achanger')); + $res = $gtw->remove($id); + } + + + + +} \ No newline at end of file
Id Nickname Name Surname
{{row.id}} {{row.nickname}} {{row.name}} {{row.surname}} {{row.email}} {{row.group}}{{row.role}}{{row.extraTime}}{{row.roles|join(', ')}}{{row.extraTime? 'yes' : 'no' }}