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": {