diff --git a/build/api/module/ue/coursController.php b/build/api/module/ue/coursController.php index f4ecc76..72acc39 100644 --- a/build/api/module/ue/coursController.php +++ b/build/api/module/ue/coursController.php @@ -25,10 +25,31 @@ class coursController{ $formations = []; extract($args); - /* Get the cours repo */ + /* Get the repos */ /** @var cours $cours_repo */ $cours_repo = Repo::getRepo('cours'); + /** @var ue $ue_repo */ + $ue_repo = Repo::getRepo('ue'); + + /* (1) Fetch default formation from UE + ---------------------------------------------------------*/ + /* (1) Try to fetch the cours' UE */ + $fetched_ue = $ue_repo->get($code); + + /* (2) Manage error */ + if( !is_array($fetched_ue) || count($fetched_ue) < 1 ) + return ['error' => new Error(Err::RepoError)]; + + $defaultForm = intval($fetched_ue[0]['idForm']); + + /* (3) Add to formation list if got a valid default formation */ + if( is_int($defaultForm) && $defaultForm >= 0 && !in_array($defaultForm, $formations) ) + $formations[] = $defaultForm; + + + /* (2) Create the cours + ---------------------------------------------------------*/ /* (1) Try to create cours */ $created_id = $cours_repo->create($code, $idProf, $volume, $formations); @@ -36,7 +57,7 @@ class coursController{ if( is_null($created_id) || !is_int($created_id) ) return ['error' => new Error(Err::RepoError)]; - return ['created_id' => $created_id]; + return ['created_id' => $created_id, 'formations' => $formations]; } diff --git a/build/api/module/ue/tdController.php b/build/api/module/ue/tdController.php index f617005..fb19c99 100644 --- a/build/api/module/ue/tdController.php +++ b/build/api/module/ue/tdController.php @@ -25,10 +25,31 @@ class tdController{ $formations = []; extract($args); - /* Get the td repo */ + /* Get the repos */ /** @var td $td_repo */ $td_repo = Repo::getRepo('td'); + /** @var ue $ue_repo */ + $ue_repo = Repo::getRepo('ue'); + + /* (1) Fetch default formation from UE + ---------------------------------------------------------*/ + /* (1) Try to fetch the TD' UE */ + $fetched_ue = $ue_repo->get($code); + + /* (2) Manage error */ + if( !is_array($fetched_ue) || count($fetched_ue) < 1 ) + return ['error' => new Error(Err::RepoError)]; + + $defaultForm = intval($fetched_ue[0]['idForm']); + + /* (3) Add to formation list if got a valid default formation */ + if( is_int($defaultForm) && $defaultForm >= 0 && !in_array($defaultForm, $formations) ) + $formations[] = $defaultForm; + + + /* (2) Create the TD + ---------------------------------------------------------*/ /* (1) Try to create td */ $created_id = $td_repo->create($code, $idProf, $volume, $formations); @@ -36,7 +57,7 @@ class tdController{ if( is_null($created_id) || !is_int($created_id) ) return ['error' => new Error(Err::RepoError)]; - return ['created_id' => $created_id]; + return ['created_id' => $created_id, 'formations' => $formations]; } diff --git a/build/api/module/ue/tpController.php b/build/api/module/ue/tpController.php index 4fe66e1..51a4a42 100644 --- a/build/api/module/ue/tpController.php +++ b/build/api/module/ue/tpController.php @@ -25,10 +25,31 @@ class tpController{ $formations = []; extract($args); - /* Get the tp repo */ + /* Get the repos */ /** @var tp $tp_repo */ $tp_repo = Repo::getRepo('tp'); + /** @var ue $ue_repo */ + $ue_repo = Repo::getRepo('ue'); + + /* (1) Fetch default formation from UE + ---------------------------------------------------------*/ + /* (1) Try to fetch the TP' UE */ + $fetched_ue = $ue_repo->get($code); + + /* (2) Manage error */ + if( !is_array($fetched_ue) || count($fetched_ue) < 1 ) + return ['error' => new Error(Err::RepoError)]; + + $defaultForm = intval($fetched_ue[0]['idForm']); + + /* (3) Add to formation list if got a valid default formation */ + if( is_int($defaultForm) && $defaultForm >= 0 && !in_array($defaultForm, $formations) ) + $formations[] = $defaultForm; + + + /* (2) Create the TP + ---------------------------------------------------------*/ /* (1) Try to create tp */ $created_id = $tp_repo->create($code, $idProf, $volume, $formations); @@ -36,7 +57,7 @@ class tpController{ if( is_null($created_id) || !is_int($created_id) ) return ['error' => new Error(Err::RepoError)]; - return ['created_id' => $created_id]; + return ['created_id' => $created_id, 'formations' => $formations]; } diff --git a/build/database/repo/professor.php b/build/database/repo/professor.php index 0dc845b..4741a85 100644 --- a/build/database/repo/professor.php +++ b/build/database/repo/professor.php @@ -321,7 +321,7 @@ class professor extends Repo_i { $parm = is_null($prof_id) ? [] : [':id' => $prof_id]; /* (2) Prepare Statement */ - $st = $this->pdo->prepare("SELECT * FROM `Professeur`$cond ORDER BY abreviation ASC"); + $st = $this->pdo->prepare("SELECT * FROM `Professeur`$cond ORDER BY firstName, lastName ASC"); /* (3) Bind params and execute statement */ if( is_bool($st) ) return []; @@ -433,7 +433,8 @@ class professor extends Repo_i { AND VHTp.idProf = Prof.idProfesseur AND VHTd.idProf = Prof.idProfesseur GROUP BY - Prof.idProfesseur;"); + Prof.idProfesseur + ORDER BY Prof.firstName, Prof.lastName ASC;"); /* (3) Bind params and execute statement */ if( is_bool($st) ) return []; diff --git a/config/modules.json b/config/modules.json index 446280a..8f46e51 100644 --- a/config/modules.json +++ b/config/modules.json @@ -331,7 +331,8 @@ "formations": { "des": "List of formations (ids)", "typ": "array", "opt": true, "def": [] } }, "output": { - "created_id" : { "des": "The id of the created Cours", "typ": "id" } + "created_id" : { "des": "The id of the created Cours", "typ": "id" }, + "formations" : { "des": "The ids of the linked formations", "typ": "array" } } }, @@ -383,7 +384,8 @@ "formations": { "des": "List of formations (ids)", "typ": "array", "opt": true, "def": [] } }, "output": { - "created_id" : { "des": "The id of the created TD", "typ": "id" } + "created_id" : { "des": "The id of the created TD", "typ": "id" }, + "formations" : { "des": "The ids of the linked formations", "typ": "array" } } }, @@ -435,7 +437,8 @@ "formations": { "des": "List of formations (ids)", "typ": "array", "opt": true, "def": [] } }, "output": { - "created_id" : { "des": "The id of the created TP", "typ": "id" } + "created_id" : { "des": "The id of the created TP", "typ": "id" }, + "formations" : { "des": "The ids of the linked formations", "typ": "array" } } }, diff --git a/webpack/component/ue/manage.vue b/webpack/component/ue/manage.vue index 7adca42..572f910 100644 --- a/webpack/component/ue/manage.vue +++ b/webpack/component/ue/manage.vue @@ -12,9 +12,9 @@
-
enseignant
-
volume horaire
-
formations
+
enseignant
+
volume horaire
+
formations
@@ -54,9 +54,9 @@ data-anim-incoming='1' :data-anim-bounce='gstore.nav_anim.out?1:0' + :data-prof='c.idProf' :data-vol='c.volume' - :data-form='c.formations.join(`|`)' - data-typ='cm'> + :data-form='c.formations.join(`|`)'>
@@ -130,9 +130,9 @@ data-anim-incoming='1' :data-anim-bounce='gstore.nav_anim.out?1:0' + :data-prof='tp.idProf' :data-vol='tp.volume' - :data-form='tp.formations.join(`|`)' - data-typ='td'> + :data-form='tp.formations.join(`|`)'>