diff --git a/manager/career.php b/manager/career.php index f8c7541..f88e206 100755 --- a/manager/career.php +++ b/manager/career.php @@ -107,7 +107,7 @@ require_once __ROOT__.'/manager/database.php'; else $groupe = null; if( $enseignantCheck ){ // si tout les paramètres sont bons - $controle = DataBase::getInstance()->getNotesEnseignant($request->enseignant, $request->controle, $groupe); + $controle = DataBase::getInstance()->getNotesEnseignant($request->enseignant, $_SESSION['semestre_pair'], $_SESSION['annee'], $request->controle, $groupe); if( is_array($controle) ){ // si on a bien un tableau $answer->controle = $controle; // on renvoie dans answer->controle diff --git a/manager/database.php b/manager/database.php index 68def46..ecf9082 100755 --- a/manager/database.php +++ b/manager/database.php @@ -656,21 +656,33 @@ class DataBase{ /********************************************/ /*** retourne les notes pour un contrôle ***/ /********************************************/ - public function getNotesEnseignant($enseignant, $controle, $groupe=null){ // [OPTIONNEL] $groupe + public function getNotesEnseignant($enseignant, $semestre_pair, $annee, $controle, $groupe=null){ // [OPTIONNEL] $groupe - // on récupère l'UID du contrôle, s'il existe - if( $groupe != null ) - if( !($groupeUID=groupRepo::UID($groupe)) ) return 'unknown_group'; else $groupeUID = (int) $groupeUID; - else - $groupeUID = null; // on récupère les informations du contrôle - if( ! ($noteList=controleRepo::info($controle)) ) return 'unknown_controle'; - - $noteList['notes'] = noteRepo::forTeacher($controle, $groupeUID); + if( ! ($controlObj=controleRepo::info($controle)) ) return 'unknown_controle'; + /* [1] si le groupe est donné + =======================================*/ + if( $groupe != null ){ + if( !($groupeUID=groupRepo::UID($groupe)) ) return 'unknown_group'; else $groupeUID = (int) $groupeUID; // on récupère l'UID du groupe - return $noteList; + $controlObj['userlist'] = groupRepo::membres($groupeUID, $controlObj['id_semestre']); // on récupère la liste des étudiants de ce groupe + + foreach($controlObj['userlist'] as $iter=>$note) + if( $resultNote = noteRepo::forStudent($controlObj['userlist'][$iter]['identifiant'], $controle) ) // si l'étudiant a une note pour ce controle + $controlObj['userlist'][$iter]['note'] = $resultNote[0]['valeur']; + else + $controlObj['userlist'][$iter]['note'] = null; + + /* [2] si on veut par groupe + =======================================*/ + }else{ + // on ajoute au controle['notes'] la liste des notes des groupes + $controlObj['grouplist'] = noteRepo::forTeacher($controle, null); + } + + return $controlObj; } diff --git a/manager/repo/controle.php b/manager/repo/controle.php index 91c9267..277b947 100755 --- a/manager/repo/controle.php +++ b/manager/repo/controle.php @@ -19,12 +19,17 @@ class controleRepo extends DBAccess{ */ public static function info($controleUID){ // on considère que le semestre existe - $getControleInfo = DataBase::getPDO()->prepare("SELECT ctrl.id_controle as id, ctrl.id_mcc_module, m.nom as module, m.libelle as modulelib, ctrl.intitule, ctrl.base, ctrl.coefficient, ctrl.date_publication ". - "FROM controle as ctrl, mcc_module as mcc_m, module as m ". + $getControleInfo = DataBase::getPDO()->prepare("SELECT ctrl.id_controle as id, ctrl.id_mcc_module, m.nom as module, m.libelle as modulelib, s.id_semestre, ctrl.intitule, ctrl.base, ctrl.coefficient, ctrl.date_publication, AVG(n.valeur) as moyenne ". + "FROM controle as ctrl, mcc_module as mcc_m, mcc_ue, semestre as s, module as m, note as n ". "WHERE ctrl.id_mcc_module = mcc_m.id_mcc_module ". "AND mcc_m.id_module = m.id_module ". + "AND n.id_controle = ctrl.id_controle ". + "AND mcc_ue.id_mcc_ue = mcc_m.id_mcc_ue ". + "AND mcc_ue.id_semestre = s.id_semestre ". - "AND id_controle = :controleUID"); + "AND ctrl.id_controle = :controleUID ". + + "GROUP BY ctrl.id_controle"); $getControleInfo->execute(array( ':controleUID' => $controleUID )); @@ -75,16 +80,19 @@ class controleRepo extends DBAccess{ * */ public static function forTeacher($enseignant, $module, $semestre){ - $getControleList = DataBase::getPDO()->prepare("SELECT DISTINCT ctrl.id_controle as id, ctrl.id_mcc_module, ctrl.intitule, ctrl.base, ctrl.coefficient, ctrl.date_publication ". - "FROM enseignement as ens, module as m, mcc_module as mcc_m, mcc_ue, controle as ctrl ". + $getControleList = DataBase::getPDO()->prepare("SELECT DISTINCT ctrl.id_controle as id, ctrl.id_mcc_module, ctrl.intitule, ctrl.base, ctrl.coefficient, ctrl.date_publication, AVG(n.valeur) as moyenne ". + "FROM enseignement as ens, module as m, mcc_module as mcc_m, mcc_ue, controle as ctrl, note as n ". "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 n.id_controle = ctrl.id_controle ". "AND ens.id_enseignant = :enseignant ". "AND mcc_m.id_module = :module ". - "AND mcc_ue.id_semestre = :semestre"); + "AND mcc_ue.id_semestre = :semestre ". + + "GROUP BY ctrl.id_controle"); $getControleList->execute(array( ':enseignant' => $enseignant, ':module' => $module, ':semestre' => $semestre )); return DataBase::delNumeric( $getControleList->fetchAll() ); diff --git a/manager/repo/group.php b/manager/repo/group.php index 07cd798..e123353 100755 --- a/manager/repo/group.php +++ b/manager/repo/group.php @@ -182,7 +182,7 @@ class groupRepo extends DBAccess{ */ public static function membres($groupeUID, $semestreUID){ // si le groupe existe => on récupère ses utilisateurs - $getMembres = DataBase::getPDO()->prepare("SELECT u.identifiant, u.prenom, u.nom, u.mail, u.droits, s.nom as semestre ". + $getMembres = DataBase::getPDO()->prepare("SELECT u.identifiant, u.prenom, u.nom, u.mail, u.droits, s.nom as semestre, g.id_groupe, g.nom as groupe ". "FROM utilisateur as u, groupe as g, semestre as s, appartenance as app ". "WHERE u.identifiant = app.id_etudiant ". "AND g.id_groupe = app.id_groupe ". diff --git a/manager/repo/note.php b/manager/repo/note.php index bfa8a9b..363e614 100755 --- a/manager/repo/note.php +++ b/manager/repo/note.php @@ -134,7 +134,7 @@ class noteRepo extends DBAccess{ ============================================================*/ if( !is_int($groupe) ){ - $getNoteList = DataBase::getPDO()->prepare("SELECT DISTINCT g.id_groupe, g.nom as groupe, n.id_note as id, n.id_appartenance, n.id_controle, AVG(n.valeur) as valeur, min(n.valeur) as min, max(n.valeur) as max, COUNT(n.valeur) as nb_notes ". + $getNoteList = DataBase::getPDO()->prepare("SELECT DISTINCT g.id_groupe, g.nom as groupe, n.id_note as id, n.id_appartenance, n.id_controle, AVG(n.valeur) as moyenne, min(n.valeur) as min, max(n.valeur) as max, COUNT(n.valeur) as nb_notes ". "FROM note as n, appartenance as app, semestre as s, controle as ctrl, mcc_ue, mcc_module as mcc_m, groupe as g ". "WHERE n.id_appartenance = app.id_appartenance ". "AND app.id_semestre = s.id_semestre ". diff --git a/page/career.php b/page/career.php index abb8244..6e5d375 100755 --- a/page/career.php +++ b/page/career.php @@ -173,7 +173,7 @@ if( permission('teacher') && $controleOpt == null ){ // si c'est un enseignant e if( count($controle['notes']) == 0 ) // si il y a au moins une note pour ce contrôle echo '
".$answer->controle['module'].' - '.$answer->controle['intitule'].' | '; echo '|||||||||
---|---|---|---|---|---|---|---|---|---|
".$answer->controle['intitule']." | "; echo "".$answer->controle['module']." - ".$answer->controle['modulelib']." | "; - if( count($answer->controle['notes']) == 0 ) // si il y a au moins une note pour ce contrôle - echo 'Pas noté | '; - else - echo 'Moyenne de 10 / 20 | '; - // echo ''.number_format($answer->controle['moyenne'], 2).' | '; - + + /* [1] Affichage par groupes + ====================================================================================*/ + if( $groupeOpt == null ){ + + if( count($answer->controle['grouplist']) == 0 ) // si il y a au moins une note pour ce contrôle + echo 'Pas noté | '; + else + echo 'Moyenne de '.number_format($answer->controle['moyenne'], 2).' / '.$answer->controle['base'].' | '; + + /* [2] Affichage par élèves + ====================================================================================*/ + }else{ + + if( count($answer->controle['userlist']) == 0 ) // si il y a au moins une note pour ce contrôle + echo 'Pas noté | '; + else + echo 'Moyenne de '.number_format($answer->controle['moyenne'], 2).' / '.$answer->controle['base'].' | '; + + } + + echo 'Coefficient '.number_format($answer->controle['coefficient'], 2).' | '; echo '
".$note['groupe']." | "; - - if( $note['nb_notes'] == 1 ) - echo "".$note['nb_notes']." note | "; - else - echo "".$note['nb_notes']." notes | "; - echo "Allant de ".$note['min']." à ".$note['max']." | "; - echo "Moyenne de ".number_format($note['valeur'], 2)." / ".$answer->controle['base']." | "; - - /* 2) s'il s'agit d'afficher par élève */ - }else{ + /* [1] Affichage par groupes + ====================================================================================*/ + if( $groupeOpt == null ){ + + foreach($answer->controle['grouplist'] as $note){ // on affiche la liste des groupes avec leurs stats + echo "|||||
".$note['groupe']." | "; + + if( $note['nb_notes'] == 1 ) + echo "".$note['nb_notes']." note | "; + else + echo "".$note['nb_notes']." notes | "; + + echo "Allant de ".$note['min']." à ".$note['max']." | "; + echo "Moyenne de ".number_format($note['moyenne'], 2)." / ".$answer->controle['base']." | "; + + + echo "|||||
".$user['identifiant']." | "; + echo "".$user['groupe']." | "; + + if( $user['note'] == null ) // si pas de note + echo "".number_format($user['note'], 2)." / ".$answer->controle['base']." | "; + else // si noté + echo "Pas noté | "; - echo "".$note['etudiant']." | "; - echo "".$note['groupe']." | "; - echo "".number_format($note['valeur'], 2)." / ".$answer->controle['base']." | "; echo ""; - } + echo " |