diff --git a/BddCorrect/BDD/SqliteDb.php b/BddCorrect/BDD/SqliteDb.php index 9cb7307..80012c9 100644 --- a/BddCorrect/BDD/SqliteDb.php +++ b/BddCorrect/BDD/SqliteDb.php @@ -136,7 +136,7 @@ class SqliteDb extends SQLite3 $this->exec("INSERT INTO Demonstration VALUES('NBA',1,1,'Exemple de requête pour selectionner les 2 premières lignes de la table JOUEUR','SELECT * FROM JOUEUR WHERE rownum<3')"); $this->exec("INSERT INTO Demonstration VALUES('NBA',1,2,'Exemple de requête pour selectionner les 2 premières lignes de la table STATS','SELECT * FROM STATS WHERE rownum<3')"); - + $this->exec("INSERT INTO Demonstration VALUES('NBA',2,1,'Exemple de requête pour selectionner les 2 premières lignes de la table GAME','SELECT * FROM GAME WHERE rownum<3')"); } function createQCM(){ @@ -245,6 +245,50 @@ class SqliteDb extends SQLite3 return true; } + function ajouterQCM($numQuestion,$consigne,$choix1,$choix2,$choix3,$numReponse){ + if($this->verificationExistenceQCM($numQuestion)) return false; + $qt = "INSERT INTO QcmQuestion VALUES(?,?)"; + $prp=$this->prepare($qt); + $prp->bindParam(1, $numQuestion); + $prp->bindParam(2, $consigne); + $prp->execute(); + + $q = "INSERT INTO QcmReponse VALUES (1,?,?)"; + $stmt = $this->prepare($q); + $stmt->bindParam(1,$choix1); + $stmt->bindParam(2,$numQuestion); + $stmt->execute(); + + $q = "INSERT INTO QcmReponse VALUES (2,?,?)"; + $stmt = $this->prepare($q); + $stmt->bindParam(1,$choix2); + $stmt->bindParam(2,$numQuestion); + $stmt->execute(); + + $q = "INSERT INTO QcmReponse VALUES (3,?,?)"; + $stmt = $this->prepare($q); + $stmt->bindParam(1,$choix3); + $stmt->bindParam(2,$numQuestion); + $stmt->execute(); + + $qt = "INSERT INTO QcmCorrection VALUES(?,?)"; + $prp=$this->prepare($qt); + $prp->bindParam(1, $numQuestion); + $prp->bindParam(2, $numReponse); + $prp->execute(); + + return true; + } + + function verificationExistenceQCM($numQuestion){ + $q = "SELECT count(*) FROM QcmQuestion WHERE numQuestion = ? "; + $prp=$this->prepare($q); + $prp->bindParam(1, $numQuestion); + $result = $prp->execute(); + $row = $result->fetchArray(); + if($row['count(*)'] == 0) return false; + return true; + } function verificationExistenceQuestion($tp,$numQuestion){ $q = "SELECT count(*) FROM Type WHERE numTp = ? AND numQuestion = ? "; diff --git a/BddCorrect/DAL/QuestionsGateway.php b/BddCorrect/DAL/QuestionsGateway.php index 360261c..1d8eea6 100644 --- a/BddCorrect/DAL/QuestionsGateway.php +++ b/BddCorrect/DAL/QuestionsGateway.php @@ -36,15 +36,26 @@ class QuestionsGateway { } public function afficherDemonstrations() { - $i = 0; - $query = 'SELECT * FROM Demonstration ORDER BY numDemo ASC'; + $tabQuestions=array(); + $query = 'SELECT chapitre FROM Demonstration'; $query = $this->db->prepare($query); $result = $query->execute(); - //$resultats = $this->db->query('SELECT found_rows()'); - while($q = $result->fetchArray()){ - $i= $i+1; - $tabDemo[] = new Question(1,$q['numDemo'],$q['description'],$q['reponse']); + //$nbTpRow = $result->fetchArray(SQLITE3_NUM); + $i = 0; + while ($chapitre = $result->fetchArray(SQLITE3_NUM)){ + $questionQuery = 'SELECT chapitre,numDemo,description,reponse FROM Demonstration WHERE chapitre = ? ORDER BY numDemo'; + $questionQuery = $this->db->prepare($questionQuery); + $questionQuery->bindParam(1, $chapitre[0]); + $questionResult = $questionQuery->execute(); + while($q = $questionResult->fetchArray()){ + $tabQuestions[] = new Question($q['chapitre'],$q['numDemo'],$q['description'],$q['reponse']); + } + $tabChapitre['chapitre'.$chapitre[0]] = $tabQuestions ; + unset($tabQuestions); + $tabQuestions = array(); } - return $tabDemo; + + //die("
".print_r($tabTp)."ajouterQCM($_GET['numQuestion'],$_GET['consigne'],$_GET['choix1'],$_GET['choix2'],$_GET['choix3'], $_GET['reponse']);
+    if(!$isAdd){
+            echo 'ERREUR : le numéro de question existe déjà dans la bdd';
+        }
+    else echo 'AJOUT QCM avec succès';
+
diff --git a/BddCorrect/Traitement/Correcteur.php b/BddCorrect/Traitement/Correcteur.php
index 4b52184..8b3e600 100644
--- a/BddCorrect/Traitement/Correcteur.php
+++ b/BddCorrect/Traitement/Correcteur.php
@@ -15,7 +15,7 @@ $conn = $n->getConn();
 
 $_SESSION['fi'] = array();
 $cmpt = 0;
-$numDemo = 0;
+$numQuestion = 0;
 header("Cache-Control: no cache");
 
 
@@ -23,15 +23,15 @@ header("Cache-Control: no cache");
    /*$numQuestion++;
     $ic = "$numQuestion";*/
     
-   $numDemo = $_GET['numQuestion'];
-   $numChapitre = $_GET['numTp'];
-    $_SESSION['fi'][$numDemo] = $textbox;
+   $numQuestion = $_GET['numQuestion'];
+   $numTp = $_GET['numTp'];
+    $_SESSION['fi'][$numQuestion] = $textbox;
     $UserQuery = oci_parse($conn, $textbox);
     $reponseUser = oci_execute($UserQuery);
     
     $typeQuery = $db->prepare('SELECT type FROM Type WHERE numQuestion = ? AND numTp= ?');
-    $typeQuery->bindParam(1, $numDemo);
-    $typeQuery->bindParam(2, $numChapitre);
+    $typeQuery->bindParam(1, $numQuestion);
+    $typeQuery->bindParam(2, $numTp);
     $resultType = $typeQuery->execute();
     $typeRow = $resultType->fetchArray();
     $err = 0;
@@ -43,8 +43,8 @@ header("Cache-Control: no cache");
         // 
         
         $sqliteQuery = $db->prepare('SELECT reponse FROM Correct WHERE numquestion= ?  AND numTp= ? ');
-        $sqliteQuery->bindParam(1, $numDemo);
-        $sqliteQuery->bindParam(2, $numChapitre);
+        $sqliteQuery->bindParam(1, $numQuestion);
+        $sqliteQuery->bindParam(2, $numTp);
         
         $result = $sqliteQuery->execute();
         $sqliteRow = $result->fetchArray();
@@ -77,8 +77,8 @@ header("Cache-Control: no cache");
         // 
 
         $aleatoireQuery = $db->prepare('SELECT aleatoire FROM Correct WHERE numQuestion = ?  AND numTp= ?');
-        $aleatoireQuery->bindParam(1, $numDemo);
-        $aleatoireQuery->bindParam(2, $numChapitre);
+        $aleatoireQuery->bindParam(1, $numQuestion);
+        $aleatoireQuery->bindParam(2, $numTp);
         $resultAleatoire = $aleatoireQuery->execute();
         $aleatoireRow = $resultAleatoire->fetchArray();
         if($aleatoireRow['aleatoire'] == 'o'){
@@ -135,26 +135,26 @@ header("Cache-Control: no cache");
         }
         // 
         if($err == 0 && $verif==1){
-            echo "La réponse à la question " .$numDemo. " est JUSTE ! \n";
+            echo "La réponse à la question " .$numQuestion. " est JUSTE ! \n";
             $cmpt++;
         }   
-        else echo "La réponse à la question " .$numDemo. " est FAUSSE ! \n";
+        else echo "La réponse à la question " .$numQuestion. " est FAUSSE ! \n";
         //
     }
     //si la question attend une modification
     else if($typeRow['type'] == 'tablemodification'){
         
         $sqliteQuery = $db->prepare('SELECT reponse FROM Correct WHERE numquestion= ?  AND numTp= ? ');
-        $sqliteQuery->bindParam(1, $numDemo);
-        $sqliteQuery->bindParam(2, $numChapitre);
+        $sqliteQuery->bindParam(1, $numQuestion);
+        $sqliteQuery->bindParam(2, $numTp);
         $result = $sqliteQuery->execute();
         $sqliteRow = $result->fetchArray();
         $vraiReponse = oci_parse($conn, $sqliteRow['reponse']);
         $enAttente = oci_execute($vraiReponse); 
         
         $sqliteQuery = $db->prepare('SELECT fonctioncorrect FROM Correct WHERE numquestion= ?  AND numTp= ?');
-        $sqliteQuery->bindParam(1, $numDemo);
-        $sqliteQuery->bindParam(2, $numChapitre);
+        $sqliteQuery->bindParam(1, $numQuestion);
+        $sqliteQuery->bindParam(2, $numTp);
         $result = $sqliteQuery->execute();
         $sqliteRow = $result->fetchArray();
         
@@ -172,18 +172,18 @@ header("Cache-Control: no cache");
         }
         
         if($err == 0 ){
-            echo "La réponse à la question " .$numDemo. " est JUSTE ! \n";
+            echo "La réponse à la question " .$numQuestion. " est JUSTE ! \n";
             $cmpt++;
         }
-        else echo "La réponse à la question " .$numDemo. " est FAUSSE ! \n";
+        else echo "La réponse à la question " .$numQuestion. " est FAUSSE ! \n";
         
         
     }
     //si la question attend un CREATE FUNCTION
     else{
         $fonctionQuery = $db->prepare('SELECT * FROM FunctionCorrect WHERE numquestion= ?  AND numTp= ? ');
-        $fonctionQuery->bindParam(1, $numDemo);
-        $fonctionQuery->bindParam(2, $numChapitre);
+        $fonctionQuery->bindParam(1, $numQuestion);
+        $fonctionQuery->bindParam(2, $numTp);
         $result = $fonctionQuery->execute();
         $fonctionRow = $result->fetchArray();
         
@@ -278,10 +278,10 @@ header("Cache-Control: no cache");
         // 
         
         if($err == 0 && $verif==1 ){
-            echo "La réponse à la question " .$numDemo. " est JUSTE ! \n";
+            echo "La réponse à la question " .$numQuestion. " est JUSTE ! \n";
             $cmpt++;
         }
-        else echo "La réponse à la question " .$numDemo. " est FAUSSE ! \n";
+        else echo "La réponse à la question " .$numQuestion. " est FAUSSE ! \n";
     }
 
 
diff --git a/BddCorrect/Traitement/Ordre.php b/BddCorrect/Traitement/Ordre.php
index a0e9daa..734cc28 100644
--- a/BddCorrect/Traitement/Ordre.php
+++ b/BddCorrect/Traitement/Ordre.php
@@ -4,24 +4,31 @@ require_once('../BDD/SqliteDb.php');
 $db = new SqliteDb('o');
 
 
-$numDemo = $_GET['numQuestion'];
-   $numChapitre = $_GET['numTp'];
-$numDemoPrec = $numDemo-1;
+$numQuestion = $_GET['numQuestion'];
+$numTp = $_GET['numTp'];
+$numQuestionPrec = $numQuestion-1;
 $test = 999;
 
 $Correct = 'Correct';
 $function = 'functionCorrect';
-if($numDemo!=1){
+
+
+if(isset($_GET['des'])){
+    $numQuestion += 1;
+    $numQuestionPrec = $numQuestion-1;
+}
+
+if($numQuestion!=1){
     
     $typeQuery = $db->prepare('SELECT type FROM Type WHERE numQuestion = ? AND numTp= ?');
-    $typeQuery->bindParam(1, $numDemo);
-    $typeQuery->bindParam(2, $numChapitre);
+    $typeQuery->bindParam(1, $numQuestion);
+    $typeQuery->bindParam(2, $numTp);
     $resultType = $typeQuery->execute();
     $typeRow = $resultType->fetchArray();
     
     $typeQuery = $db->prepare('SELECT type FROM Type WHERE numQuestion = ? AND numTp= ?');
-    $typeQuery->bindParam(1, $numDemoPrec);
-    $typeQuery->bindParam(2, $numChapitre);
+    $typeQuery->bindParam(1, $numQuestionPrec);
+    $typeQuery->bindParam(2, $numTp);
     $resultType = $typeQuery->execute();
     $type2Row = $resultType->fetchArray();
     
@@ -40,8 +47,8 @@ if($numDemo!=1){
     
     $sqliteQuery = $db->prepare('UPDATE '.$table.' SET numQuestion=? WHERE numQuestion=? AND numTp=?');   
     $sqliteQuery->bindParam(1, $test);
-    $sqliteQuery->bindParam(2, $numDemo);
-    $sqliteQuery->bindParam(3, $numChapitre);
+    $sqliteQuery->bindParam(2, $numQuestion);
+    $sqliteQuery->bindParam(3, $numTp);
     $result = $sqliteQuery->execute();
     
     //---------
@@ -55,15 +62,15 @@ if($numDemo!=1){
     }
     
     $sqliteQuery = $db->prepare('UPDATE '.$table2.' SET numQuestion=? WHERE numQuestion=? AND numTp=?');
-    $sqliteQuery->bindParam(1, $numDemo);
-    $sqliteQuery->bindParam(2, $numDemoPrec);
-    $sqliteQuery->bindParam(3, $numChapitre);
+    $sqliteQuery->bindParam(1, $numQuestion);
+    $sqliteQuery->bindParam(2, $numQuestionPrec);
+    $sqliteQuery->bindParam(3, $numTp);
     $resulti = $sqliteQuery->execute();
     
     $sqliteQuery = $db->prepare('UPDATE Type SET type=? WHERE numQuestion=? AND numTp=?');
     $sqliteQuery->bindParam(1, $type2);
-    $sqliteQuery->bindParam(2, $numDemo);
-    $sqliteQuery->bindParam(3, $numChapitre);
+    $sqliteQuery->bindParam(2, $numQuestion);
+    $sqliteQuery->bindParam(3, $numTp);
     $resulti = $sqliteQuery->execute();
      
    
@@ -71,38 +78,18 @@ if($numDemo!=1){
     
     $sqliteQuery = $db->prepare('UPDATE '.$table.' SET numQuestion=? WHERE numQuestion=? AND numTp=?');
 
-    $sqliteQuery->bindParam(1, $numDemoPrec);
+    $sqliteQuery->bindParam(1, $numQuestionPrec);
     $sqliteQuery->bindParam(2, $test);
-    $sqliteQuery->bindParam(3, $numChapitre);
+    $sqliteQuery->bindParam(3, $numTp);
     $resultp = $sqliteQuery->execute();
     
     $sqliteQuery = $db->prepare('UPDATE Type SET type=? WHERE numQuestion=? AND numTp=?');
     $sqliteQuery->bindParam(1, $type);
-    $sqliteQuery->bindParam(2, $numDemoPrec);
-    $sqliteQuery->bindParam(3, $numChapitre);
-    $resulti = $sqliteQuery->execute();
-    
-    
-    ////---------------------------------------------------------
-    
-    
-    /*$sqliteQuery = $db->prepare('UPDATE Type SET numQuestion=? WHERE numQuestion=? AND numTp=?');
-    $sqliteQuery->bindParam(1, $test);
-    $sqliteQuery->bindParam(2, $numQuestion);
-    $sqliteQuery->bindParam(3, $numTp);
-    $result = $sqliteQuery->execute();
-    
-    $sqliteQuery = $db->prepare('UPDATE Type SET numQuestion=? WHERE numQuestion=? AND numTp=?');
-    $sqliteQuery->bindParam(1, $numQuestion);
     $sqliteQuery->bindParam(2, $numQuestionPrec);
     $sqliteQuery->bindParam(3, $numTp);
     $resulti = $sqliteQuery->execute();
     
-    $sqliteQuery = $db->prepare('UPDATE Type SET numQuestion=? WHERE numQuestion=? AND numTp=?');
-    $sqliteQuery->bindParam(1, $numQuestionPrec);
-    $sqliteQuery->bindParam(2, $test);
-    $sqliteQuery->bindParam(3, $numTp);
-    $resultp = $sqliteQuery->execute();*/
+
     
     
 }
diff --git a/BddCorrect/Traitement/OrdreDemo.php b/BddCorrect/Traitement/OrdreDemo.php
index 5127180..efd6cf5 100644
--- a/BddCorrect/Traitement/OrdreDemo.php
+++ b/BddCorrect/Traitement/OrdreDemo.php
@@ -4,31 +4,36 @@ require_once('../BDD/SqliteDb.php');
 $db = new SqliteDb('o');
 
 
-$numDemo = $_GET['numDemo'];
-$numChapitre = $_GET['numChapitre'];
-$numDemoPrec = $numDemo-1;
+$numQuestion = $_GET['numDemo'];
+$numTp = $_GET['numChapitre'];
+$numQuestionPrec = $numQuestion-1;
 $test = 999;
 
-if($numDemo!=1){
+if(isset($_GET['des'])){
+    $numQuestion += 1;
+    $numQuestionPrec = $numQuestion-1;
+}
+
+if($numQuestion!=1){
           
     $sqliteQuery = $db->prepare('UPDATE Demonstration SET numDemo=? WHERE numDemo=? AND chapitre=?');   
     $sqliteQuery->bindParam(1, $test);
-    $sqliteQuery->bindParam(2, $numDemo);
-    $sqliteQuery->bindParam(3, $numChapitre);
+    $sqliteQuery->bindParam(2, $numQuestion);
+    $sqliteQuery->bindParam(3, $numTp);
     $result = $sqliteQuery->execute();
    
     
     $sqliteQuery = $db->prepare('UPDATE Demonstration SET numDemo=? WHERE numDemo=? AND chapitre=?');
-    $sqliteQuery->bindParam(1, $numDemo);
-    $sqliteQuery->bindParam(2, $numDemoPrec);
-    $sqliteQuery->bindParam(3, $numChapitre);
+    $sqliteQuery->bindParam(1, $numQuestion);
+    $sqliteQuery->bindParam(2, $numQuestionPrec);
+    $sqliteQuery->bindParam(3, $numTp);
     $resulti = $sqliteQuery->execute();
 
     
     $sqliteQuery = $db->prepare('UPDATE Demonstration SET numDemo=? WHERE numDemo=? AND chapitre=?');
-    $sqliteQuery->bindParam(1, $numDemoPrec);
+    $sqliteQuery->bindParam(1, $numQuestionPrec);
     $sqliteQuery->bindParam(2, $test);
-    $sqliteQuery->bindParam(3, $numChapitre);
+    $sqliteQuery->bindParam(3, $numTp);
     $resultp = $sqliteQuery->execute();
     
     
diff --git a/BddCorrect/Traitement/Suppression.php b/BddCorrect/Traitement/Suppression.php
index 2ab3913..1b751e6 100644
--- a/BddCorrect/Traitement/Suppression.php
+++ b/BddCorrect/Traitement/Suppression.php
@@ -4,112 +4,140 @@
 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();
-
-
-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']);
+if(isset($_GET['type'])){
+    
+    $numDemoSuiv = $_GET['numDemo']+1;
+    
+    $sqliteQuery = $db->prepare('SELECT count(*) FROM Demonstration WHERE chapitre=?');
+    $sqliteQuery->bindParam(1, $_GET['numChapitre']);
     $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']);
+    $sqliteQuery = $db->prepare('DELETE FROM Demonstration WHERE numDemo= ? AND chapitre=? ');
+    $sqliteQuery->bindParam(1, $_GET['numDemo']);
+    $sqliteQuery->bindParam(2, $_GET['numChapitre']);
     $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();
-        
-        $sqliteQuery = $db->prepare('UPDATE Type SET numQuestion=? WHERE numQuestion=? AND numTp=? ');
+    for( $iSuiv = $numDemoSuiv, $j=$_GET['numDemo'] ; $iSuiv <= $nbQuestionsRow['count(*)'] ; $iSuiv++ , $j++ ){              
+        $sqliteQuery = $db->prepare('UPDATE Demonstration SET numDemo=? WHERE numDemo=? AND chapitre=? ');
         $sqliteQuery->bindParam(1, $j);
         $sqliteQuery->bindParam(2, $iSuiv);
-        $sqliteQuery->bindParam(3, $_GET['numTp']);
+        $sqliteQuery->bindParam(3, $_GET['numChapitre']);
         $result = $sqliteQuery->execute();
+        echo 'lol';
     }
 }
+
 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']);
+
+    $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();
-    $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();   
-    
+    $typeRow = $result->fetchArray();
 
-    
-    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();
+    $sqliteQuery = $db->prepare('DELETE FROM Type WHERE numquestion= ? AND numTp=? ');
+    $sqliteQuery->bindParam(1, $_GET['numQuestion']);
+    $sqliteQuery->bindParam(2, $_GET['numTp']);
+    $result = $sqliteQuery->execute();
 
-        
-        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']);
+
+    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();
-        
-        $sqliteQuery = $db->prepare('UPDATE Type SET numQuestion=? WHERE numQuestion=? AND numTp=? ');
-        $sqliteQuery->bindParam(1, $j);
-        $sqliteQuery->bindParam(2, $iSuiv);
-        $sqliteQuery->bindParam(3, $_GET['numTp']);
+        $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();
+
+            $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{
+                $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('UPDATE Type SET numQuestion=? WHERE numQuestion=? AND numTp=? ');
+            $sqliteQuery->bindParam(1, $j);
+            $sqliteQuery->bindParam(2, $iSuiv);
+            $sqliteQuery->bindParam(3, $_GET['numTp']);
+            $result = $sqliteQuery->execute();
+        }
+    }
+}// fin else type
+
 
diff --git a/BddCorrect/Traitement/test2.db b/BddCorrect/Traitement/test2.db
index 35d23d9..e05eb50 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 2022814..bcd43aa 100644
--- a/BddCorrect/config/config.php
+++ b/BddCorrect/config/config.php
@@ -13,6 +13,11 @@ $vues['vueDemonstration']='vues/VueDemonstration.php';
 $vues['vueQCM']='vues/VueQCM.php';
 $vues['vueAccueil']='vues/VueAccueil.php';
 $vues['vueAdmin']='vues/VueAdmin.php';
+$vues['vueLibre']='vues/VueLibre.php';
+$vues['vueAjoutQCM']='vues/vueAjoutQCM.php';
+$vues['vueAjoutDemo']='vues/vueAjoutDemo.php';
+
+$vues['vueGestion']='vues/VueGestionTables.php';
 
 
 $vues['vueBoo']='css/bootstrap.min.css';
diff --git a/BddCorrect/controleur/Controleur.php b/BddCorrect/controleur/Controleur.php
index e81b82e..5798235 100644
--- a/BddCorrect/controleur/Controleur.php
+++ b/BddCorrect/controleur/Controleur.php
@@ -28,6 +28,10 @@ class Controleur {
                 require ($rep.$vues['vueAdmin']);
                 break;
             
+            case 'TP':
+                    //require ($rep.$vues['vueLogin']);
+                $this->afficherQuestions(); 
+                    break;
             case 'Afficher les questions':
                     //require ($rep.$vues['vueLogin']);
                 $this->afficherQuestions(); 
@@ -41,12 +45,19 @@ class Controleur {
                
                 $this->Correction();
                 break;
+            case 'Demonstrations de cours' :
+                //$this->verificationConnexion();
+               
+                $this->afficherDemonstrations();
+                break;
             case 'Afficher les demonstrations' :
                 //$this->verificationConnexion();
                
                 $this->afficherDemonstrations();
                 break;
-            
+            case 'Ajouter une demonstration' : 
+                require ($rep.$vues['vueAjoutDemo']);
+                break;
             case 'Générer Base de données aléatoire':
                 $this->resetRandomBdd();
                 break;
@@ -59,14 +70,26 @@ class Controleur {
                 $this->resetDemonstrations();
                 break;
             
+            case 'Reintiliser les QCM' :
+                $this->resetQCM();
+                break;
             case 'Réintiliser les questions' :
                 $this->resetQuestions();
                 break;
             
-            case 'Afficher les QCM' :                
+            case 'QCM' :                
                 $this->afficherQCM();
                 break;
+            case 'Ajouter QCM' : 
+                require ($rep.$vues['vueAjoutQCM']);
+                break;
+            case 'Creation de table' :                
+                $this->afficherCreationTable();
+                break;
             
+            case 'Gestion de tables' :                
+                $this->afficherGestionTable();
+                break;
             default:
                 $dVueEreur[] ="Erreur d'appel php";           
                 require ($rep.$vues['erreur']);
@@ -85,6 +108,11 @@ class Controleur {
     }    
     
     
+    function resetQCM(){
+        $db = new SqliteDb();
+        $db->createQCM();
+        $this->afficherQCM();
+    }
     
     function resetQuestions(){
         $db = new SqliteDb();
@@ -155,5 +183,17 @@ class Controleur {
     function Correction(){
         require('Correcteur.php');
     }
+    
+    function afficherCreationTable(){
+                global $rep,$vues;
+
+        require ($rep.$vues['vueLibre']);
+    }
+    
+    function afficherGestionTable(){
+        global $rep,$vues;
+
+        require ($rep.$vues['vueGestion']);
+    }
 }
 
diff --git a/BddCorrect/css/VuePrincipale.css b/BddCorrect/css/VuePrincipale.css
index 60e9f87..ddc5ad1 100644
--- a/BddCorrect/css/VuePrincipale.css
+++ b/BddCorrect/css/VuePrincipale.css
@@ -8,42 +8,7 @@ and open the template in the editor.
     Author     : Mehdi
 */
 
-.frm{
-        
-    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;
diff --git a/BddCorrect/css/vueGestionTables.css b/BddCorrect/css/vueGestionTables.css
new file mode 100644
index 0000000..5847d9a
--- /dev/null
+++ b/BddCorrect/css/vueGestionTables.css
@@ -0,0 +1,46 @@
+html,body {
+  height:100%;
+  width:100%;
+  margin:0;
+}
+body {
+  display:flex;
+}
+form {
+  margin:auto;/* nice thing of auto margin if display:flex; it center both horizontal and vertical :) */
+}
+
+.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;
+     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;
+    height: 10px;
+}
+   
\ No newline at end of file
diff --git a/BddCorrect/demonstrations.txt b/BddCorrect/demonstrations.txt
new file mode 100644
index 0000000..7c04f14
--- /dev/null
+++ b/BddCorrect/demonstrations.txt
@@ -0,0 +1,2 @@
+NBA**1**3**5 premières lignes de la table EQUIPE** SELECT * FROM EQUIPE WHERE rownum<6
+NBA**1**4**5 premières lignes de la table GAME** SELECT * FROM GAME WHERE rownum<6
\ No newline at end of file
diff --git a/BddCorrect/nbproject/private/private.xml b/BddCorrect/nbproject/private/private.xml
index 6e2ea97..2b9ec28 100644
--- a/BddCorrect/nbproject/private/private.xml
+++ b/BddCorrect/nbproject/private/private.xml
@@ -3,10 +3,11 @@
     
     
         
-            file:/C:/xampp/htdocs/BddCorrect/css/VueAccueil.css
-            file:/C:/xampp/htdocs/BddCorrect/vues/VueAccueil.php
-            file:/C:/xampp/htdocs/BddCorrect/css/VuePrincipale.css
+            file:/C:/xampp/htdocs/BddCorrect/vues/VueAdmin.php
+            file:/C:/xampp/htdocs/BddCorrect/Traitement/AjoutQuestion.php
+            file:/C:/xampp/htdocs/BddCorrect/BDD/SqliteDb.php
             file:/C:/xampp/htdocs/BddCorrect/vues/VuePrincipale.php
+            file:/C:/xampp/htdocs/BddCorrect/Traitement/Correcteur.php
         
     
 
diff --git a/BddCorrect/questions.txt b/BddCorrect/questions.txt
new file mode 100644
index 0000000..5a7d20f
--- /dev/null
+++ b/BddCorrect/questions.txt
@@ -0,0 +1,2 @@
+requete**NBA**1**1**Lister les joueurs de la table Equipe**SELECT * FROM EQUIPE**10**o
+requete**NBA**1**2**Lister les joueurs de la table JOUEUR**SELECT * FROM JOUEUR**10**o
diff --git a/BddCorrect/vues/VueAccueil.php b/BddCorrect/vues/VueAccueil.php
index 9a5f7a3..e085d6c 100644
--- a/BddCorrect/vues/VueAccueil.php
+++ b/BddCorrect/vues/VueAccueil.php
@@ -28,22 +28,24 @@
 
 
             
-
-
-
+
+
+
+
+
- + - + + --> diff --git a/BddCorrect/vues/VueAdmin.php b/BddCorrect/vues/VueAdmin.php index 0b7aaba..f213a71 100644 --- a/BddCorrect/vues/VueAdmin.php +++ b/BddCorrect/vues/VueAdmin.php @@ -63,6 +63,9 @@
+ + + - - + + + -
+
@@ -34,7 +34,7 @@ NBA -
+
@@ -42,24 +42,74 @@
+ + + + + +
diff --git a/BddCorrect/vues/VueGestionTables.php b/BddCorrect/vues/VueGestionTables.php new file mode 100644 index 0000000..cd66154 --- /dev/null +++ b/BddCorrect/vues/VueGestionTables.php @@ -0,0 +1,28 @@ + + + + + + + + + + + + +
+ + + +
+
+ + + diff --git a/BddCorrect/vues/VuePrincipale.php b/BddCorrect/vues/VuePrincipale.php index 125f891..07da9a0 100644 --- a/BddCorrect/vues/VuePrincipale.php +++ b/BddCorrect/vues/VuePrincipale.php @@ -35,10 +35,7 @@
-
-

test

-

TEST

-
+
@@ -62,7 +59,8 @@

-

+ +

@@ -73,12 +71,7 @@
- - -
- - -
+
@@ -171,6 +164,7 @@ } function MonterQuestion(numQuestion, numTp) { + if(numQuestion > 1){ $.get("Traitement/Ordre.php", { numQuestion : numQuestion, numTp : numTp }, function(data) { @@ -182,6 +176,21 @@ } } + function DescendreQuestion(nbQuestions,numQuestion, numTp) { + //alert(nbQuestions); + + var des = 1; + if(numQuestion < nbQuestions){ + $.get("Traitement/Ordre.php", { des : des , numQuestion : numQuestion, numTp : numTp }, + function(data) { + + //$('#questionsForm')[0].reset(); + $('#inp-questions').trigger("click"); + //window.location.replace("index.php"); + }); + } + } + window.addEventListener('scroll',function() { localStorage.setItem('scrollPosition',window.scrollY); },false); diff --git a/BddCorrect/vues/VueQCM.php b/BddCorrect/vues/VueQCM.php index fa0ce85..6089c72 100644 --- a/BddCorrect/vues/VueQCM.php +++ b/BddCorrect/vues/VueQCM.php @@ -16,29 +16,11 @@ - +
-
-

test

-

TEST

-
+ d
@@ -47,8 +29,7 @@
-

TP 2

- +

TP 2

getNumQuestion(); ?>">

- - - - - + +
- - - +
+ +
-
-
+ +
- - -
-
-

IUT Clermont-Ferrand 2020

-
- -
- - - - - - - - - - diff --git a/BddCorrect/vues/vueAjoutQCM.php b/BddCorrect/vues/vueAjoutQCM.php new file mode 100644 index 0000000..5aa6aeb --- /dev/null +++ b/BddCorrect/vues/vueAjoutQCM.php @@ -0,0 +1,83 @@ + + + + + + + + + + + +
+
+ + +

Ajouter une question(QCM)

+
+ + + + + + + + + + + + + + + + + +
+ +
+ +
+
+
+
+ +
+ +
+ +
+ + + + + +