fixed encoding + implemented incoherence detection

This commit is contained in:
SeekDaSky 2018-03-05 20:30:05 +01:00
parent a9fec0373e
commit b1bf05541d
5 changed files with 141 additions and 13 deletions

View File

@ -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()];
}
}

View File

@ -301,15 +301,15 @@ class excelController
foreach ($allProf as $initials => &$prof){
//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
if(!$prof["lastName"]) $prof["lastName"] = "missingLastName";
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"]){
$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");
foreach ($allFormations as &$form){
$form["dbId"] = $formRepo->exists( utf8_decode($form["name"]));
$form["dbId"] = $formRepo->exists( $form["name"]);
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;
}
$ueRepo->create(utf8_decode($codeUE),
utf8_decode($UE["name"]),
$ueRepo->create($codeUE,
$UE["name"],
$UE["required"] == "OBL",
$UE["CourseVH"],
$UE["TdVH"],
@ -367,19 +367,19 @@ class excelController
switch ($type){
case "Course":
$coursRepo->create( utf8_decode($codeUE),
$coursRepo->create( $codeUE,
$allProf[$group["professor"]]["dbId"],
$group["VH"],
$formations);
break;
case "TD":
$tdRepo->create(utf8_decode($codeUE),
$tdRepo->create($codeUE,
$allProf[$group["professor"]]["dbId"],
$group["VH"],
$formations);
break;
case "TP":
$tpRepo->create(utf8_decode($codeUE),
$tpRepo->create($codeUE,
$allProf[$group["professor"]]["dbId"],
$group["VH"],
$formations);

View File

@ -13,14 +13,15 @@ use database\core\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
$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,
"label" => $label
]);
}
public function delete(int $id) :bool{

View File

@ -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;
}
}

View File

@ -59,6 +59,17 @@
}
},
"departement":{
"errors":{
"GET": {
"des": "Get the list of incoherence of the department",
"per": [],
"par": {
}
}
}
},
"professor":{
"POST": {