diff --git a/BddCorrect/BDD/OracleDb.php b/BddCorrect/BDD/OracleDb.php index 8afaffa..2e2ff79 100644 --- a/BddCorrect/BDD/OracleDb.php +++ b/BddCorrect/BDD/OracleDb.php @@ -14,7 +14,7 @@ class OracleDb { function __construct() { //$this->conn = oci_connect('u_prems', '123456', 'localhost/orcl'); $this->conn = oci_connect('meelaichao', 'meelaichao', 'kirov:1521/kirov'); - $this->createRandomTables(); + //$this->createRandomTables(); } function createRandomTables() { diff --git a/BddCorrect/DAL/QuestionsGateway.php b/BddCorrect/DAL/QuestionsGateway.php index d5698f7..360261c 100644 --- a/BddCorrect/DAL/QuestionsGateway.php +++ b/BddCorrect/DAL/QuestionsGateway.php @@ -1,5 +1,7 @@ db->prepare($query); $result = $query->execute(); - //$resultats = $this->db->query('SELECT found_rows()'); - while($q = $result->fetchArray()){ - $i= $i+1; - $tabQuestions[] = new Question($q['numTp'],$q['numquestion'],$q['question'],$q['reponse']); + //$nbTpRow = $result->fetchArray(SQLITE3_NUM); + $i = 0; + while ($tp = $result->fetchArray(SQLITE3_NUM)){ + $questionQuery = 'SELECT numTp,numquestion,question,reponse FROM Correct WHERE numTp = ? UNION SELECT numTp,numquestion,question,reponse FROM FunctionCorrect WHERE numTp = ? '; + $questionQuery = $this->db->prepare($questionQuery); + $questionQuery->bindParam(1, $tp[0]); + $questionQuery->bindParam(2, $tp[0]); + $questionResult = $questionQuery->execute(); + while($q = $questionResult->fetchArray()){ + $tabQuestions[] = new Question($q['numTp'],$q['numquestion'],$q['question'],$q['reponse']); + } + $tabTp['tp'.$tp[0]] = $tabQuestions ; + unset($tabQuestions); + $tabQuestions = array(); } - return $tabQuestions; + + //die("
".print_r($tabTp)."ERREUR : Veuillez remplir tous les champs '; @@ -15,8 +15,8 @@ else if(!is_numeric($_GET['tp'])) echo 'ERREUR : une valeur non numérique à été détectée dans le champ \'Numéro de question :\' '; else if(!is_numeric($_GET['num'])) echo 'ERREUR : une valeur non numérique à été détectée dans le champ \'TP n° :\' '; - - +else if(!is_numeric($_GET['points'])) + echo 'ERREUR : une valeur non numérique à été détectée dans le champ \'Barème:\' '; else { if(isset($_GET['modif'])){ if ($_GET["type"] == 'fonction') diff --git a/BddCorrect/Traitement/Suppression.php b/BddCorrect/Traitement/Suppression.php index 4f476f2..2ab3913 100644 --- a/BddCorrect/Traitement/Suppression.php +++ b/BddCorrect/Traitement/Suppression.php @@ -3,28 +3,113 @@ require_once('../BDD/SqliteDb.php'); $db = new SqliteDb('o'); + +$numQuestionSuiv = $_GET['numQuestion']+1; + + + + +$sqliteQuery = $db->prepare('SELECT type FROM Type WHERE numQuestion=? AND numTp = ?'); +$sqliteQuery->bindParam(1, $_GET['numQuestion']); +$sqliteQuery->bindParam(2, $_GET['numTp']); +$result = $sqliteQuery->execute(); +$typeRow = $result->fetchArray(); +$sqliteQuery = $db->prepare('DELETE FROM Type WHERE numquestion= ? AND numTp=? '); +$sqliteQuery->bindParam(1, $_GET['numQuestion']); +$sqliteQuery->bindParam(2, $_GET['numTp']); +$result = $sqliteQuery->execute(); - $sqliteQuery = $db->prepare('SELECT type FROM Type WHERE numQuestion=? AND numTp = ?'); - $sqliteQuery->bindParam(1, $_GET['numQuestion']); - $sqliteQuery->bindParam(2, $_GET['numTp']); + +if($typeRow['type'] == 'query'){ + $sqliteQuery = $db->prepare('SELECT count(*) FROM (SELECT numQuestion FROM Correct WHERE numTp=? UNION SELECT numQuestion FROM FunctionCorrect WHERE numTp=?)'); + $sqliteQuery->bindParam(1, $_GET['numTp']); + $sqliteQuery->bindParam(2, $_GET['numTp']); + $result = $sqliteQuery->execute(); + $nbQuestionsRow = $result->fetchArray(); + + $sqliteQuery = $db->prepare('DELETE FROM Correct WHERE numquestion= ? AND numTp=? '); + $sqliteQuery->bindParam(1, $_GET['numQuestion']); + $sqliteQuery->bindParam(2, $_GET['numTp']); + $result = $sqliteQuery->execute(); + + + for( $iSuiv = $numQuestionSuiv, $j=$_GET['numQuestion'] ; $iSuiv <= $nbQuestionsRow['count(*)'] ; $iSuiv++ , $j++ ){ + + $typeQuery = $db->prepare('SELECT type FROM Type WHERE numQuestion = ? AND numTp= ?'); + $typeQuery->bindParam(1, $iSuiv); + $typeQuery->bindParam(2, $_GET['numTp']); + $resultType = $typeQuery->execute(); + $typeRow = $resultType->fetchArray(); + + if($typeRow['type'] == 'query'){ + $table = 'Correct'; + $type = 'query'; + } + else{ + $table = 'FunctionCorrect'; + $type = 'functionCorrect'; + } + + $sqliteQuery = $db->prepare('UPDATE '.$table.' SET numQuestion=? WHERE numQuestion=? AND numTp=? '); + $sqliteQuery->bindParam(1, $j); + $sqliteQuery->bindParam(2, $iSuiv); + $sqliteQuery->bindParam(3, $_GET['numTp']); $result = $sqliteQuery->execute(); - $typeRow = $result->fetchArray(); - if($typeRow['type'] == 'query'){ - $sqliteQuery = $db->prepare('DELETE FROM Correct WHERE numquestion= ? AND numTp=? '); - $sqliteQuery->bindParam(1, $_GET['numQuestion']); - $sqliteQuery->bindParam(2, $_GET['numTp']); - $result = $sqliteQuery->execute(); + $sqliteQuery = $db->prepare('UPDATE Type SET numQuestion=? WHERE numQuestion=? AND numTp=? '); + $sqliteQuery->bindParam(1, $j); + $sqliteQuery->bindParam(2, $iSuiv); + $sqliteQuery->bindParam(3, $_GET['numTp']); + $result = $sqliteQuery->execute(); + } +} +else { + + $sqliteQuery = $db->prepare('SELECT count(*) FROM (SELECT numQuestion FROM Correct WHERE numTp=? UNION SELECT numQuestion FROM FunctionCorrect WHERE numTp=?)'); + $sqliteQuery->bindParam(1, $_GET['numTp']); + $sqliteQuery->bindParam(2, $_GET['numTp']); + $result = $sqliteQuery->execute(); + $nbQuestionsRow = $result->fetchArray(); + + $sqliteQueryF = $db->prepare('DELETE FROM FunctionCorrect WHERE numquestion= ? AND numTp=?'); + $sqliteQueryF->bindParam(1, $_GET['numQuestion']); + $sqliteQueryF->bindParam(2, $_GET['numTp']); + $result = $sqliteQueryF->execute(); + + + + for( $iSuiv = $numQuestionSuiv, $j=$_GET['numQuestion'] ; $iSuiv <= $nbQuestionsRow['count(*)'] ; $iSuiv++ , $j++ ){ + + $typeQuery = $db->prepare('SELECT type FROM Type WHERE numQuestion = ? AND numTp= ?'); + $typeQuery->bindParam(1, $numQuestionSuiv); + $typeQuery->bindParam(2, $_GET['numTp']); + $resultType = $typeQuery->execute(); + $typeRow = $resultType->fetchArray(); + + + if($typeRow['type'] == 'query'){ + $table = 'Correct'; + $type = 'query'; } - else { - $sqliteQueryF = $db->prepare('DELETE FROM FunctionCorrect WHERE numquestion= ? AND numTp=?'); - $sqliteQueryF->bindParam(1, $_GET['numQuestion']); - $sqliteQueryF->bindParam(2, $_GET['numTp']); - $result = $sqliteQueryF->execute(); + else{ + $table = 'FunctionCorrect'; + $type = 'functionCorrect'; } + + $sqliteQuery = $db->prepare('UPDATE '.$table.' SET numQuestion=? WHERE numQuestion=? AND numTp=? '); + $sqliteQuery->bindParam(1, $j); + $sqliteQuery->bindParam(2, $iSuiv); + $sqliteQuery->bindParam(3, $_GET['numTp']); + $result = $sqliteQuery->execute(); - $sqliteQuery = $db->prepare('DELETE FROM Type WHERE numquestion= ? AND numTp=? '); - $sqliteQuery->bindParam(1, $_GET['numQuestion']); - $sqliteQuery->bindParam(2, $_GET['numTp']); - $result = $sqliteQuery->execute(); \ No newline at end of file + $sqliteQuery = $db->prepare('UPDATE Type SET numQuestion=? WHERE numQuestion=? AND numTp=? '); + $sqliteQuery->bindParam(1, $j); + $sqliteQuery->bindParam(2, $iSuiv); + $sqliteQuery->bindParam(3, $_GET['numTp']); + $result = $sqliteQuery->execute(); + } +} + + + diff --git a/BddCorrect/Traitement/test2.db b/BddCorrect/Traitement/test2.db index 6f7c6ee..35d23d9 100644 Binary files a/BddCorrect/Traitement/test2.db and b/BddCorrect/Traitement/test2.db differ diff --git a/BddCorrect/config/config.php b/BddCorrect/config/config.php index 505e406..2022814 100644 --- a/BddCorrect/config/config.php +++ b/BddCorrect/config/config.php @@ -11,6 +11,10 @@ $vues['vueSupression']='vues/VueSupression.php'; $vues['vueNbQuestions']='vues/VueNbQuestions.php'; $vues['vueDemonstration']='vues/VueDemonstration.php'; $vues['vueQCM']='vues/VueQCM.php'; +$vues['vueAccueil']='vues/VueAccueil.php'; +$vues['vueAdmin']='vues/VueAdmin.php'; + + $vues['vueBoo']='css/bootstrap.min.css'; $css['vuePrincipale']='css/VuePrincipale.php'; $css['bootstrap']='css/bootstrap.min.css'; \ No newline at end of file diff --git a/BddCorrect/controleur/Controleur.php b/BddCorrect/controleur/Controleur.php index 30df799..e81b82e 100644 --- a/BddCorrect/controleur/Controleur.php +++ b/BddCorrect/controleur/Controleur.php @@ -12,10 +12,22 @@ class Controleur { echo $action; switch($action) { - case NULL: + case NULL : //require ($rep.$vues['vueLogin']); - $this->afficherQuestions(); - break; + //$this->afficherQuestions(); + require ($rep.$vues['vueAccueil']); + break; + + case 'Retour au menu principal' : + //require ($rep.$vues['vueLogin']); + //$this->afficherQuestions(); + require ($rep.$vues['vueAccueil']); + break; + + case 'Ajouter une question' : + require ($rep.$vues['vueAdmin']); + break; + case 'Afficher les questions': //require ($rep.$vues['vueLogin']); $this->afficherQuestions(); @@ -47,6 +59,10 @@ class Controleur { $this->resetDemonstrations(); break; + case 'Réintiliser les questions' : + $this->resetQuestions(); + break; + case 'Afficher les QCM' : $this->afficherQCM(); break; @@ -68,6 +84,13 @@ class Controleur { //$this->afficherQuestions(); } + + + function resetQuestions(){ + $db = new SqliteDb(); + $db->createTable(); + $this->afficherQuestions(); + } function resetRandomBdd(){ require_once('BDD/OracleDb.php'); $oraDb = new OracleDb(); diff --git a/BddCorrect/css/.bash_history b/BddCorrect/css/.bash_history new file mode 100644 index 0000000..8cc7f9e --- /dev/null +++ b/BddCorrect/css/.bash_history @@ -0,0 +1,13 @@ +cd /var/www/html/ +cd oracle/ +cd correction-bd-mehdi/ +cd BddCorrect/ +ls +cd .. +ls +ls -l +chmod -R 777 BddCorrect/ +cd BddCorrect/ +ls -l +cd Traitement/ +ls -l diff --git a/BddCorrect/css/VueAccueil.css b/BddCorrect/css/VueAccueil.css new file mode 100644 index 0000000..0e08ad0 --- /dev/null +++ b/BddCorrect/css/VueAccueil.css @@ -0,0 +1,40 @@ +.bouton { + background: #0082b5; + color: #fff; + border: 1px solid #eee; + border-radius: 20px; + box-shadow: 5px 5px 5px #eee; + text-shadow:none; + width: 100%; + height: 100px; + margin: 20px; +} + +.bouton:hover { + background: #016ABC; + color: #fff; + border: 1px solid #eee; + border-radius: 20px; + box-shadow: 5px 5px 5px #eee; + text-shadow:none; +} + +body { + text-align: center; +} + +form { + margin-top: 100px; + display: inline-block; + width: 50%; +} + +footer{ + position: fixed; + left: 0; + bottom: 0; + width: 100%; + background-color: red; + color: white; + text-align: center; +} diff --git a/BddCorrect/css/VueDemonstration.css b/BddCorrect/css/VueDemonstration.css new file mode 100644 index 0000000..6dce448 --- /dev/null +++ b/BddCorrect/css/VueDemonstration.css @@ -0,0 +1,34 @@ +#frm-reset{ + position:absolute; + right: 0; + + +} + + +#frm-reset input{ + background: #0082b5; + color: #fff; + border: 1px solid #eee; + border-radius: 20px; + box-shadow: 5px 5px 5px #eee; + text-shadow:none; + width: 500px; + + display: block; + height: 30%; +} + +#content{ + min-height:88vh; +} +footer{ + position: relative; + bottom: 0; + width: 100%; + background-color: red; + color: white; + text-align: center; + min-height: 12vh; + border : double; +} diff --git a/BddCorrect/css/VuePrincipale.css b/BddCorrect/css/VuePrincipale.css index 62486a3..60e9f87 100644 --- a/BddCorrect/css/VuePrincipale.css +++ b/BddCorrect/css/VuePrincipale.css @@ -9,6 +9,79 @@ and open the template in the editor. */ .frm{ - text-align: right; - margin: 10px; + + position:absolute; + right: 0; +} + +.inp-reset{ + background: #0082b5; + color: #fff; + border: 1px solid #eee; + border-radius: 20px; + box-shadow: 5px 5px 5px #eee; + text-shadow:none; + width: 500px; + margin-bottom: 5px; + display: block; + height: 30%; + +} + +.inp-reset:hover { + background: #d9534f; + color: #fff; + border: 1px solid #eee;footer{ + position: relative; + left: 0; + bottom: 0; + width: 100%; + background-color: red; + color: white; + text-align: center; +} + border-radius: 20px; + box-shadow: 5px 5px 5px #eee; + text-shadow:none; +} + +footer{ + position: relative; + left: 0; + bottom: 0; + width: 100%; + background-color: red; + color: white; + text-align: center; +} + + +li { + cursor: pointer; +} + +#btn-ajout, #inp-ret { + background: #0082b5; + border: 1px solid #eee; + color: #fff; + border-radius:20px; + box-shadow: 5px 5px 5px #eee; + margin-bottom: 10px; + width: 400px; +} + +#btn-ajout:hover, #inp-ret:hover { + background: #016ABC; + color: #fff; + border: 1px solid #eee; + border-radius: 20px; + box-shadow: 5px 5px 5px #eee; + text-shadow:none; +} + +#a-ajout{ +position: absolute; + left: 0; + + text-shadow:none; } \ No newline at end of file diff --git a/BddCorrect/modeles/Modele.php b/BddCorrect/modeles/Modele.php index 9628c36..d966b35 100644 --- a/BddCorrect/modeles/Modele.php +++ b/BddCorrect/modeles/Modele.php @@ -6,8 +6,7 @@ class Modele { function afficherQuestions(){ $db = new SqliteDb(); //$db->createTable(); - $qg = new QuestionsGateway($db); - die("test"); + $qg = new QuestionsGateway($db); $tabQuestions = $qg->afficherQuestions(); return $tabQuestions; diff --git a/BddCorrect/nbproject/private/private.properties b/BddCorrect/nbproject/private/private.properties index 440ba30..19bd4fe 100644 --- a/BddCorrect/nbproject/private/private.properties +++ b/BddCorrect/nbproject/private/private.properties @@ -1,6 +1,7 @@ auxiliary.org-netbeans-modules-php-editor.fluent_2e_setter_2e_project_2e_property=false auxiliary.org-netbeans-modules-php-editor.getter_2e_setter_2e_method_2e_name_2e_generation=AS_JAVA auxiliary.org-netbeans-modules-php-editor.public_2e_modifier_2e_project_2e_property=false +browser.id=SL[/Browsers/MicrosoftEdgeBrowser copy.src.files=false copy.src.on.open=false copy.src.target=C:\\xampp\\htdocs\\PhpProject1 diff --git a/BddCorrect/nbproject/private/private.xml b/BddCorrect/nbproject/private/private.xml index 4279b6d..6e2ea97 100644 --- a/BddCorrect/nbproject/private/private.xml +++ b/BddCorrect/nbproject/private/private.xml @@ -3,14 +3,10 @@
TEST
+TEST
-