Implemented TD Equivalent Computing for the professors
This commit is contained in:
parent
65a8f7582c
commit
fd9357fdba
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: lucas
|
||||
* Date: 27/02/18
|
||||
* Time: 16:19
|
||||
*/
|
||||
|
||||
namespace api\module\Professor;
|
||||
|
||||
|
||||
use database\core\Repo;
|
||||
|
||||
class Stats
|
||||
{
|
||||
public static function get($args){
|
||||
$idProf = 0;
|
||||
extract($args);
|
||||
|
||||
//get data from the database
|
||||
$VH = Repo::request("professor", "getVH", $idProf);
|
||||
|
||||
if(in_array($VH["idCat"],[1,3])){
|
||||
$VH["equiTD"] = $VH["VHTd"] + $VH["VHTp"] + 1.5*$VH["VHCours"];
|
||||
|
||||
if($VH["equiTD"] > $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];
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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": {
|
||||
|
|
Loading…
Reference in New Issue