Merge branch 'master' of https://git.xdrm.io/ptut/vhost
This commit is contained in:
commit
92dfdbbc5b
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: lucas
|
||||||
|
* Date: 05/03/18
|
||||||
|
* Time: 19:36
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace api\module\departement;
|
||||||
|
|
||||||
|
|
||||||
|
use database\core\Repo;
|
||||||
|
use database\repo\departement;
|
||||||
|
|
||||||
|
class errorsController
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function get($args){
|
||||||
|
/** @var departement $repo */
|
||||||
|
$repo = Repo::getRepo("departement");
|
||||||
|
|
||||||
|
return ["data" => $repo->getErrors()];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -301,15 +301,15 @@ class excelController
|
||||||
|
|
||||||
foreach ($allProf as $initials => &$prof){
|
foreach ($allProf as $initials => &$prof){
|
||||||
//create or update the professor category
|
//create or update the professor category
|
||||||
$catRepo->createOrUpdate($prof["categoryIndex"], utf8_decode($prof["categoryLabel"]));
|
$catRepo->create($prof["categoryIndex"], $prof["categoryLabel"]);
|
||||||
|
|
||||||
//create the professor, as some names are missing, we replace them by something else
|
//create the professor, as some names are missing, we replace them by something else
|
||||||
if(!$prof["lastName"]) $prof["lastName"] = "missingLastName";
|
if(!$prof["lastName"]) $prof["lastName"] = "missingLastName";
|
||||||
if(!$prof["firstName"]) $prof["firstName"] = "missingFirstName";
|
if(!$prof["firstName"]) $prof["firstName"] = "missingFirstName";
|
||||||
|
|
||||||
$prof["dbId"] = $profRepo->exists(utf8_decode($prof["lastName"]), utf8_decode($prof["firstName"]));
|
$prof["dbId"] = $profRepo->exists($prof["lastName"], $prof["firstName"]);
|
||||||
if(!$prof["dbId"]){
|
if(!$prof["dbId"]){
|
||||||
$prof["dbId"] = $profRepo->create( utf8_decode($prof["lastName"]), utf8_decode($prof["firstName"]), $prof["categoryIndex"], $prof["hoursToDo"], $initials);
|
$prof["dbId"] = $profRepo->create( $prof["lastName"], $prof["firstName"], $prof["categoryIndex"], $prof["hoursToDo"], $initials);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,9 +318,9 @@ class excelController
|
||||||
$formRepo = Repo::getRepo("formation");
|
$formRepo = Repo::getRepo("formation");
|
||||||
|
|
||||||
foreach ($allFormations as &$form){
|
foreach ($allFormations as &$form){
|
||||||
$form["dbId"] = $formRepo->exists( utf8_decode($form["name"]));
|
$form["dbId"] = $formRepo->exists( $form["name"]);
|
||||||
if(!$form["dbId"]){
|
if(!$form["dbId"]){
|
||||||
$form["dbId"] = $formRepo->create( utf8_decode($form["name"]), $form["internal"]);
|
$form["dbId"] = $formRepo->create( $form["name"], $form["internal"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,8 +346,8 @@ class excelController
|
||||||
$UE["defaultFormationId"] = null;
|
$UE["defaultFormationId"] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ueRepo->create(utf8_decode($codeUE),
|
$ueRepo->create($codeUE,
|
||||||
utf8_decode($UE["name"]),
|
$UE["name"],
|
||||||
$UE["required"] == "OBL",
|
$UE["required"] == "OBL",
|
||||||
$UE["CourseVH"],
|
$UE["CourseVH"],
|
||||||
$UE["TdVH"],
|
$UE["TdVH"],
|
||||||
|
@ -367,19 +367,19 @@ class excelController
|
||||||
|
|
||||||
switch ($type){
|
switch ($type){
|
||||||
case "Course":
|
case "Course":
|
||||||
$coursRepo->create( utf8_decode($codeUE),
|
$coursRepo->create( $codeUE,
|
||||||
$allProf[$group["professor"]]["dbId"],
|
$allProf[$group["professor"]]["dbId"],
|
||||||
$group["VH"],
|
$group["VH"],
|
||||||
$formations);
|
$formations);
|
||||||
break;
|
break;
|
||||||
case "TD":
|
case "TD":
|
||||||
$tdRepo->create(utf8_decode($codeUE),
|
$tdRepo->create($codeUE,
|
||||||
$allProf[$group["professor"]]["dbId"],
|
$allProf[$group["professor"]]["dbId"],
|
||||||
$group["VH"],
|
$group["VH"],
|
||||||
$formations);
|
$formations);
|
||||||
break;
|
break;
|
||||||
case "TP":
|
case "TP":
|
||||||
$tpRepo->create(utf8_decode($codeUE),
|
$tpRepo->create($codeUE,
|
||||||
$allProf[$group["professor"]]["dbId"],
|
$allProf[$group["professor"]]["dbId"],
|
||||||
$group["VH"],
|
$group["VH"],
|
||||||
$formations);
|
$formations);
|
||||||
|
|
|
@ -13,14 +13,15 @@ use database\core\Repo_i;
|
||||||
|
|
||||||
class category extends Repo_i{
|
class category extends Repo_i{
|
||||||
|
|
||||||
public function createOrUpdate(int $id, string $label){
|
public function create(int $id, string $label) : bool{
|
||||||
//create the category or update the label
|
//create the category or update the label
|
||||||
$st = $this->pdo->prepare("INSERT INTO Categorie (idCategorie, labelCategorie) VALUES (:id, :label) ON DUPLICATE KEY UPDATE labelCategorie = :label;");
|
$st = $this->pdo->prepare("INSERT INTO Categorie (idCategorie, labelCategorie) VALUE (:id, :label)");
|
||||||
|
|
||||||
$st->execute([
|
return $st->execute([
|
||||||
"id" => $id,
|
"id" => $id,
|
||||||
"label" => $label
|
"label" => $label
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(int $id) :bool{
|
public function delete(int $id) :bool{
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: lucas
|
||||||
|
* Date: 05/03/18
|
||||||
|
* Time: 19:39
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace database\repo;
|
||||||
|
|
||||||
|
|
||||||
|
use database\core\Repo_i;
|
||||||
|
|
||||||
|
class departement extends Repo_i
|
||||||
|
{
|
||||||
|
|
||||||
|
public function getErrors() : array {
|
||||||
|
|
||||||
|
$results = [];
|
||||||
|
|
||||||
|
/* (1) Find Groups without formation bound */
|
||||||
|
$GroupWithoutFormation = $this->pdo->prepare("
|
||||||
|
(SELECT 'NO_FORMATION_ASSIGNED' errorType, 'Cours' entityType, idCours id FROM Cours WHERE idCours NOT IN (SELECT Cours_idCours FROM GroupeCours))
|
||||||
|
UNION
|
||||||
|
(SELECT 'NO_FORMATION_ASSIGNED' errorType, 'TD' entityType, idTD id FROM TD WHERE idTD NOT IN (SELECT TD_idTD FROM GroupeTD))
|
||||||
|
UNION
|
||||||
|
(SELECT 'NO_FORMATION_ASSIGNED' errorType, 'TP' entityType, idTP id FROM TP WHERE idTP NOT IN (SELECT TP_idTP FROM GroupeTP))");
|
||||||
|
|
||||||
|
$GroupWithoutFormation->execute([]);
|
||||||
|
|
||||||
|
$results = array_merge($results,$GroupWithoutFormation->fetchAll());
|
||||||
|
|
||||||
|
/* (2) Find Groups without a professor bound */
|
||||||
|
|
||||||
|
$GroupWithoutProfessor = $this->pdo->prepare("
|
||||||
|
(SELECT 'NO_PROFESSOR_ASSIGNED' errorType, 'Cours' entityType, idCours id FROM Cours WHERE Professeur_idProfesseur IS NULL)
|
||||||
|
UNION
|
||||||
|
(SELECT 'NO_PROFESSOR_ASSIGNED' errorType, 'TD' entityType, idTD id FROM TD WHERE Professeur_idProfesseur IS NULL)
|
||||||
|
UNION
|
||||||
|
(SELECT 'NO_PROFESSOR_ASSIGNED' errorType, 'TP' entityType, idTP id FROM TP WHERE Professeur_idProfesseur IS NULL)");
|
||||||
|
|
||||||
|
$GroupWithoutProfessor->execute([]);
|
||||||
|
|
||||||
|
$results = array_merge($results,$GroupWithoutProfessor->fetchAll());
|
||||||
|
|
||||||
|
/* (3) Find Groups a null VH */
|
||||||
|
|
||||||
|
$GroupWithNullVH = $this->pdo->prepare("
|
||||||
|
(SELECT 'NULL_VH' errorType, 'Cours' entityType, idCours id FROM Cours WHERE volume = 0)
|
||||||
|
UNION
|
||||||
|
(SELECT 'NULL_VH' errorType, 'TD' entityType, idTD id FROM TD WHERE volume = 0)
|
||||||
|
UNION
|
||||||
|
(SELECT 'NULL_VH' errorType, 'TP' entityType, idTP id FROM TP WHERE volume = 0)");
|
||||||
|
|
||||||
|
$GroupWithNullVH->execute([]);
|
||||||
|
|
||||||
|
$results = array_merge($results,$GroupWithNullVH->fetchAll());
|
||||||
|
|
||||||
|
/* (4) Find UE with an incorrect VH in the groups compared to what's supposed to be */
|
||||||
|
|
||||||
|
$UEWithIncorrectGroupVH = $this->pdo->prepare("
|
||||||
|
(SELECT 'UNEQUIVALENT_VH' errorType, 'Cours' entityType, U.code
|
||||||
|
FROM UE U
|
||||||
|
WHERE
|
||||||
|
0 != (SELECT MOD(SUM(volume),U.volumeCours) modCours FROM Cours WHERE UE_code = U.code GROUP BY Cours.UE_code)
|
||||||
|
)
|
||||||
|
|
||||||
|
UNION
|
||||||
|
|
||||||
|
(SELECT 'UNEQUIVALENT_VH' errorType, 'TD' entityType, U.code
|
||||||
|
FROM UE U
|
||||||
|
WHERE
|
||||||
|
0 != (SELECT MOD(SUM(volume),U.volumeTD) modCours FROM TD WHERE UE_code = U.code GROUP BY TD.UE_code)
|
||||||
|
)
|
||||||
|
|
||||||
|
UNION
|
||||||
|
|
||||||
|
(SELECT 'UNEQUIVALENT_VH' errorType, 'TP' entityType, U.code
|
||||||
|
FROM UE U
|
||||||
|
WHERE
|
||||||
|
0 != (SELECT MOD(SUM(volume),U.volumeTP) modCours FROM TP WHERE UE_code = U.code GROUP BY TP.UE_code)
|
||||||
|
)");
|
||||||
|
|
||||||
|
$UEWithIncorrectGroupVH->execute([]);
|
||||||
|
|
||||||
|
$results = array_merge($results,$UEWithIncorrectGroupVH->fetchAll());
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -71,6 +71,17 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"departement":{
|
||||||
|
"errors":{
|
||||||
|
"GET": {
|
||||||
|
"des": "Get the list of incoherence of the department",
|
||||||
|
"per": [],
|
||||||
|
"par": {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
"professor":{
|
"professor":{
|
||||||
|
|
||||||
"POST": {
|
"POST": {
|
||||||
|
|
Loading…
Reference in New Issue