Import MCC intégration des contrôles -> tout fonctionnel
This commit is contained in:
parent
6b05ff417f
commit
47754ac076
|
@ -112,8 +112,8 @@ class DataBase{
|
||||||
|
|
||||||
foreach($module['controles'] as $controle){
|
foreach($module['controles'] as $controle){
|
||||||
|
|
||||||
// $controle = controleRepo::forMCC($mcc_module, $controle['nom'], $controle['libelle'], $controle['coefficient']);
|
$controle_uid = controleRepo::forMCC($mcc_module, $controle['nom'], $controle['libelle'], $controle['coefficient']);
|
||||||
|
// var_dump( $controle_uid );
|
||||||
// echo '    '.$controle['nom'].'<br>';
|
// echo '    '.$controle['nom'].'<br>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,4 +128,66 @@ class controleRepo extends DBAccess{
|
||||||
return DataBase::delNumeric( $getControleList->fetchAll() );
|
return DataBase::delNumeric( $getControleList->fetchAll() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* 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ÉÉ
|
||||||
|
=====================================================*/
|
||||||
|
echo "$mcc_module|$nom|$libelle|$coefficient<br>";
|
||||||
|
$creerControle = DataBase::getPDO()->prepare("INSERT INTO controle(id_controle, id_mcc_module, nom, libelle, coefficient, date_publication)
|
||||||
|
VALUES(DEFAULT, :mcc_module, :nom, :libelle, :coefficient, NOW())");
|
||||||
|
$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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -205,7 +205,7 @@ class moduleRepo extends DBAccess{
|
||||||
$getModuleUID = DataBase::getPDO()->prepare("SELECT id_module as id FROM module WHERE nom = :nom AND libelle = :libelle");
|
$getModuleUID = DataBase::getPDO()->prepare("SELECT id_module as id FROM module WHERE nom = :nom AND libelle = :libelle");
|
||||||
$getModuleUID->execute(array( ':nom' => $nom, ':libelle' => $libelle ));
|
$getModuleUID->execute(array( ':nom' => $nom, ':libelle' => $libelle ));
|
||||||
|
|
||||||
while( !$moduleUID = $getModuleUID->fetch()['id'] ){ // on vérifie l'existence de cet UE
|
while( !$moduleUID = $getModuleUID->fetch()['id'] ){ // on vérifie l'existence de ce module
|
||||||
|
|
||||||
/* [1] SI LE MODULE N'EXISTE PAS => ON LE CRÉÉ
|
/* [1] SI LE MODULE N'EXISTE PAS => ON LE CRÉÉ
|
||||||
=====================================================*/
|
=====================================================*/
|
||||||
|
|
|
@ -490,7 +490,7 @@ if( permission('admin') ){ // si l'utilisateur est un admin
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if( false && permission('admin') ){
|
if( permission('admin') ){
|
||||||
require_once __ROOT__.'/manager/phpExcel.php';
|
require_once __ROOT__.'/manager/phpExcel.php';
|
||||||
require_once __ROOT__.'/manager/database.php';
|
require_once __ROOT__.'/manager/database.php';
|
||||||
|
|
||||||
|
@ -509,7 +509,7 @@ if( false && permission('admin') ){
|
||||||
|
|
||||||
$semestre = 1;
|
$semestre = 1;
|
||||||
|
|
||||||
// var_dump( DataBase::getInstance()->setMCC($semestre, $answer->mcc) );
|
var_dump( DataBase::getInstance()->setMCC($semestre, $answer->mcc) );
|
||||||
|
|
||||||
echo "</section>";
|
echo "</section>";
|
||||||
}else
|
}else
|
||||||
|
|
Loading…
Reference in New Issue