<?
include("../BarreDeMenu.php3");
include("fonctions_moyenne.php3");
include("../security.php");
// Entete
buildHeader("Relevé de notes");
// Verification de la session
$autorisation_list[0]=1; // Professeur
$user_type = validateSession($id_session);
if ($user_type == -1 || !security($id_session,$autorisation_list)) print("Accès refusé");
else
{
// Barre de menu
buildMenuBar($id_session,$user_type,"gdn/consulter_notes.php3",false);
// Ouverture de la connexion
$connection = openConnection($databaseName);
if (!isset($index)) $index=0;
//***********************************************************************************************
//* Debut du formulaire
//***********************************************************************************************
print("<form name=\"form1\" action=\"consulter_notes.php3\" method=post>\n");
print(" <input type=\"hidden\" name=\"login\" value=\"$login\">\n");
print(" <input type=\"hidden\" name=\"index\" value=\"$index\">\n");
print(" <input type=\"hidden\" name=\"id_session\" value=\"$id_session\">\n");
print(" <input type=\"hidden\" name=\"user_type\" value=\"$user_type\">\n");
print(" <input type=\"hidden\" name=\"user_id\" value=\"$user_id\">\n");
print(" <input type=\"hidden\" name=\"display\" value=\"$display\">\n");
print(" <input type=\"hidden\" name=\"mat\" value=\"$mat\">\n");
print(" <input type=\"hidden\" name=\"promo\" value=\"$promo\">\n");
//***********************************************************************************************
//******** PREMIERE ETAPE : SELECTION DE LA PROMOTION ET DE LA PERIODE *********
//***********************************************************************************************
if($index<3){
// liste des promotions
$result2 = mysql_query("SELECT id_promotion, sigle FROM promotion ");
print(" <table align=center border=0 cellspacing=0 cellpading=0 bgcolor=\"#C0C000\">\n");
print(" <tr>\n");
print(" <td>\n");
print(" <font size=3><i>Promotion : </i></font> \n");
print(" </td>\n");
print(" <td>\n");
print(" <SELECT tabindex=-1 NAME=\"promo\" onChange=\"index.value=2;submit();\"> \n");
if(!isset($promo)) print(" <OPTION SELECTED > </option> \n");
for($i=0;$i<mysql_num_rows($result2);$i++){
$temp = mysql_fetch_row($result2);
if(isset($promo) && $temp[0]==$promo)
print(" <OPTION SELECTED VALUE=$temp[0]> $temp[1] \n");
else
print(" <OPTION VALUE=$temp[0]> $temp[1] \n");
}
print(" </SELECT> \n");
print(" </td>\n");
print(" </tr>\n");
if($index==2){
// liste des matieres :
$result3 = mysql_query("SELECT DISTINCT m.id_matiere, m.nom FROM matiere m, suiviparpromotion spp, suivipargroupe spg, associer a WHERE (spp.id_promotion=$promo AND spp.id_matiere=m.id_matiere) OR (spg.id_matiere=m.id_matiere AND spg.id_groupe=a.id_groupe AND a.id_promotion=$promo)");
print(" <tr>\n");
print(" <td>\n");
print(" <font size=3><i>Matière : </i></font> \n");
print(" </td>\n");
print(" <td>\n");
print(" <SELECT size=1 tabindex=-1 NAME=\"mat\" onChange=\"index.value=3;submit();\"> \n");
print(" <OPTION SELECTED > </option> \n");
for($i=0;$i<mysql_num_rows($result3);$i++){
$temp = mysql_fetch_row($result3);
print(" <OPTION VALUE=$temp[0]> $temp[1] \n");
}
print(" </SELECT> \n");
print(" </td>\n");
print(" </tr>\n");
}
print(" </table> \n");
}// fin index==1 ou 2
//***********************************************************************************************
//******** DEUXIEME ETAPE : AFFICHAGE DES NOTES CORRESPONDANTES *********
//***********************************************************************************************
if($index==3){
$res = mysql_query("SELECT moyenne.id_etudiant, moyenne.moyenne FROM moyenne, appartient, associer WHERE moyenne.id_matiere=$mat AND moyenne.id_etudiant=appartient.id_etudiant AND appartient.id_groupe=associer.id_groupe AND associer.id_promotion=$promo");
if(mysql_num_rows($res)==0) $moyennes = -1;
$result = mysql_query("SELECT G.id_groupe, G.nom FROM groupe G, suivipargroupe spg, associer a WHERE G.id_groupe=spg.id_groupe AND spg.id_matiere=$mat AND spg.id_groupe=a.id_groupe AND a.id_promotion=$promo ");
if(mysql_num_rows($result)!=0){
$info_groupe = mysql_fetch_row($result);
$id_groupe = $info_groupe[0];
}else{
$id_groupe = -1;
}
// affichage du nom de la matiere et de la promotion :
$result_b = mysql_query("SELECT matiere.nom, promotion.libelle, periode.numero, numero_semaine_debut, nb_semaines FROM promotion, matiere, periode WHERE promotion.id_promotion=$promo AND matiere.id_matiere=$mat AND periode.id_periode=matiere.id_periode");
$infos = mysql_fetch_row($result_b);
print(" <DIV ALIGN=left><I><U>Matière :</U> $infos[0]<br><U>Période :</U> $infos[2] (commence sem. $infos[3] et s'étend sur $infos[4] sem.)<br><U>Promotion :</U> $infos[1]<br>\n");
if($id_groupe!=-1) print(" <U>Groupe :</U> $info_groupe[1] <br> \n");
print(" </I></DIV><br> \n");
// liste des notes se rapportant a la promotion (ou au groupe) :
if($id_groupe!=-1)
$result = mysql_query("SELECT DISTINCT note.id_note, note.libelle, note.coefficient, note.rapport, DATE_FORMAT(note.date,'%d/%m/%Y'), note.id_typenote FROM note, suivipargroupe ANAG WHERE note.id_matiere=$mat AND ANAG.id_matiere=$mat AND ANAG.id_groupe=$id_groupe ORDER BY id_typenote, date");
else
$result = mysql_query("SELECT DISTINCT note.id_note, note.libelle, note.coefficient, note.rapport, DATE_FORMAT(note.date,'%d/%m/%Y'), note.id_typenote FROM note, suiviparpromotion ANAG WHERE note.id_matiere=$mat AND ANAG.id_matiere=$mat AND ANAG.id_promotion=$promo ORDER BY id_typenote, date");
print(" <table align=center border=1 cellspacing=0 cellpading=0 width=100%> \n");
print(" <tr> \n");
print(" <td> </td> \n");
$nb_notes = mysql_num_rows($result);
for($i=0;$i<$nb_notes;$i++){
$note = mysql_fetch_row($result);
$id_notes[$i] = $note[0];
$coefficient[$i] = $note[2];
$rapport[$i] = $note[3];
print(" <td align=center width=70> <font size=2 face=arial><b> $note[1] </b></font> <br> <font size=1 face=arial>($note[4])</font> </td> \n");
}
// si pas bcp de notes (- de 5) on rajoute des colonnes vides
for($i=$nb_notes;$i<=5;$i++) print(" <td align=center width=70> </td> \n");
if($moyennes!=-1)
print(" <td align=center width=70> <font size=2 face=arial><b>Moyenne</b></font> </td> \n");
print(" </tr> \n");
// liste des etudiants de la promotion (ou du groupe) :
if($id_groupe!=-1)
$result = mysql_query("SELECT E.id_etudiant, UPPER(E.nom), E.prenom FROM etudiant E, appartient AP, associer ASS WHERE E.id_etudiant=AP.id_etudiant AND AP.id_groupe=$id_groupe AND AP.id_groupe=ASS.id_groupe AND ASS.id_promotion=$promo ORDER BY E.nom, E.prenom");
else
$result = mysql_query("SELECT E.id_etudiant, UPPER(E.nom), E.prenom FROM etudiant E, inscrit I WHERE E.id_etudiant=I.id_etudiant AND I.id_promotion=$promo ORDER BY E.nom, E.prenom");
$nb_etu = mysql_num_rows($result);
for($k=0;$k<$nb_notes;$k++){
// initialisations des tableaux qui serviront à calculer la moyenne de la classe pour chaque epreuve :
$sommes_notes[$k] = 0.0;
$sommes_etudiants[$k] = 0.0;
}
for($i=0;$i<mysql_num_rows($result);$i++){
$etudiant = mysql_fetch_row($result);
// génération de la requete qui va trouver les notes de l'etudiant :
$requete = "SELECT id_note, note FROM avoirUneNote WHERE id_etudiant=$etudiant[0]";
for($j=0;$j<$nb_notes;$j++){
if($j==0) $requete .= " AND ( ";
else $requete .= " or " ;
$requete .= " id_note=$id_notes[$j] " ;
if($j==$nb_notes-1) $requete .= " ) ORDER BY id_note";
}
$result2 = mysql_query($requete);
for($k=0;$k<$nb_notes;$k++) $notes_etudiant[$k]=""; // initialisation du tableau de notes
for($k=0;$k<mysql_num_rows($result2);$k++){
$note = mysql_fetch_row($result2);
// on met toutes les notes de l'etudiant dans le tableau $notes_etudiant
for($t=0;$t<$nb_notes;$t++){
if($note[0]==$id_notes[$t]) $notes_etudiant[$t]=$note[1];
}
}
// maintenant :
// le tableau $id_notes[] contient la liste des 'id_notes'
// le tableau $coefficient[] contient les coefficients des notes correspondantes
// le tableau $rapport[] contient le rapport de chacune des notes
// et le tableau $notes_etudiant[] contient les notes de l'etudiant en cours pour chacune des notes du tableau $id_notes[]
print(" <tr> \n");
print(" <td align=left> $etudiant[1] $etudiant[2] </td> \n");
for($k=0;$k<$nb_notes;$k++){
print(" <td align=center><font size=2 face=arial> ");
if($notes_etudiant[$k]==-1) print(" abs ");
else{
if($notes_etudiant[$k]==-2) print(" <font color=red>def</font> ");
else{
print(" $notes_etudiant[$k] ");
if($notes_etudiant[$k]!=""){
$sommes_notes[$k] += $notes_etudiant[$k];
$sommes_etudiants[$k]+= 1.0;
}
}
}
print(" </font></td> \n");
}
// si pas bcp de notes (- de 5) on rajoute des colonnes vides
for($k=$nb_notes;$k<=5;$k++) print(" <td > </td> \n");
$moy = "";
if($moyenne!=-1){
$tmp = mysql_query("SELECT moyenne FROM moyenne WHERE id_etudiant=$etudiant[0] AND id_matiere=$mat");
$res_tmp = mysql_fetch_row($tmp);
$moy = $res_tmp[0];
if($moy<0) $moy = "def";
print(" <td align=center><font size=2 face=arial> $moy </font></td> \n");
}
print(" </tr> \n");
}
// derniere ligne du tableau : les moyennes de chaque epreuve
print(" <tr> \n");
print(" <td align=left><font size=2 face=arial> <b>Moyennes des épreuves</b> </font></td> \n");
for($k=0;$k<$nb_notes;$k++){
print(" <td align=center><font size=2 face=arial> ");
if($sommes_etudiants[$k]==0) print(" - ");
else{
$moy_epreuve = $sommes_notes[$k] / $sommes_etudiants[$k];
$moy_epreuve = sprintf ("%01.2f", $moy_epreuve);
print(" <b>$moy_epreuve</b> ");
}
print("</td> \n");
}
// si pas bcp de notes (- de 5) on rajoute des colonnes vides
for($k=$nb_notes;$k<=5;$k++) print(" <td > </td> \n");
if($moyennes!=-1){
$temp = mysql_query("SELECT moyenne FROM moyennepromotion WHERE id_matiere=$mat AND id_promotion=$promo AND id_groupe=$id_groupe");
$moy_gene = mysql_fetch_row($temp);
print(" <td align=center><font size=2 face=arial><b> $moy_gene[0] </b></font></td> \n");
}
print(" </table> \n");
print(" <br> \n");
print(" <input type=hidden name=\"nb_etu\" value=\"$nb_etu\" > \n");
}
//***********************************************************************************************
//* Fin du formulaire
//***********************************************************************************************
print("</form> \n");
//***********************************************************************************************
//***********************************************************************************************
//***********************************************************************************************
}
buildEndOfPage();
?>