91 lines
2.8 KiB
PHP
91 lines
2.8 KiB
PHP
|
<?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;
|
||
|
}
|
||
|
|
||
|
}
|