ptut-vhost/build/api/module/Professor/Stats.php

41 lines
873 B
PHP

<?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];
}
}