Affinage par @formation pour enseignant@modules + admin@modules

This commit is contained in:
xdrm-brackets 2015-11-16 17:03:16 +01:00
parent 01334b44e6
commit 50c8c44453
2 changed files with 78 additions and 18 deletions

View File

@ -5,7 +5,7 @@
/********************************/
/* GESTION DE L'AFFINAGE PAR UE */
/********************************/
var partList = document.querySelectorAll("#CONTAINER > section[name] > table.partlist[name=UE], #CONTAINER > section[name] > table.partlist[name=semestre]");
var partList = document.querySelectorAll("#CONTAINER > section[name] > table.partlist[name=UE], #CONTAINER > section[name] > table.partlist[name=semestre], #CONTAINER > section[name] > table.partlist[name=formation]");
for( var i = 0 ; i < partList.length ; i++ ){
@ -14,16 +14,28 @@ for( var i = 0 ; i < partList.length ; i++ ){
if( tableauParent.tagName == 'TABLE' && e.target.dataset.hasOwnProperty('value') ){
/* SI c'est une affinage par FORMATION */
if( tableauParent.getAttribute('name') == 'formation' ){
pageM.vars[1] = 'f:'+e.target.dataset.value;
if( pageM.vars.length > 2 ) // si un deuxième affinage existe, on le supprime lors du choix de la formation
pageM.vars.pop();
}
/* SI c'est une affinage par SEMESTRE */
if( tableauParent.getAttribute('name') == 'semestre' )
pageM.vars[1] = 's:'+e.target.dataset.value;
pageM.vars[2] = 's:'+e.target.dataset.value;
/* SI c'est un affinage par UE */
if( tableauParent.getAttribute('name') == 'UE' )
pageM.vars[1] = 'u:'+e.target.dataset.value;
pageM.vars[2] = 'u:'+e.target.dataset.value;
// si la formation n'est pas définie, on l'active
if( !/^f:/.test(pageM.vars[1]) )
pageM.vars[1] = 'f:'+document.querySelector('#CONTAINER > section[name] > table.partlist[name=formation] option[data-value].active').dataset.formation;
// si on a '*' comme valeur, on l'enlève
if( /\*$/.test(pageM.vars[1]) )
if( /\*$/.test(pageM.vars[2]) )
pageM.vars.pop();
reload();

View File

@ -7,8 +7,9 @@ require_once __ROOT__.'/manager/modules.php';
/*** GESTION DES PARAMETRES OPTIONNELS ***/
// on initialise les paramètres optionnels
$ueOpt = null;
$semestreOpt = null;
$ueOpt = null;
$semestreOpt = null;
$formationOpt = null;
// on cherche dans toutes les variables _get si on trouve des paramètres
foreach($_POST as $k=>$v){
@ -19,10 +20,14 @@ require_once __ROOT__.'/manager/modules.php';
if( preg_match('/^u:(.+)$/', $k, $m) ) // u:nomUE
$ueOpt = $m[1];
if( preg_match('/^f:(.+)$/', $k, $m) ) // f:codeFormation
$formationOpt = $m[1];
}
$ueOpt = ($ueOpt == null || $ueOpt == '*') ? null : $ueOpt;
$semestreOpt = ($semestreOpt == null || $semestreOpt == '*') ? null : $semestreOpt;
$ueOpt = ($ueOpt == null || $ueOpt == '*') ? null : $ueOpt;
$semestreOpt = ($semestreOpt == null || $semestreOpt == '*') ? null : $semestreOpt;
$formationOpt = ($formationOpt == null || $formationOpt == '*') ? null : $formationOpt;
/****************************************
@ -146,18 +151,41 @@ if( permission('teacher') ){ // si l'utilisateur est un prof
/* ON RECUPERE UNE LISTE UNIQUE DES SEMESTRES */
$ListeNomsSemestres = array();
$ListeNomsFormations = array();
$ListeNomsUE = array();
foreach($answer->semestres as $semestre){
// on selectionne les formations présentes
foreach($answer->semestres as $semestre)
array_push( $ListeNomsFormations, $semestre['formation'] );
// si la formation optionnelle n'est pas définie ou pas dans la liste, on la définit
$ListeNomsFormations = array_unique($ListeNomsFormations);
if( $formationOpt == null || !in_array($formationOpt, $ListeNomsFormations) ) $formationOpt = $ListeNomsFormations[0];
foreach($answer->semestres as $semestre){ if( $semestre['formation'] == $formationOpt ){
array_push( $ListeNomsSemestres, $semestre['nom'] );
/* ON RECUPERE UNE LISTE UNIQUE DES UEs */
foreach($semestre['UElist'] as $UE)
array_push( $ListeNomsUE, $UE['nom'] );
}
}}
$ListeNomsSemestres = array_unique($ListeNomsSemestres);
$ListeNomsUE = array_unique($ListeNomsUE);
echo "<table class='partlist' name='formation'><tbody><tr>";
foreach($ListeNomsFormations as $NomFormation)
if( $NomFormation == $formationOpt ) // si c'est le semestre séléctionné
echo "<td data-value='".$NomFormation."' class='active'>".$NomFormation.'</td>';
else // sinon on affiche normalement
echo "<td data-value='".$NomFormation."'>".$NomFormation.'</td>';
echo "</tr></tbody></table>";
echo "<table class='partlist' name='semestre'><tbody><tr>";
if( $semestreOpt == null ) echo "<td data-value='*' class='active'>Tous</td>";
else echo "<td data-value='*'>Tous</td>";
@ -171,8 +199,6 @@ if( permission('teacher') ){ // si l'utilisateur est un prof
echo "<table class='partlist' name='UE'><tbody><tr>";
if( $ueOpt == null ) echo "<td data-value='*' class='active'>Tous</td>";
else echo "<td data-value='*'>Tous</td>";
@ -186,9 +212,10 @@ if( permission('teacher') ){ // si l'utilisateur est un prof
foreach($answer->semestres as $semestre){
if( $semestreOpt == null || $semestre['nom'] == $semestreOpt ){ // on affiche les semestres en fonction de l'affinage
if( ($semestreOpt == null || $semestre['nom'] == $semestreOpt) && ($formationOpt == null || $semestre['formation'] == $formationOpt) ){ // on affiche les semestres en fonction de l'affinage
foreach($semestre['UElist'] as $UE){
@ -273,18 +300,41 @@ if( permission('admin') ){ // si l'utilisateur est un admin
/* ON RECUPERE UNE LISTE UNIQUE DES SEMESTRES */
$ListeNomsSemestres = array();
$ListeNomsFormations = array();
$ListeNomsUE = array();
foreach($answer->semestres as $semestre){
// on selectionne les formations présentes
foreach($answer->semestres as $semestre)
array_push( $ListeNomsFormations, $semestre['formation'] );
// si la formation optionnelle n'est pas définie, on la définit
$ListeNomsFormations = array_unique($ListeNomsFormations);
if( $formationOpt == null || !in_array($formationOpt, $ListeNomsFormations) ) $formationOpt = $ListeNomsFormations[0];
foreach($answer->semestres as $semestre){ if( $semestre['formation'] == $formationOpt ){
array_push( $ListeNomsSemestres, $semestre['nom'] );
/* ON RECUPERE UNE LISTE UNIQUE DES UEs */
foreach($semestre['UElist'] as $UE)
array_push( $ListeNomsUE, $UE['nom'] );
}
}}
$ListeNomsSemestres = array_unique($ListeNomsSemestres);
$ListeNomsUE = array_unique($ListeNomsUE);
echo "<table class='partlist' name='formation'><tbody><tr>";
foreach($ListeNomsFormations as $NomFormation)
if( $NomFormation == $formationOpt ) // si c'est le semestre séléctionné
echo "<td data-value='".$NomFormation."' class='active'>".$NomFormation.'</td>';
else // sinon on affiche normalement
echo "<td data-value='".$NomFormation."'>".$NomFormation.'</td>';
echo "</tr></tbody></table>";
echo "<table class='partlist' name='semestre'><tbody><tr>";
if( $semestreOpt == null ) echo "<td data-value='*' class='active'>Tous</td>";
else echo "<td data-value='*'>Tous</td>";
@ -298,8 +348,6 @@ if( permission('admin') ){ // si l'utilisateur est un admin
echo "<table class='partlist' name='UE'><tbody><tr>";
if( $ueOpt == null ) echo "<td data-value='*' class='active'>Tous</td>";
else echo "<td data-value='*'>Tous</td>";
@ -315,7 +363,7 @@ if( permission('admin') ){ // si l'utilisateur est un admin
foreach($answer->semestres as $semestre){
if( $semestreOpt == null || $semestre['nom'] == $semestreOpt ){ // on affiche les semestres en fonction de l'affinage
if( ($semestreOpt == null || $semestre['nom'] == $semestreOpt) && ($formationOpt == null || $semestre['formation'] == $formationOpt) ){ // on affiche les semestres en fonction de l'affinage
foreach($semestre['UElist'] as $UE){