diff --git a/manager/database.php b/manager/database.php index 2434a5f..df8eb43 100755 --- a/manager/database.php +++ b/manager/database.php @@ -548,6 +548,7 @@ class DataBase{ $UEList[$iter_ue]['modules'][$iter_mod]['controles'][$iter_ct]['grouplist'] = noteRepo::forTeacher($UEList[$iter_ue]['modules'][$iter_mod]['controles'][$iter_ct]['id']); $UEList[$iter_ue]['modules'][$iter_mod]['controles'][$iter_ct]['moyenne'] = noteRepo::moyenneForControle($UEList[$iter_ue]['modules'][$iter_mod]['controles'][$iter_ct]['id']); + } } @@ -568,10 +569,8 @@ class DataBase{ // on récupère les informations du contrôle if( ! ($controlObj=controleRepo::info($controle)) ) return 'unknown_controle'; - if( $moyenneObj = noteRepo::moyenneForControle($controle) ) - $controlObj['moyenne'] = $moyenneObj['moyenne']; - else - $controlObj['moyenne'] = null; + // on ajoute la moyenne au contrôle + $controlObj['moyenne'] = noteRepo::moyenneForControle($controlObj['id']); /* [1] si le groupe est donné =======================================*/ diff --git a/manager/repo/note.php b/manager/repo/note.php index 861aa69..550f035 100755 --- a/manager/repo/note.php +++ b/manager/repo/note.php @@ -198,7 +198,7 @@ class noteRepo extends DBAccess{ * */ public static function moyenneForControle($controle){ - $getMoyenne = DataBase::getPDO()->prepare("SELECT AVG(n.valeur) as moyenne ". + $getMoyenne = DataBase::getPDO()->prepare("SELECT ctrl.id_controle, AVG(n.valeur) as moyenne ". "FROM controle as ctrl, note as n ". "WHERE ctrl.id_controle = n.id_controle ". "AND ctrl.id_controle = :controle ".