Ajout de l'affichage des étudiants même s'ils n'ont pas de note

This commit is contained in:
xdrm-brackets 2015-11-15 12:15:30 +01:00
parent 6d24b03256
commit e51c344356
6 changed files with 100 additions and 48 deletions

View File

@ -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

View File

@ -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';
if( ! ($controlObj=controleRepo::info($controle)) ) return 'unknown_controle';
$noteList['notes'] = noteRepo::forTeacher($controle, $groupeUID);
/* [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
$controlObj['userlist'] = groupRepo::membres($groupeUID, $controlObj['id_semestre']); // on récupère la liste des étudiants de ce groupe
return $noteList;
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;
}

View File

@ -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() );

View File

@ -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 ".

View File

@ -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 ".

View File

@ -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 '<td><span class=unstressed>Pas noté</span></td>';
else
echo '<td><span class=unstressed>Moyenne de</span> 10 <span class=unstressed>/</span> 20</td>';
echo '<td><span class=unstressed>Moyenne de</span> '.number_format($controle['moyenne'], 2).' <span class=unstressed>/</span> '.$controle['base'].'</td>';
// echo '<td>'.number_format($controle['moyenne'], 2).'</td>';
echo '<td><span class=unstressed>Coefficient</span> '.number_format($controle['coefficient'], 2).'</td>';
@ -242,17 +242,34 @@ elseif( permission('teacher') ){ // si enseignant et qu'un contrôle est spécif
echo "<table class='basic col4'><thead>";
echo "<th colspan=5 style='font-size:1.5em; text-align:center;'>".$answer->controle['module'].' - '.$answer->controle['intitule'].'</th>';
echo '<tr>';
echo "<th><span class='link ctrl' data-ctrl='".$answer->controle['id']."'>".$answer->controle['intitule']."</span></th>";
echo "<th>".$answer->controle['module']." - ".$answer->controle['modulelib']."</th>";
if( count($answer->controle['notes']) == 0 ) // si il y a au moins une note pour ce contrôle
echo '<th><span class=unstressed>Pas noté</span></th>';
else
echo '<th><span class=unstressed>Moyenne de</span> 10 <span class=unstressed>/</span> 20</th>';
// echo '<th>'.number_format($answer->controle['moyenne'], 2).'</th>';
/* [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 '<th><span class=unstressed>Pas noté</span></th>';
else
echo '<th><span class=unstressed>Moyenne de</span> '.number_format($answer->controle['moyenne'], 2).' <span class=unstressed>/</span> '.$answer->controle['base'].'</th>';
/* [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 '<th><span class=unstressed>Pas noté</span></th>';
else
echo '<th><span class=unstressed>Moyenne de</span> '.number_format($answer->controle['moyenne'], 2).' <span class=unstressed>/</span> '.$answer->controle['base'].'</th>';
}
echo '<th><span class=unstressed>Coefficient</span> '.number_format($answer->controle['coefficient'], 2).'</th>';
@ -260,33 +277,48 @@ elseif( permission('teacher') ){ // si enseignant et qu'un contrôle est spécif
echo "<tbody>";
foreach($answer->controle['notes'] as $note){ // on affiche la liste des élèves avec leurs notes
echo "<tr>";
/* 1) s'il s'agit d'afficher par groupe */
if( isset($note['nb_notes']) ){
/* [1] Affichage par groupes
====================================================================================*/
if( $groupeOpt == null ){
echo "<td><span class='link grp ctrl' data-grp='".$note['groupe']."' data-ctrl='".$answer->controle['id']."'>".$note['groupe']."</span></td>";
foreach($answer->controle['grouplist'] as $note){ // on affiche la liste des groupes avec leurs stats
echo "<tr>";
if( $note['nb_notes'] == 1 )
echo "<td>".$note['nb_notes']." <span class=unstressed>note</span></td>";
else
echo "<td>".$note['nb_notes']." <span class=unstressed>notes</span></td>";
echo "<td><span class='link grp ctrl' data-grp='".$note['groupe']."' data-ctrl='".$answer->controle['id']."'>".$note['groupe']."</span></td>";
echo "<td><span class=unstressed>Allant de</span> ".$note['min']." <span class=unstressed>à</span> ".$note['max']."</td>";
echo "<td><span class=unstressed>Moyenne de </span>".number_format($note['valeur'], 2)." <span class=unstressed>/</span> ".$answer->controle['base']."</td>";
if( $note['nb_notes'] == 1 )
echo "<td>".$note['nb_notes']." <span class=unstressed>note</span></td>";
else
echo "<td>".$note['nb_notes']." <span class=unstressed>notes</span></td>";
/* 2) s'il s'agit d'afficher par élève */
}else{
echo "<td><span class=unstressed>Allant de</span> ".$note['min']." <span class=unstressed>à</span> ".$note['max']."</td>";
echo "<td><span class=unstressed>Moyenne de </span>".number_format($note['moyenne'], 2)." <span class=unstressed>/</span> ".$answer->controle['base']."</td>";
echo "</tr>";
}
/* [2] Affichage par élèves
====================================================================================*/
}else{
foreach($answer->controle['userlist'] as $user){ // on affiche la liste des élèves avec leurs notes
echo "<tr>";
echo "<td><span class='link etu' data-etu='".$user['identifiant']."' data-ctrl='".$answer->controle['id']."'>".$user['identifiant']."</span></td>";
echo "<td><span class='link grp' data-grp='".$user['groupe']."'>".$user['groupe']."</span></td>";
if( $user['note'] == null ) // si pas de note
echo "<td>".number_format($user['note'], 2)." <span class=unstressed>/</span> ".$answer->controle['base']."</td>";
else // si noté
echo "<td><span class=unstressed>Pas noté</span></td>";
echo "<td><span class='link etu' data-etu='".$note['etudiant']."' data-ctrl='".$answer->controle['id']."'>".$note['etudiant']."</span></td>";
echo "<td><span class='link grp' data-grp='".$note['groupe']."'>".$note['groupe']."</span></td>";
echo "<td>".number_format($note['valeur'], 2)." <span class=unstressed>/</span> ".$answer->controle['base']."</td>";
echo "<td></td>";
}
echo "</tr>";
}
echo "</tr>";
}
echo '</tbody></table>';