From fd9357fdba4576a509d92e940d1b0d4925cf1418 Mon Sep 17 00:00:00 2001 From: SeekDaSky Date: Tue, 27 Feb 2018 17:22:08 +0100 Subject: [PATCH] Implemented TD Equivalent Computing for the professors --- build/api/module/Professor/Stats.php | 41 ++++++++++++++++++++++++++++ build/database/repo/professor.php | 19 +++++++++++++ config/modules.json | 12 ++++++++ 3 files changed, 72 insertions(+) create mode 100644 build/api/module/Professor/Stats.php diff --git a/build/api/module/Professor/Stats.php b/build/api/module/Professor/Stats.php new file mode 100644 index 0000000..9098481 --- /dev/null +++ b/build/api/module/Professor/Stats.php @@ -0,0 +1,41 @@ + $VH["du"]){ + $partTP = $VH["VHTp"] / $VH["equiTD"]; + $valReelleTP = $partTP * $VH["du"]; + $VH["equiTD"] = round(1.5*$VH["VHCours"] + $VH["VHTd"] + $valReelleTP + ($VH["VHTp"] - $valReelleTP)*(2/3),2); + } + + $VH["VHComp"] = round($VH["equiTD"] - $VH["du"],2); + $VH["VHComp"] < 0 ? 0 : $VH["VHComp"]; + }else{ + $VH["equiTD"] = $VH["VHTd"] + (2/3)*$VH["VHTp"] + 1.5*$VH["VHCours"]; + } + + return ["data" => $VH]; + } + +} \ No newline at end of file diff --git a/build/database/repo/professor.php b/build/database/repo/professor.php index 433d58d..f5aecfa 100644 --- a/build/database/repo/professor.php +++ b/build/database/repo/professor.php @@ -86,4 +86,23 @@ class professor extends Repo_i { ]); } + public function getVH(int $id) : array{ + $st = $this->pdo->prepare("SELECT VHCours, VHTd, VHTp, Cat.idCategorie idCat, Prof.hoursToDo du + FROM Professeur Prof, Categorie Cat, + (SELECT SUM(C.volume) VHCours , Prof.idProfesseur idProf FROM Cours C, Professeur Prof WHERE C.Professeur_idProfesseur = Prof.idProfesseur GROUP BY Prof.idProfesseur) VHCours, + (SELECT SUM(T.volume) VHTd , Prof.idProfesseur idProf FROM TD T, Professeur Prof WHERE T.Professeur_idProfesseur = Prof.idProfesseur GROUP BY Prof.idProfesseur) VHTd, + (SELECT SUM(T2.volume) VHTp, Prof.idProfesseur idProf FROM TP T2 , Professeur Prof WHERE T2.Professeur_idProfesseur = Prof.idProfesseur GROUP BY Prof.idProfesseur) VHTp + WHERE + Prof.idProfesseur = :idProf AND + Prof.Categorie_idCategorie = Cat.idCategorie AND + VHCours.idProf = Prof.idProfesseur AND + VHTp.idProf = Prof.idProfesseur AND + VHTd.idProf = Prof.idProfesseur;"); + $st->execute([ + "idProf" => $id + ]); + + return $st->fetch(); + } + } \ No newline at end of file diff --git a/config/modules.json b/config/modules.json index cd5aded..c0901a1 100644 --- a/config/modules.json +++ b/config/modules.json @@ -70,6 +70,18 @@ } }, + "Professor":{ + "Stats": { + "GET":{ + "des": "Get statistics of the professor", + "per": [], + "par":{ + "URL0": {"des" : "Id of the professor", "typ": "id", "ren": "idProf", "opt" : false} + } + } + } + }, + "a": { "b": {