diff --git a/BddCorrect/AjoutQuestion.php b/BddCorrect/AjoutQuestion.php
new file mode 100644
index 0000000..d396fe2
--- /dev/null
+++ b/BddCorrect/AjoutQuestion.php
@@ -0,0 +1,14 @@
+ajouterRequete($_POST['num'],$_POST['consigne'], $_POST['reponse']);
+else
+//require_once('index.php');
+header("Location: index.php");
+
diff --git a/BddCorrect/Correcteur.php b/BddCorrect/Correcteur.php
index 5c31cc6..98e2d4d 100644
--- a/BddCorrect/Correcteur.php
+++ b/BddCorrect/Correcteur.php
@@ -9,8 +9,8 @@ require_once('OracleDb.php');
header('Content-type: text/plain');
$db = new SqliteDb();
-$conn = oci_connect('u_prems', '123456','localhost/orcl');
-//$conn = oci_connect('meelaichao', 'meelaichao', 'kirov:1521/kirov');
+//$conn = oci_connect('u_prems', '123456','localhost/orcl');
+$conn = oci_connect('meelaichao', 'meelaichao', 'kirov:1521/kirov');
$_SESSION['fi'] = array();
$cmpt = 0;
@@ -165,7 +165,7 @@ foreach ($_POST['textbox'] as $textbox) {
}
//si la question attend un CREATE FUNCTION
else{
- $fonctionQuery = $db->prepare('SELECT * FROM FunctionCorrect WHERE rowid= ? ');
+ $fonctionQuery = $db->prepare('SELECT * FROM FunctionCorrect WHERE numquestion= ? ');
$fonctionQuery->bindParam(1, $numQuestion);
$result = $fonctionQuery->execute();
$fonctionRow = $result->fetchArray();
@@ -181,11 +181,14 @@ foreach ($_POST['textbox'] as $textbox) {
if(oci_num_rows($testUser) != oci_num_rows($testF)){
$err=-3;
}
- while( ($reponseRow = oci_fetch_array($testUser,OCI_NUM)) && $err == 0){
+ while( ($reponseRow = oci_fetch_array($testUser,OCI_NUM)) && $err == 0){ echo 'qdsdqdsqdqs';
+
$vraiReponseRow = oci_fetch_array($testF,OCI_NUM );
+
$verif=1;
- if(sizeof($reponseRow) == sizeof($vraiReponseRow)){
- for($i=0 ; $i< sizeof($vraiReponseRow)-1 ; $i++){
+ if(sizeof($reponseRow) == sizeof($vraiReponseRow)){
+ for($i=0 ; $i< sizeof($vraiReponseRow) ; $i++){echo 'IIIDFFQSIDPFHJ';
+ echo nl2br('reponse : '.$reponseRow[$i].'question : '.$vraiReponseRow[$i]);
if($reponseRow[$i] != $vraiReponseRow[$i]){
$err = -1;
break;
diff --git a/BddCorrect/DAL/QuestionsGateway.php b/BddCorrect/DAL/QuestionsGateway.php
index 65b6e64..ccc1184 100644
--- a/BddCorrect/DAL/QuestionsGateway.php
+++ b/BddCorrect/DAL/QuestionsGateway.php
@@ -10,7 +10,7 @@ class QuestionsGateway {
public function afficherQuestions() {
$i = 0;
- $query = 'SELECT * FROM Correct UNION SELECT * FROM functionCorrect';
+ $query = 'SELECT numquestion,question,reponse FROM Correct UNION SELECT numquestion,question,reponse FROM FunctionCorrect';
$query = $this->db->prepare($query);
$result = $query->execute();
//$resultats = $this->db->query('SELECT found_rows()');
diff --git a/BddCorrect/OracleDb.php b/BddCorrect/OracleDb.php
index 761603d..82c6d92 100644
--- a/BddCorrect/OracleDb.php
+++ b/BddCorrect/OracleDb.php
@@ -16,8 +16,8 @@ class OracleDb {
private $conn;
function __construct() {
- $this->conn = oci_connect('u_prems', '123456', 'localhost/orcl');
- //$this->conn = oci_connect('meelaichao', 'meelaichao', 'kirov:1521/kirov');
+ //$this->conn = oci_connect('u_prems', '123456', 'localhost/orcl');
+ $this->conn = oci_connect('meelaichao', 'meelaichao', 'kirov:1521/kirov');
$this->createRandomTables();
}
diff --git a/BddCorrect/SqliteDb.php b/BddCorrect/SqliteDb.php
index f2ef129..ea1d02d 100644
--- a/BddCorrect/SqliteDb.php
+++ b/BddCorrect/SqliteDb.php
@@ -13,7 +13,7 @@ class SqliteDb extends SQLite3
function createTable(){
//Création De La Table
$this->exec('DROP TABLE Correct');
- $this->exec('CREATE TABLE Correct ( numquestion NUMBER,question STRING, reponse STRING, type STRING, fonctionCorrect STRING,testUser STRING)');
+ $this->exec('CREATE TABLE Correct ( numquestion NUMBER,question STRING, reponse STRING,points NUMBER)');
$this->exec('DROP TABLE FunctionCorrect');
$this->exec('CREATE TABLE FunctionCorrect (numquestion NUMBER, question STRING, reponse STRING, type STRING, fonctionCorrect STRING,testUser STRING)');
@@ -28,67 +28,54 @@ class SqliteDb extends SQLite3
$this->exec("INSERT INTO Type VALUES(2,'query')");
$this->exec("INSERT INTO Type VALUES(3,'query')");
$this->exec("INSERT INTO Type VALUES(4,'query')");
- $this->exec("INSERT INTO Type VALUES(5,'query')");
- $this->exec("INSERT INTO Type VALUES(6,'functionCorrect')");
+ $this->exec("INSERT INTO Type VALUES(5,'functionCorrect')");
//Question 1
$type = 'query';
- $fonctionCorrect = null;
- $testU = null;
+ $points =1;
$reponse = 'SELECT count(*) FROM STATS WHERE prenomnoms=\'Kevin Durant\' ';
- $q = "INSERT INTO Correct VALUES (1,'Trouver le nombre de matchs joués par Kevin Durant', ? ,?,?,?)";
+ $q = "INSERT INTO Correct VALUES (1,'Trouver le nombre de matchs joués par Kevin Durant', ? ,?)";
$stmt = $this->prepare($q);
$stmt->bindParam(1,$reponse);
- $stmt->bindParam(2,$type);
- $stmt->bindParam(3,$fonctionCorrect);
- $stmt->bindParam(4,$testU);
+ $stmt->bindParam(2,$points);
$stmt->execute();
//Question 2
$type = 'query';
- $fonctionCorrect = null;
- $testU = null;
+ $points =1;
$reponse = ' SELECT prenomnoms,datematch,points,equipeadverse FROM STATS WHERE points = (SELECT max(points) FROM STATS)';
- $q = "INSERT INTO Correct VALUES (2,'Lister le(s) joueur(s) ayant marqué le plus de points dans la saison en indiquant son nom, la date du match, le nombre de points, l équipe adverse et le nombre de points marqués ', ? ,?,?,?)";
+ $q = "INSERT INTO Correct VALUES (2,'Lister le(s) joueur(s) ayant marqué le plus de points dans la saison en indiquant son nom, la date du match, le nombre de points, l équipe adverse et le nombre de points marqués ', ? ,?)";
$stmt = $this->prepare($q);
$stmt->bindParam(1,$reponse);
- $stmt->bindParam(2,$type);
- $stmt->bindParam(3,$fonctionCorrect);
- $stmt->bindParam(4,$testU);
+ $stmt->bindParam(2,$points);
$stmt->execute();
//Question 3
$type = 'query';
- $fonctionCorrect = null;
- $testU = null;
+ $points =1;
$reponse = ' SELECT prenomnoms, COUNT(*) FROM STATS GROUP BY prenomnoms HAVING count(*) = (SELECT MAX(c) FROM (SELECT COUNT(*) AS c FROM STATS GROUP BY prenomnoms))';
- $q = "INSERT INTO Correct VALUES (3,'Lister le(s) joueur(s) ayant joué le plus de match pendant la saison', ? ,?,?,?)";
+ $q = "INSERT INTO Correct VALUES (3,'Lister le(s) joueur(s) ayant joué le plus de match pendant la saison', ? ,?)";
$stmt = $this->prepare($q);
$stmt->bindParam(1,$reponse);
- $stmt->bindParam(2,$type);
- $stmt->bindParam(3,$fonctionCorrect);
- $stmt->bindParam(4,$testU);
+ $stmt->bindParam(2,$points);
$stmt->execute();
- //Question 5
+ //Question 4
$type = 'query';
- $fonctionCorrect = null;
- $testU = null;
+ $points =1;
$reponse = 'SELECT nom FROM EQUIPE, STATS WHERE datematch = \'30-OCT-17\' AND prenomnoms = \'Kevin Durant\' AND idequipe = CASE WHEN locationjoueur = \'Away\' THEN equipeadverse WHEN locationjoueur = \'Home\' THEN equipejoueur END ';
- $q = "INSERT INTO Correct VALUES (4,'Déterminer pour Kevin Durant pour le match du 30-oct-17 quelle est l équipe qui joue à domicile', ?,?,?,? )";
+ $q = "INSERT INTO Correct VALUES (4,'Déterminer pour Kevin Durant pour le match du 30-oct-17 quelle est l équipe qui joue à domicile', ?,? )";
$stmt = $this->prepare($q);
$stmt->bindParam(1,$reponse);
- $stmt->bindParam(2,$type);
- $stmt->bindParam(3,$fonctionCorrect);
- $stmt->bindParam(4,$testU);
+ $stmt->bindParam(2,$points);
$stmt->execute();
- //Question 6
+ //Question 5
$this->joueurEtDateRandom($joueurRandom, $dateRandom);
$type = 'fonction';
- $fonctionCorrect = 'CREATE OR REPLACE FUNCTION fpointsmarques(date_match IN VARCHAR2, joueur IN VARCHAR2 ) RETURN NUMBER IS nbPoints NUMBER ; BEGIN SELECT DISTINCT points INTO nbPoints FROM STATS WHERE datematch = date_match AND prenomnoms=joueur; RETURN nbPoints; END;' ;
+ $fonctionCorrect = 'CREATE OR REPLACE FUNCTION fpointsmarques(date_match IN VARCHAR2, joueur IN VARCHAR2 ) RETURN NUMBER IS nbPoints NUMBER ; BEGIN SELECT points INTO nbPoints FROM STATS WHERE datematch = date_match AND prenomnoms=joueur; RETURN nbPoints; END;' ;
$reponse = 'SELECT fpointsmarques(\''.$dateRandom.'\', \''.$joueurRandom.'\') FROM DUAL';
$testU = 'SELECT pointsmarques(\''.$dateRandom.'\', \''.$joueurRandom.'\') FROM DUAL' ;
$q = "INSERT INTO FunctionCorrect VALUES (5,'Ecrire une fonction pointsmarques qui détermine pour une date de match et un joueur donnés quelle est le nombre de points marqués par ce joueur', ?,?,?,? )";
@@ -170,6 +157,20 @@ class SqliteDb extends SQLite3
function createRandomTable(){
}
+
+ function ajouterRequete($num,$consigne,$requete){
+ $qt = "INSERT INTO Type VALUES(?,'query')";
+ $prp=$this->prepare($qt);
+ $prp->bindParam(1, $num);
+ $prp->execute();
+ $q = "INSERT INTO Correct VALUES (?,?,? ,1)";
+ $stmt = $this->prepare($q);
+ $stmt->bindParam(1,$num);
+ $stmt->bindParam(2,$consigne);
+ $stmt->bindParam(3,$requete);
+
+ $stmt->execute();
+ }
}
diff --git a/BddCorrect/modeles/Modele.php b/BddCorrect/modeles/Modele.php
index 8e222de..43ccb26 100644
--- a/BddCorrect/modeles/Modele.php
+++ b/BddCorrect/modeles/Modele.php
@@ -5,7 +5,7 @@ class Modele {
function afficherQuestions(){
$db = new SqliteDb();
- $db->createTable();
+ //$db->createTable();
$qg = new QuestionsGateway($db);
$tabQuestions = $qg->afficherQuestions();
diff --git a/BddCorrect/nbproject/private/private.xml b/BddCorrect/nbproject/private/private.xml
index 9275d2b..7dbabb8 100644
--- a/BddCorrect/nbproject/private/private.xml
+++ b/BddCorrect/nbproject/private/private.xml
@@ -3,10 +3,16 @@