From cad8d58ad055f10e4141ef5a052fdc4b395fc574 Mon Sep 17 00:00:00 2001 From: Mehdi Date: Tue, 23 Jun 2020 09:11:32 +0200 Subject: [PATCH] =?UTF-8?q?nouveau=20type=20de=20correction=20:=20pour=20v?= =?UTF-8?q?=C3=A9rifier=20que=20l'utilisateur=20a=20bien=20ajouter=20une?= =?UTF-8?q?=20colonne=20(Tp2-Exercice=203-=20Q1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BddCorrect/Correcteur.php | 33 ++++++++++++++++++++--- BddCorrect/SqliteDb.php | 14 +++++----- BddCorrect/config/config.php | 2 +- BddCorrect/controleur/Controleur.php | 4 +-- BddCorrect/nbproject/private/private.xml | 4 +-- BddCorrect/test.db | Bin 12288 -> 12288 bytes 6 files changed, 41 insertions(+), 16 deletions(-) diff --git a/BddCorrect/Correcteur.php b/BddCorrect/Correcteur.php index 2e57299..5eeb845 100644 --- a/BddCorrect/Correcteur.php +++ b/BddCorrect/Correcteur.php @@ -60,14 +60,41 @@ foreach ($_POST['textbox'] as $textbox) { else echo "La réponse à la question " .$numQuestion. " est FAUSSE ! \n"; } //si la question attend une modification - /*else if($typeRow['type'] == 'tablemodification'){ + else if($typeRow['type'] == 'tablemodification'){ + $sqliteQuery = $db->prepare('SELECT reponse FROM Correct WHERE rowid= ? '); $sqliteQuery->bindParam(1, $numQuestion); $result = $sqliteQuery->execute(); $sqliteRow = $result->fetchArray(); $vraiReponse = oci_parse($conn, $sqliteRow['reponse']); $enAttente = oci_execute($vraiReponse); - }*/ + + $sqliteQuery = $db->prepare('SELECT fonctioncorrect FROM Correct WHERE rowid= ? '); + $sqliteQuery->bindParam(1, $numQuestion); + $result = $sqliteQuery->execute(); + $sqliteRow = $result->fetchArray(); + + + $t = oci_fetch_all($vraiReponse, $vraiReponseRow); + print_r($vraiReponseRow); + + $err = 1; + foreach ($vraiReponseRow as $v){ + for($i = 0 ; $i < sizeof($v, OCI_NUM) ; $i++){ + if($v[$i] == $sqliteRow[0]){ + $err = 0; + } + } + } + + if($err == 0 ){ + echo "La réponse à la question " .$numQuestion. " est JUSTE ! \n"; + $cmpt++; + } + else echo "La réponse à la question " .$numQuestion. " est FAUSSE ! \n"; + + + } //si la question attend un CREATE FUNCTION else{ $fonctionQuery = $db->prepare('SELECT * FROM Correct WHERE rowid= ? '); @@ -77,7 +104,7 @@ foreach ($_POST['textbox'] as $textbox) { $creationFonction = oci_parse($conn, $fonctionRow['fonctionCorrect']); $creatF = oci_execute($creationFonction); - + $testUser = oci_parse($conn, $fonctionRow['testUser']); $testu = oci_execute($testUser); $testF = oci_parse($conn, $fonctionRow['reponse']); diff --git a/BddCorrect/SqliteDb.php b/BddCorrect/SqliteDb.php index 34aefae..b0aa05e 100644 --- a/BddCorrect/SqliteDb.php +++ b/BddCorrect/SqliteDb.php @@ -16,7 +16,7 @@ class SqliteDb extends SQLite3 $this->exec('CREATE TABLE Correct ( question STRING, reponse STRING, type STRING, fonctionCorrect STRING,testUser STRING)'); //Question 1 - $type = 'query'; + /* $type = 'query'; $fonctionCorrect = null; $testU = null; $reponse = 'SELECT count(*) FROM stats WHERE prenomnoms=\'Kevin Durant\' '; @@ -80,21 +80,21 @@ class SqliteDb extends SQLite3 $stmt->bindParam(2,$type); $stmt->bindParam(3,$fonctionCorrect); $stmt->bindParam(4,$testU); - $stmt->execute(); + $stmt->execute();*/ //Question 9 - /* $type = 'tablemodification'; - $fonctionCorrect = 'idjoueur'; + $type = 'tablemodification'; + $fonctionCorrect = 'IDJOUEUR'; $testU = null; - $reponse = ' SELECT column_name FROM all_tab_columns WHERE table_name = \'JOUEUR\' '; - $q = "INSERT INTO Correct VALUES ('Déterminer pour Kevin Durant pour le match du 30-oct-17 quelle est l équipe qui joue à domicile', ?,?,?,? )"; + $reponse = 'SELECT column_name FROM all_TAB_COLUMNS WHERE table_name = \'TEST\' '; + $q = "INSERT INTO Correct VALUES ('Modifier la table JOUEUR pour ajouter un champ idjoueur', ?,?,?,? )"; $stmt = $this->prepare($q); $stmt->bindParam(1,$reponse); $stmt->bindParam(2,$type); $stmt->bindParam(3,$fonctionCorrect); $stmt->bindParam(4,$testU); - $stmt->execute();*/ + $stmt->execute(); } function createLogin(){ diff --git a/BddCorrect/config/config.php b/BddCorrect/config/config.php index 924d99d..d1f6d5f 100644 --- a/BddCorrect/config/config.php +++ b/BddCorrect/config/config.php @@ -5,6 +5,6 @@ $rep=__DIR__.'/../'; //Vues -$vues['vuePrincipale']='vues/vuePrincipale.php'; +$vues['vuePrincipale']='vues/VuePrincipale.php'; $vues['vueLogin']='vues/vueLogin.php'; diff --git a/BddCorrect/controleur/Controleur.php b/BddCorrect/controleur/Controleur.php index e72db61..b29f603 100644 --- a/BddCorrect/controleur/Controleur.php +++ b/BddCorrect/controleur/Controleur.php @@ -20,8 +20,7 @@ class Controleur { $this->verificationConnexion(); break; default: - $dVueEreur[] ="Erreur d'appel php"; - + $dVueEreur[] ="Erreur d'appel php"; require ($rep.$vues['erreur']); break; } @@ -54,7 +53,6 @@ class Controleur { $modele = new Modele(); if($modele->connection($id,$mdp)==null){ - echo 'AAAAAAAAAA'; require($rep.$vues['vueLogin']); } else $this->afficherQuestions(); diff --git a/BddCorrect/nbproject/private/private.xml b/BddCorrect/nbproject/private/private.xml index 331476b..cb8adc2 100644 --- a/BddCorrect/nbproject/private/private.xml +++ b/BddCorrect/nbproject/private/private.xml @@ -3,13 +3,13 @@ + file:/C:/xampp/htdocs/BddCorrect/config/config.php file:/C:/xampp/htdocs/BddCorrect/controleur/Controleur.php - file:/C:/xampp/htdocs/BddCorrect/DAL/UserGateway.php file:/C:/xampp/htdocs/BddCorrect/SqliteDb.php file:/C:/xampp/htdocs/BddCorrect/vues/VuePrincipale.php file:/C:/xampp/htdocs/BddCorrect/modeles/Modele.php - file:/C:/xampp/htdocs/BddCorrect/vues/vueLogin.php file:/C:/xampp/htdocs/BddCorrect/Correcteur.php + file:/C:/xampp/htdocs/BddCorrect/vues/vueLogin.php diff --git a/BddCorrect/test.db b/BddCorrect/test.db index a4952060f87a6c2041d145db2dae1bc6dc7ebbfa..f9ed7d7bc19703fa5f7825ac11a929014490421b 100644 GIT binary patch delta 276 zcmZojXh@hKCB%M|fq{V;h@pUG-9#NDCibHn6Hf9m>P^<-_hZ!GT*)6KU|*RZk{4BG z;OCv6=N*ve>~5Z(8fxGll$4v69PaBMWn5C3Xq@cqlpj%Em7n4rX<|_B9+k)oG?tM+ zm4QEXGnYane|@7=qXZ*+b)&GpB!h2$N@iMSYLP-tqC!bxQckLZmw%{hXpllderb_H zVpe`>2~e^$Pa!!YF}FY=GX*G;T3QtB>f`DhqM(qRpHrHf7oV4yo2uXzldsL?%^8b3Naa?%2q*6J;XIQL>(fS3${Nwu_QA;4`MR_`wLWb delta 276 zcmZojXh@hKCB$}vfq{V;h@pT*V4{u@6WfiA2`Bj&Ste`o`!TX^uH+9AurCjAay7^( z$u)7yND0mL&I|W7h;m6SaW%Av3NtBkHOi@q46;l$j!Jbda862fOAPf+PAlaF8q3PX z&A{KXnM)y(zuw2yIYc2hu|lIDKQphSSX03*$lq6?xFiwCE-Xzgs;pvUFK%QOXJ7~^ z$}cTTEmFuyRmjWFO)5%NNJ$0iEJ@BNR>;aPJ-o75p&+qH!8^4qGf%;#v?wvJB-j;f md~$wiUWtYlve^pZ9