From fb37b5aeeb1262c16c5a6881d46418bfea32deb3 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 15 Nov 2015 18:12:49 +0100 Subject: [PATCH] Modification du select par partlist et filtrage PHP sur page/*.php plus efficace qu'au niveau de database et des managers --- css/global.css | 68 +++++++++++++-- js/pageManager.js | 21 +++-- manager/career.php | 51 +++++++++++ page/_JS/career.js | 55 +++++++++++- page/_JS/groups.js | 50 ++++++++--- page/career.php | 198 ++++++++++++++++++++++++++++++------------ page/groups.php | 212 ++++++++++++++++++++++++--------------------- 7 files changed, 470 insertions(+), 185 deletions(-) diff --git a/css/global.css b/css/global.css index dde0e75..282d102 100755 --- a/css/global.css +++ b/css/global.css @@ -15,7 +15,7 @@ tr:hover > td > span.unstressed{ color: #ddd; } span.stressed{ font-weight: bold; } - +thead.normal > tr > th{ font-weight: normal; } /*************************/ /*** TITLE PERSONALISÉ ***/ @@ -186,18 +186,18 @@ span.link:hover{ color: #000; } /*********************/ select{ /* position */ - margin: 2em 0; + margin: 2em; padding: 0 1em; /* border */ border-radius: 5px; - border: 1px solid #ddd; + border: 1px solid #2dcc70; /* background */ background-color: #fff; /* foreground */ - color: #233342; + color: #2dcc70; /* select */ -webkit-appearance:none; @@ -216,7 +216,7 @@ select > option{ background-color: #fff; /* foreground */ - color: #233342; + color: #555; text-indent: 1em; } @@ -269,3 +269,61 @@ tr:hover td select.active + .valider_action{ background-image: url(../src/valida /* bouton validation */ input.saisie_note.active + .valider_action{ display: inline-block; background-image: url(../src/validate.svg); } tr:hover td input.saisie_note.active + .valider_action{ background-image: url(../src/validate@hover.svg); } + + + + +/******************************/ +/*** SELECTIONS DES PARTIES ***/ +/******************************/ +#CONTAINER > section > .partlist{ + /* position */ + display: table; + margin: 2em; + + /* border */ + border-spacing: 0; + +} + +#CONTAINER > section > .partlist td{ + /* position */ + padding: .7em 2em; + + /* border */ + border: 1px solid #2dcc70; + border-right: 0; + + /* background */ + background-color: #fff; + + /* foreground */ + color: #2dcc70; + + /* extra */ + cursor: pointer; + + /* animation */ + transition: .2s ease-in-out; + -moz-transition: .2s ease-in-out; + -webkit-transition: .2s ease-in-out; + -ms-transition: .2s ease-in-out; + -o-transition: .2s ease-in-out; +} + +/* @radius */ +#CONTAINER > section > .partlist td:first-child{ + border-radius: 5px 0 0 5px; +} + +/* @border + @radius */ +#CONTAINER > section > .partlist td:last-child{ + border-radius: 0 5px 5px 0; + border-right: 1px solid #2dcc70; +} + + +#CONTAINER > section > .partlist td.active{ + background-color: #2dcc70; + color: #fff; +} \ No newline at end of file diff --git a/js/pageManager.js b/js/pageManager.js index eff3a10..45163bc 100755 --- a/js/pageManager.js +++ b/js/pageManager.js @@ -22,23 +22,22 @@ pageManager.prototype = { ajax: function(pLink, pHandler, pMethod, pForm){ // on efface les requêtes qui sont terminées et on push une nouvelle for( var i = 0 ; i < this.xhr.length ; i++ ){ - if( this.xhr[i].readyState == 4 ) // si terminée + // if( this.xhr[i].readyState == 4 ) // si terminée this.xhr = this.xhr.slice(0,i-1).concat(this.xhr.slice(i,this.xhr.length-1)); // suppression entrée } - this.xhr.push(true); - i = this.xhr.length-1; + var index; if(window.XMLHttpRequest) // IE7+, Firefox, Chrome, Opera, Safari - this.xhr[i] = new XMLHttpRequest(); + index = this.xhr.push( new XMLHttpRequest() ) -1; else // IE5, IE6 - this.xhr[i] = new ActiveXObject('Microsoft.XMLHttpRequest'); + index = this.xhr.push( new ActiveXObject('Microsoft.XMLHttpRequest') ) -1; var ptrPageManager = this; - this.xhr[i].onreadystatechange = function(){ - if( ptrPageManager.xhr[i].readyState == 4 ) // si la requête est terminée - if( [0,200].indexOf(ptrPageManager.xhr[i].status) > -1 ) // si fichier existe et reçu - pHandler(ptrPageManager.xhr[i].responseText); + this.xhr[index].onreadystatechange = function(){ + if( ptrPageManager.xhr[index].readyState == 4 ) // si la requête est terminée + if( [0,200].indexOf(ptrPageManager.xhr[index].status) > -1 ) // si fichier existe et reçu + pHandler(ptrPageManager.xhr[index].responseText); else // si code d'erreur retourne null pHandler(); } @@ -49,8 +48,8 @@ pageManager.prototype = { // gestion du formulaire si la méthode est POST var form = ( method == 'POST' && typeof pForm == 'object' && pForm instanceof FormData ) ? pForm : null; - this.xhr[i].open( method, pLink, true); - this.xhr[i].send( form ); + this.xhr[index].open( method, pLink, true ); + this.xhr[index].send( form ); }, /***************************************************** [APPLICATION] Ajax() ******************************************************/ // EXEMPLES DE FONCTIONS POUR pHandler // diff --git a/manager/career.php b/manager/career.php index 30c60dd..759d2ff 100755 --- a/manager/career.php +++ b/manager/career.php @@ -122,6 +122,27 @@ require_once __ROOT__.'/manager/database.php'; break; + /**********************************************/ + /* informations relatives au dossier étudiant */ + /**********************************************/ + case 'studentcase': if( permission('teacher') ){ + + $areSetParam = isset($request->etudiant) && isset($request->controle) && isset($request->note); // les arguments existent + $typeOkParam = $areSetParam && is_string($request->etudiant); // si c'est des strings + $nEmptyParam = $typeOkParam && strlen($request->etudiant) > 0 && is_numeric($request->controle) && is_numeric($request->note); // des bon types + $etudiantCheck = $nEmptyParam && preg_match('/^[\w -]{3,50}$/i', $request->etudiant); // nom bon format + + if( $etudiantCheck ){ // si tout les paramètres sont bons + $answer->request = DataBase::getInstance()->saisieNote($request->etudiant, $request->controle, $request->note); + }else + $answer->request = 'param_error'; + + }else + $answer->request = 'permission_error'; + + break; + + /****************************************************/ /* saisie d'une note pour un étudiant à un contrôle */ @@ -145,6 +166,36 @@ require_once __ROOT__.'/manager/database.php'; + +/* _ ____ ___ _____ _____ _ _ ____ _____ ____ +/* / \ | _ \_ _| ___| ___| | | / ___|| ____| _ \ +/* / _ \ | | | | || |_ | |_ | | | \___ \| _| | |_) | +/* / ___ \ | |_| | || _| | _| | |_| |___) | |___| _ < +/* /_/ \_\ |____/___|_| |_| \___/|____/|_____|_| \_\ +/* + + /****************************************************/ + /* saisie d'une note pour un groupe à un contrôle */ + /****************************************************/ + case 'saisieNoteGroupe': if( permission('teacher') ){ + + $areSetParam = isset($request->etudiant) && isset($request->controle) && isset($request->note); // les arguments existent + $typeOkParam = $areSetParam && is_string($request->etudiant); // si c'est des strings + $nEmptyParam = $typeOkParam && strlen($request->etudiant) > 0 && is_numeric($request->controle) && is_numeric($request->note); // des bon types + $etudiantCheck = $nEmptyParam && preg_match('/^[\w -]{3,50}$/i', $request->etudiant); // nom bon format + + if( $etudiantCheck ){ // si tout les paramètres sont bons + $answer->request = DataBase::getInstance()->saisieNoteGroupe($request->etudiant, $request->controle, $request->note); + }else + $answer->request = 'param_error'; + + }else + $answer->request = 'permission_error'; + break; + + + + /***********/ /* DEFAULT */ /***********/ diff --git a/page/_JS/career.js b/page/_JS/career.js index e6b1cc7..96b10cc 100644 --- a/page/_JS/career.js +++ b/page/_JS/career.js @@ -1,5 +1,37 @@