2015-11-12 10:19:58 +00:00
|
|
|
<?php require_once __ROOT__.'/manager/security.php';
|
|
|
|
|
|
|
|
/************************************************************************************/
|
|
|
|
/* ____ ___ _ _ _____ ____ ___ _ _____ ____ _____ ____ ___ */
|
|
|
|
/* / ___/ _ \| \ | |_ _| _ \ / _ \| | | ____| | _ \| ____| _ \ / _ \ */
|
|
|
|
/* | | | | | | \| | | | | |_) | | | | | | _| | |_) | _| | |_) | | | | */
|
|
|
|
/* | |__| |_| | |\ | | | | _ <| |_| | |___| |___ | _ <| |___| __/| |_| | */
|
|
|
|
/* \____\___/|_| \_| |_| |_| \_\\___/|_____|_____| |_| \_\_____|_| \___/ */
|
|
|
|
/* */
|
|
|
|
/************************************************************************************/
|
|
|
|
|
|
|
|
class controleRepo extends DBAccess{
|
|
|
|
/* RENVOIE LES INFORMATIONS D'UN CONTROLE D'UID DONNÉ
|
|
|
|
*
|
|
|
|
* @controleUID<int> l'UID du controle duquel on veut les infos
|
|
|
|
*
|
2015-11-26 18:06:27 +00:00
|
|
|
* @enseignant<String> ***OPTIONNEL*** l'UID de l'enseignant
|
2015-11-19 07:58:15 +00:00
|
|
|
*
|
|
|
|
*
|
2015-11-14 17:33:06 +00:00
|
|
|
* @return controle<Array> tableau associatif contenant tout les champs de la BDD pour ce controle
|
2015-11-12 10:19:58 +00:00
|
|
|
*
|
|
|
|
*/
|
2015-12-01 17:15:44 +00:00
|
|
|
public static function info($controleUID, $enseignant=null, $groupe=null){
|
2015-11-19 07:58:15 +00:00
|
|
|
if( $enseignant == null ){
|
|
|
|
|
|
|
|
/* [1] On cherche juste le contrôle avec l'id spécifié
|
|
|
|
============================================================*/
|
|
|
|
|
2015-11-20 16:13:47 +00:00
|
|
|
$getControleInfo = DataBase::getPDO()->prepare("SELECT ctrl.id_controle as id, ctrl.nom, ctrl.id_mcc_module, m.nom as module, m.libelle as modulelib, s.id_semestre, ctrl.libelle, ctrl.base, ctrl.coefficient, ctrl.date_publication
|
2015-11-19 07:58:15 +00:00
|
|
|
FROM controle as ctrl, mcc_module as mcc_m, mcc_ue, semestre as s, module as m
|
|
|
|
WHERE ctrl.id_mcc_module = mcc_m.id_mcc_module
|
|
|
|
AND mcc_m.id_module = m.id_module
|
|
|
|
AND mcc_ue.id_mcc_ue = mcc_m.id_mcc_ue
|
|
|
|
AND mcc_ue.id_semestre = s.id_semestre
|
|
|
|
|
|
|
|
AND ctrl.id_controle = :controleUID
|
|
|
|
|
|
|
|
GROUP BY ctrl.id_controle");
|
|
|
|
$getControleInfo->execute(array(
|
|
|
|
':controleUID' => $controleUID
|
|
|
|
));
|
|
|
|
|
|
|
|
}else{ // cas où on cherche un contrôle qu'un enseignant corrige
|
2015-12-01 17:15:44 +00:00
|
|
|
$groupeUID = (is_numeric($groupe)) ? $groupe : '%';
|
2015-11-19 07:58:15 +00:00
|
|
|
|
|
|
|
/* [2] On cherche le contrôle avec l'id spécifié qu'enseignant l'@enseignant
|
|
|
|
==============================================================================*/
|
2015-11-20 16:13:47 +00:00
|
|
|
$getControleInfo = DataBase::getPDO()->prepare("SELECT ctrl.id_controle as id, ctrl.nom, ctrl.id_mcc_module, m.nom as module, m.libelle as modulelib, s.id_semestre, ctrl.libelle, ctrl.base, ctrl.coefficient, ctrl.date_publication
|
2015-11-19 07:58:15 +00:00
|
|
|
FROM controle as ctrl, mcc_module as mcc_m, mcc_ue, semestre as s, module as m, enseignement as ens
|
|
|
|
WHERE ctrl.id_mcc_module = mcc_m.id_mcc_module
|
|
|
|
AND mcc_m.id_module = m.id_module
|
|
|
|
AND mcc_ue.id_mcc_ue = mcc_m.id_mcc_ue
|
|
|
|
AND mcc_ue.id_semestre = s.id_semestre
|
|
|
|
AND ens.id_mcc_module = mcc_m.id_mcc_module
|
|
|
|
AND ens.correcteur = 1
|
|
|
|
AND ens.id_enseignant = :enseignant
|
2015-12-01 17:15:44 +00:00
|
|
|
AND ens.id_groupe LIKE '$groupeUID'
|
2015-11-19 07:58:15 +00:00
|
|
|
|
|
|
|
AND ctrl.id_controle = :controleUID
|
|
|
|
|
|
|
|
GROUP BY ctrl.id_controle");
|
|
|
|
$getControleInfo->execute(array(
|
|
|
|
':enseignant' => $enseignant,
|
|
|
|
':controleUID' => $controleUID
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2015-11-12 10:19:58 +00:00
|
|
|
|
2015-11-27 07:45:59 +00:00
|
|
|
|
|
|
|
$ctrlInfo = $getControleInfo->fetch();
|
|
|
|
|
|
|
|
if( !is_bool($ctrlInfo) ) // on retourne le résultat en supprimant les doublons à indices numériques s'il est ok
|
|
|
|
return DataBase::delNumeric( $ctrlInfo, true );
|
|
|
|
else
|
|
|
|
return array();
|
2015-11-12 10:19:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* RENVOIE LES CONTROLES POUR UN MODULE ET SEMESTRE PARTICULIER
|
|
|
|
*
|
|
|
|
* @module<int> l'UID du module concerné
|
|
|
|
* @semestre<int> l'UID du semestre concerné
|
|
|
|
*
|
|
|
|
* @return controles<Array> retourne les controles d'un étudiant pour un controle particulier
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function forStudent($module, $semestre){
|
2015-11-20 16:13:47 +00:00
|
|
|
$getControleList = DataBase::getPDO()->prepare("SELECT DISTINCT ctrl.id_controle as id, ctrl.nom, ctrl.id_mcc_module, ctrl.libelle, ctrl.base, ctrl.coefficient, ctrl.date_publication
|
2015-11-17 12:00:50 +00:00
|
|
|
FROM controle as ctrl, module as m, mcc_module as mcc_m, mcc_ue, semestre as s
|
|
|
|
WHERE ctrl.id_mcc_module = mcc_m.id_mcc_module
|
|
|
|
AND mcc_m.id_mcc_ue = mcc_ue.id_mcc_ue
|
|
|
|
AND mcc_ue.id_semestre = s.id_semestre
|
|
|
|
|
|
|
|
AND mcc_m.id_module = :module
|
|
|
|
AND s.id_semestre = :semestre");
|
2015-11-12 10:19:58 +00:00
|
|
|
$getControleList->execute(array( ':module' => $module, ':semestre' => $semestre ));
|
|
|
|
|
|
|
|
return DataBase::delNumeric( $getControleList->fetchAll() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-11-13 18:07:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* RENVOIE LES CONTROLES QU'UN ENSEIGNANT PEUT CORRIGER POUR UN MODULE ET SEMESTRE PARTICULIER
|
|
|
|
*
|
|
|
|
* @enseignant<String> l'identifiant de l'enseignant
|
|
|
|
* @module<int> l'UID du module concerné
|
|
|
|
* @semestre<int> l'UID du semestre concerné
|
|
|
|
*
|
|
|
|
* @return controles<Array> retourne les controles q'un enseignant peut corriger pour un module d'un semestre
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function forTeacher($enseignant, $module, $semestre){
|
2015-11-20 16:13:47 +00:00
|
|
|
$getControleList = DataBase::getPDO()->prepare("SELECT DISTINCT ctrl.id_controle as id, ctrl.nom, ctrl.id_mcc_module, ctrl.libelle, ctrl.base, ctrl.coefficient, ctrl.date_publication
|
2015-11-17 12:00:50 +00:00
|
|
|
FROM enseignement as ens, module as m, mcc_module as mcc_m, mcc_ue, controle as ctrl
|
|
|
|
WHERE ens.id_mcc_module = mcc_m.id_mcc_module
|
|
|
|
AND mcc_m.id_mcc_module = ctrl.id_mcc_module
|
|
|
|
AND mcc_m.id_module = m.id_module
|
|
|
|
AND mcc_ue.id_mcc_ue = mcc_m.id_mcc_ue
|
|
|
|
|
|
|
|
AND ens.id_enseignant = :enseignant
|
|
|
|
AND mcc_m.id_module = :module
|
|
|
|
AND mcc_ue.id_semestre = :semestre
|
|
|
|
|
|
|
|
GROUP BY ctrl.id_controle");
|
2015-11-13 18:07:36 +00:00
|
|
|
$getControleList->execute(array( ':enseignant' => $enseignant, ':module' => $module, ':semestre' => $semestre ));
|
|
|
|
|
|
|
|
return DataBase::delNumeric( $getControleList->fetchAll() );
|
|
|
|
}
|
|
|
|
|
2015-11-20 21:07:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-11-26 17:17:05 +00:00
|
|
|
/* RENVOIE LES CONTROLES POUR UN MODULE ET SEMESTRE PARTICULIER
|
|
|
|
*
|
|
|
|
* @module<int> l'UID du module concerné
|
|
|
|
* @semestre<int> l'UID du semestre concerné
|
|
|
|
*
|
|
|
|
* @return controles<Array> retourne les controles pour un module d'un semestre
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function forYear($module, $semestre){
|
|
|
|
$getControleList = DataBase::getPDO()->prepare("SELECT DISTINCT ctrl.id_controle as id, ctrl.nom, ctrl.id_mcc_module, ctrl.libelle, ctrl.base, ctrl.coefficient, ctrl.date_publication
|
|
|
|
FROM module as m, mcc_module as mcc_m, mcc_ue, controle as ctrl
|
|
|
|
WHERE mcc_m.id_mcc_module = ctrl.id_mcc_module
|
|
|
|
AND mcc_m.id_module = m.id_module
|
|
|
|
AND mcc_ue.id_mcc_ue = mcc_m.id_mcc_ue
|
|
|
|
|
|
|
|
AND mcc_m.id_module = :module
|
|
|
|
AND mcc_ue.id_semestre = :semestre
|
|
|
|
|
|
|
|
GROUP BY ctrl.id_controle");
|
|
|
|
$getControleList->execute(array( ':module' => $module, ':semestre' => $semestre ));
|
|
|
|
|
|
|
|
return DataBase::delNumeric( $getControleList->fetchAll() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-11-20 21:07:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* retourne l'UID d'un contrôle s'il existe sinon créé tout ce qui a besoin et on retourne l'UID
|
|
|
|
*
|
|
|
|
* @mcc_module<int> l'UID du mcc_module en question
|
|
|
|
* @nom<String> le code du contrôle en question
|
|
|
|
* @libelle<String> le libellé du contrôle en question
|
|
|
|
* @coefficient<Float> le coefficient du contrôle en question dans le mcc_module en question
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return UID<int> retourne l'UID du CONTRÔLE si tout s'est bien passé
|
|
|
|
* @return FALSE<Boolean> retourne FALSE s'il y a eu une erreur
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function forMCC($mcc_module, $nom, $libelle, $coefficient){
|
|
|
|
$count = 0; $maxLoop = 2;
|
|
|
|
|
|
|
|
/* ON VÉRIFIE QUE L'UE EN LUI-MÊME (NOM/LIBELLÉ) EXISTE DANS LA BDD */
|
|
|
|
$getControleUID = DataBase::getPDO()->prepare("SELECT ctrl.id_controle as id
|
|
|
|
FROM mcc_module as mcc_m, controle as ctrl
|
|
|
|
WHERE ctrl.id_mcc_module = mcc_m.id_mcc_module
|
|
|
|
AND mcc_m.id_mcc_module = :mcc_module
|
|
|
|
AND ctrl.nom = :nom
|
|
|
|
AND ctrl.libelle = :libelle
|
|
|
|
AND ctrl.coefficient = :coefficient");
|
|
|
|
$getControleUID->execute(array( ':mcc_module' => $mcc_module, ':nom' => $nom, ':libelle' => $libelle, ':coefficient' => $coefficient ));
|
|
|
|
|
|
|
|
while( !$controleUID = $getControleUID->fetch()['id'] ){ // on vérifie l'existence de ce contrôle
|
|
|
|
|
|
|
|
/* [1] SI LE CONTRÔLE N'EXISTE PAS => ON LE CRÉÉ
|
|
|
|
=====================================================*/
|
2015-11-21 12:10:08 +00:00
|
|
|
$creerControle = DataBase::getPDO()->prepare("INSERT INTO controle(id_controle, id_mcc_module, nom, libelle, base, coefficient, date_publication)
|
|
|
|
VALUES(DEFAULT, :mcc_module, :nom, :libelle, 20, :coefficient, NOW())");
|
2015-11-20 21:07:02 +00:00
|
|
|
$creerControle->execute(array( ':mcc_module' => $mcc_module, ':nom' => $nom, ':libelle' => $libelle, ':coefficient' => $coefficient ));
|
|
|
|
|
|
|
|
/* ON VÉRIFIE QUE LE MODULE APPARTIENT AU MCC DE CE MCC_UE */
|
|
|
|
$getControleUID = DataBase::getPDO()->prepare("SELECT ctrl.id_controle as id
|
|
|
|
FROM mcc_module as mcc_m, controle as ctrl
|
|
|
|
WHERE ctrl.id_mcc_module = mcc_m.id_mcc_module
|
|
|
|
AND mcc_m.id_mcc_module = :mcc_module
|
|
|
|
AND ctrl.nom = :nom
|
|
|
|
AND ctrl.libelle = :libelle
|
|
|
|
AND ctrl.coefficient = :coefficient");
|
|
|
|
$getControleUID->execute(array( ':mcc_module' => $mcc_module, ':nom' => $nom, ':libelle' => $libelle, ':coefficient' => $coefficient ));
|
|
|
|
|
|
|
|
if( $count >= $maxLoop ) return false;
|
|
|
|
$count++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// on retourne enfin l'UID du mcc_ue en question
|
|
|
|
return $controleUID;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-11-12 10:19:58 +00:00
|
|
|
}
|