From 6cd8bebe8cb1eba3b92839406cb5d91db4cfd064 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 10 Nov 2015 10:56:43 +0100 Subject: [PATCH] =?UTF-8?q?Prise=20en=20compte=20si=20on=20est=20dans=20p?= =?UTF-8?q?=C3=A9riode=20S1/S3=20ou=20S2/S4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/database.php | 8 ++++++-- manager/groups.php | 2 +- manager/repo/semestre.php | 2 +- manager/user.php | 7 ++++--- test.php | 18 ++++++++++-------- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/manager/database.php b/manager/database.php index 2c3370d..a29fe1d 100755 --- a/manager/database.php +++ b/manager/database.php @@ -247,7 +247,9 @@ class DataBase{ /******************************************************************/ /*** retourne la liste des utilisateurs des groupes d'une année ***/ /******************************************************************/ - public function listeEtudiantsTousGroupesAnnee($annee, $pSemestre, $pGroupe){ + public function listeEtudiantsTousGroupesAnnee($annee, $semestre_pair, $pSemestre, $pGroupe){ + $semestre_pair = ($semestre_pair) ? '0' : '1'; + // définition des paramètres optionnels $semestreDeb = 1; $semestreFin = 4; if( $pSemestre != null ){ $semestreDeb = $pSemestre; $semestreFin = $pSemestre; } // semestre donné uniquement (si param non null) @@ -272,12 +274,14 @@ class DataBase{ "AND s.id_semestre = app.id_semestre ". "AND g.nom LIKE '".$groupeOpt."' ". - "AND s.rang BETWEEN :semestreDeb AND :semestreFin ". + "AND s.rang BETWEEN :semestreDeb AND :semestreFin ". + "AND s.rang % 2 = :semestre_pair ". "AND s.annee = :annee ". "ORDER BY g.nom"); $getGroupesUID->execute(array( ':semestreDeb' => $semestreDeb, ':semestreFin' => $semestreFin, + ':semestre_pair' => $semestre_pair, ':annee' => $annee )); diff --git a/manager/groups.php b/manager/groups.php index 0417acd..12fa860 100755 --- a/manager/groups.php +++ b/manager/groups.php @@ -221,7 +221,7 @@ require_once __ROOT__.'/manager/database.php'; if( $anneeCheck ){ - $grouplist = DataBase::getInstance()->listeEtudiantsTousGroupesAnnee($request->annee, $semestre, $groupe); + $grouplist = DataBase::getInstance()->listeEtudiantsTousGroupesAnnee($request->annee, $_SESSION['semestre_pair'], $semestre, $groupe); if( is_array($grouplist) ){ // si on a récupéré la liste des utilisateurs $answer->grouplist = $grouplist; diff --git a/manager/repo/semestre.php b/manager/repo/semestre.php index d53f40a..b8e2b01 100755 --- a/manager/repo/semestre.php +++ b/manager/repo/semestre.php @@ -76,7 +76,7 @@ class semestreRepo extends DBAccess{ */ public static function studentCurrent($etudiant, $semestre_pair, $annee){ // on formate les variables - $semestre_pair = ($semestre_pair) ? '1' : '0'; + $semestre_pair = ($semestre_pair) ? '0' : '1'; $getSemestreUID = DataBase::getPDO()->prepare("SELECT s.id_semestre as id ". "FROM semestre as s, appartenance as app ". diff --git a/manager/user.php b/manager/user.php index b052a08..a2c1ba9 100755 --- a/manager/user.php +++ b/manager/user.php @@ -175,13 +175,14 @@ require_once __ROOT__.'/manager/database.php'; // on défini si le semestre est pair ou non $_SESSION['semestre_pair'] = semestrePair(time()); + // on défini le semestre par défaut à NULL + $_SESSION['semestre'] = null; + /* on récupère le semestre courant si c'est un étudiant */ if( permission('student') ){ $semestre = DataBase::studentSemestre( $_SESSION['identifiant'], $_SESSION['semestre_pair'], $_SESSION['annee']); if( is_numeric($semestre) )// si on a bien récupéré le semestre - $_SESSION['semestre'] = ''.$semestre.''; - else - $_SESSION['semestre'] = null; + $_SESSION['semestre'] = ''.$semestre.''; } return 'success'; diff --git a/test.php b/test.php index 8a531c6..0398f53 100755 --- a/test.php +++ b/test.php @@ -2,6 +2,8 @@ require_once __ROOT__.'/manager/security.php'; + var_dump( $_SESSION['semestre'] ); + /***************/ /*** A FAIRE ***/ /*************** @@ -59,20 +61,20 @@ require_once __ROOT__.'/manager/security.php'; /*** RETOURNE LE SEMESTRE COURANT D'UN ETUDIANT ***/ - require_once __ROOT__.'/manager/groups.php'; + // require_once __ROOT__.'/manager/groups.php'; - $request = new stdClass(); - $answer = new stdClass(); + // $request = new stdClass(); + // $answer = new stdClass(); - $request->level_1 = 'getSemestre'; - $request->etudiant = 'mrd1609a'; + // $request->level_1 = 'getSemestre'; + // $request->etudiant = 'mrd1609a'; - groups_switch_level_1($request, $answer); + // groups_switch_level_1($request, $answer); - echo var_dump( $answer ); + // echo var_dump( $answer ); - echo "






It works !"; + // echo "






It works !";