Remplacement post par get, finalisation de l'ajout. Fonctionnalités : suppression, modifier positionnement...
parent
494d036377
commit
c02fb4bed1
@ -0,0 +1,273 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of OracleDb
|
||||
*
|
||||
* @author Mehdi
|
||||
*/
|
||||
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->createRandomTables();
|
||||
}
|
||||
|
||||
function createRandomTables() {
|
||||
$this->createRandomStats();
|
||||
$this->createRandomJoueur();
|
||||
$this->createRandomEquipe();
|
||||
$this->createRandomGame();
|
||||
}
|
||||
|
||||
function createRandomStats(){
|
||||
//Creation de la table
|
||||
$drop = oci_parse($this->conn, 'DROP TABLE randomstats');
|
||||
oci_execute($drop);
|
||||
$q = oci_parse($this->conn, 'CREATE TABLE randomstats AS SELECT * FROM stats WHERE 1=0');
|
||||
oci_execute($q);
|
||||
|
||||
//Insertion Stats
|
||||
$tabStats = oci_parse($this->conn, 'SELECT * FROM stats');
|
||||
oci_execute($tabStats);
|
||||
|
||||
$tabDate = array();
|
||||
$tabType = array();
|
||||
$tabEquipeJoueur = array();
|
||||
$tabLocation = array();
|
||||
$tabResultat = array();
|
||||
$tabPrenom = array();
|
||||
$tabStatus = array();
|
||||
$tabMinutes = array();
|
||||
$tabNaissance = array();
|
||||
$tabPoints = array();
|
||||
$tabPasses = array();
|
||||
$tabBallesPerdues = array();
|
||||
$tabInterceptions = array();
|
||||
$tabContres = array();
|
||||
$tabFautes = array();
|
||||
$tabTirsPris = array();
|
||||
$tabTirsMarques = array();
|
||||
$tabTirsPourcent = array();
|
||||
$tabTirs2Pris = array();
|
||||
$tabTirs2Marques = array();
|
||||
$tabTirs2Pourcent = array();
|
||||
$tabTirs3Pris = array();
|
||||
$tabTirs3Marques = array();
|
||||
$tabTirs3Pourcent = array();
|
||||
$tabLfPris = array();
|
||||
$tabLfMarques = array();
|
||||
$tabLfPourcent = array();
|
||||
$tabRebondDef = array();
|
||||
$tabRebondOff = array();
|
||||
$tabRebondTotal = array();
|
||||
$tabEquipeAdverse = array();
|
||||
|
||||
while ($statsArray = oci_fetch_array($tabStats, OCI_NUM)) {
|
||||
$tabDate[] = $statsArray[0];
|
||||
$tabType[] = $statsArray[1];
|
||||
$tabEquipeJoueur[] = $statsArray[2];
|
||||
$tabLocation[] = $statsArray[3];
|
||||
$tabResultat[] = $statsArray[4];
|
||||
$tabPrenom[] = $statsArray[5];
|
||||
$tabStatus[] = $statsArray[6];
|
||||
$tabMinutes[] = $statsArray[7];
|
||||
$tabNaissance[] = $statsArray[8];
|
||||
$tabPoints[] = $statsArray[9];
|
||||
$tabPasses[] = $statsArray[10];
|
||||
$tabBallesPerdues[] = $statsArray[11];
|
||||
$tabInterceptions[] = $statsArray[12];
|
||||
$tabContres[] = $statsArray[13];
|
||||
$tabFautes[] = $statsArray[14];
|
||||
$tabTirsPris[] = $statsArray[15];
|
||||
$tabTirsMarques[] = $statsArray[16];
|
||||
$tabTirsPourcent[] = $statsArray[17];
|
||||
$tabTirs2Pris[] = $statsArray[18];
|
||||
$tabTirs2Marques[] = $statsArray[19];
|
||||
$tabTirs2Pourcent[] = $statsArray[20];
|
||||
$tabTirs3Pris[] = $statsArray[21];
|
||||
$tabTirs3Marques[] = $statsArray[22];
|
||||
$tabTirs3Pourcent[] = $statsArray[23];
|
||||
$tabLfPris[] = $statsArray[24];
|
||||
$tabLfMarques[] = $statsArray[25];
|
||||
$tabLfPourcent[] = $statsArray[26];
|
||||
$tabRebondDef[] = $statsArray[27];
|
||||
$tabRebondOff[] = $statsArray[28];
|
||||
$tabRebondTotal[] = $statsArray[29];
|
||||
$tabEquipeAdverse[] = $statsArray[30];
|
||||
}
|
||||
|
||||
shuffle($tabDate);
|
||||
shuffle($tabType);
|
||||
shuffle($tabEquipeJoueur);
|
||||
shuffle($tabLocation);
|
||||
shuffle($tabResultat);
|
||||
shuffle($tabPrenom);
|
||||
shuffle($tabStatus);
|
||||
shuffle($tabMinutes);
|
||||
shuffle($tabNaissance);
|
||||
shuffle($tabPoints);
|
||||
shuffle($tabPasses);
|
||||
shuffle($tabBallesPerdues);
|
||||
shuffle($tabInterceptions);
|
||||
shuffle($tabContres);
|
||||
shuffle($tabFautes);
|
||||
shuffle($tabTirsPris);
|
||||
shuffle($tabTirsMarques);
|
||||
shuffle($tabTirsPourcent);
|
||||
shuffle($tabTirs2Pris);
|
||||
shuffle($tabTirs2Marques);
|
||||
shuffle($tabTirs2Pourcent);
|
||||
shuffle($tabTirs3Pris);
|
||||
shuffle($tabTirs3Marques);
|
||||
shuffle($tabTirs3Pourcent);
|
||||
shuffle($tabLfPris);
|
||||
shuffle($tabLfMarques);
|
||||
shuffle($tabLfPourcent);
|
||||
shuffle($tabRebondDef);
|
||||
shuffle($tabRebondOff);
|
||||
shuffle($tabRebondTotal);
|
||||
shuffle($tabEquipeAdverse);
|
||||
|
||||
for ($i = 0; $i < sizeof($tabDate); $i++) {
|
||||
$insert = oci_parse($this->conn, 'INSERT INTO randomstats VALUES(\'' . $tabDate[$i] . ' \' , \''.$tabType[$i].'\' ,\'' . $tabEquipeJoueur[$i] . '\' , \'' . $tabLocation[$i] . '\' , \'' . $tabResultat[$i] . '\' , \'' . $tabPrenom[$i] . '\' , \'' . $tabStatus[$i] . '\' ,' . $tabMinutes[$i] . ' , \'' . $tabNaissance[$i] . ' \' ,'.$tabPoints[$i] . ' ,'.$tabPasses[$i] . ' ,'.$tabBallesPerdues[$i] . ' ,'.$tabInterceptions[$i] . ' ,'.$tabContres[$i] . ' ,'.$tabFautes[$i] . ' ,'.$tabTirsPris[$i] . ' ,'.$tabTirsMarques[$i] . ' ,'.$tabTirsPourcent[$i] . ' ,'.$tabTirs2Pris[$i] . ' ,'.$tabTirs2Marques[$i] . ' ,'.$tabTirs2Pourcent[$i] . ' ,'.$tabTirs3Pris[$i] . ' ,'.$tabTirs3Marques[$i] . ' ,'.$tabTirs3Pourcent[$i] . ' ,'.$tabLfPris[$i] . ' ,'.$tabLfMarques[$i] . ' ,'.$tabLfPourcent[$i] . ' ,'.$tabRebondDef[$i] . ' ,'.$tabRebondOff[$i] . ' ,'.$tabRebondTotal[$i] . ' , \'' . $tabEquipeAdverse[$i] . '\' ) ');
|
||||
oci_execute($insert);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function createRandomJoueur(){
|
||||
//Creation de la table
|
||||
$drop = oci_parse($this->conn, 'DROP TABLE randomjoueur');
|
||||
oci_execute($drop);
|
||||
$q = oci_parse($this->conn, 'CREATE TABLE randomjoueur AS SELECT * FROM joueur WHERE 1=0');
|
||||
oci_execute($q);
|
||||
|
||||
//Insertion Joueur
|
||||
$tabJoueur = oci_parse($this->conn, 'SELECT * FROM joueur');
|
||||
oci_execute($tabJoueur);
|
||||
|
||||
$tabPrenomnomj = array();
|
||||
$tabAnneedebut = array();
|
||||
$tabAnneefin = array();
|
||||
$tabPoste = array();
|
||||
$tabTaille = array();
|
||||
$tabPoids = array();
|
||||
$tabDateNaissanceJ = array();
|
||||
|
||||
while ($joueurArray = oci_fetch_array($tabJoueur, OCI_NUM)) {
|
||||
$tabPrenomnomj[] = $joueurArray[0];
|
||||
$tabAnneedebut[] = $joueurArray[1];
|
||||
$tabAnneefin[] = $joueurArray[2];
|
||||
$tabPoste[] = $joueurArray[3];
|
||||
$tabTaille[] = $joueurArray[4];
|
||||
$tabPoids[] = $joueurArray[5];
|
||||
$tabDateNaissanceJ[] = $joueurArray[6];
|
||||
}
|
||||
|
||||
shuffle($tabPrenomnomj);
|
||||
shuffle($tabAnneedebut);
|
||||
shuffle($tabAnneefin);
|
||||
shuffle($tabPoste);
|
||||
shuffle($tabTaille);
|
||||
shuffle($tabPoids);
|
||||
shuffle($tabDateNaissanceJ);
|
||||
|
||||
for ($i = 0; $i < sizeof($tabPrenomnomj); $i++) {
|
||||
$insert = oci_parse($this->conn, 'INSERT INTO randomJoueur VALUES(\'' . $tabPrenomnomj[$i] . ' \' ,' . $tabAnneedebut[$i] . ' ,'.$tabAnneefin[$i] . ' , \'' . $tabPoste[$i] . '\', '.$tabTaille[$i] . ','.$tabPoids[$i] . ',\'' . $tabDateNaissanceJ[$i] . '\' ) ');
|
||||
oci_execute($insert);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function createRandomEquipe(){
|
||||
//Creation de la table
|
||||
$drop = oci_parse($this->conn, 'DROP TABLE randomequipe');
|
||||
oci_execute($drop);
|
||||
$q = oci_parse($this->conn, 'CREATE TABLE randomequipe AS SELECT * FROM equipe WHERE 1=0');
|
||||
oci_execute($q);
|
||||
|
||||
//Insertion Joueur
|
||||
$tabEquipe = oci_parse($this->conn, 'SELECT * FROM equipe');
|
||||
oci_execute($tabEquipe);
|
||||
|
||||
$tabId = array();
|
||||
$tabVille = array();
|
||||
$tabNom = array();
|
||||
$tabConference = array();
|
||||
|
||||
while ($equipeArray = oci_fetch_array($tabEquipe, OCI_NUM)) {
|
||||
$tabId[] = $equipeArray[0];
|
||||
$tabVille[] = $equipeArray[1];
|
||||
$tabNom[] = $equipeArray[2];
|
||||
$tabConference[] = $equipeArray[3];
|
||||
}
|
||||
|
||||
shuffle($tabId);
|
||||
shuffle($tabVille);
|
||||
shuffle($tabNom);
|
||||
shuffle($tabConference);
|
||||
|
||||
for ($i = 0; $i < sizeof($tabId); $i++) {
|
||||
$insert = oci_parse($this->conn, 'INSERT INTO randomequipe VALUES(\'' . $tabId[$i] . '\' ,\'' . $tabVille[$i] . '\', \'' . $tabNom[$i] . '\', \'' . $tabConference[$i] . '\' ) ');
|
||||
oci_execute($insert);
|
||||
}
|
||||
}
|
||||
|
||||
function createRandomGame(){
|
||||
//Creation de la table
|
||||
$drop = oci_parse($this->conn, 'DROP TABLE randomgame');
|
||||
oci_execute($drop);
|
||||
$q = oci_parse($this->conn, 'CREATE TABLE randomgame AS SELECT * FROM game WHERE 1=0');
|
||||
oci_execute($q);
|
||||
|
||||
//Insertion Joueur
|
||||
$tabGame = oci_parse($this->conn, 'SELECT * FROM game');
|
||||
oci_execute($tabGame);
|
||||
|
||||
$tabDate = array();
|
||||
$tabHoraire = array();
|
||||
$tabIdDomicile = array();
|
||||
$tabIdExterieur = array();
|
||||
$tabResultatDomicile = array();
|
||||
$tabResultatExterieur = array();
|
||||
$tabScoreDomicile = array();
|
||||
$tabScoreExterieur = array();
|
||||
|
||||
while ($gameArray = oci_fetch_array($tabGame, OCI_NUM)) {
|
||||
$tabDate[] = $gameArray[0];
|
||||
$tabHoraire[] = $gameArray[1];
|
||||
$tabIdDomicile[] = $gameArray[2];
|
||||
$tabResultatDomicile[] = $gameArray[3];
|
||||
$tabScoreDomicile[] = $gameArray[4];
|
||||
$tabIdExterieur[] = $gameArray[5];
|
||||
$tabResultatExterieur[] = $gameArray[6];
|
||||
$tabScoreExterieur[] = $gameArray[7];
|
||||
}
|
||||
shuffle($tabDate);
|
||||
shuffle($tabHoraire);
|
||||
shuffle($tabIdDomicile);
|
||||
shuffle($tabResultatDomicile);
|
||||
shuffle($tabScoreDomicile);
|
||||
shuffle($tabIdExterieur);
|
||||
shuffle($tabResultatExterieur);
|
||||
shuffle($tabScoreExterieur);
|
||||
|
||||
for ($i = 0; $i < sizeof($tabDate); $i++) {
|
||||
$insert = oci_parse($this->conn, 'INSERT INTO randomgame VALUES(\'' . $tabDate[$i] . '\' ,' . $tabHoraire[$i] . ', \'' . $tabIdDomicile[$i] . '\', \''.$tabResultatDomicile[$i].'\', \''.$tabScoreDomicile[$i].'\', \''.$tabIdExterieur[$i].'\', \''.$tabResultatExterieur[$i].'\',' .$tabScoreExterieur[$i].' ) ');
|
||||
oci_execute($insert);
|
||||
}
|
||||
}
|
||||
|
||||
public function getConn(){
|
||||
return $this->conn;
|
||||
}
|
||||
}
|
@ -0,0 +1,248 @@
|
||||
<?php
|
||||
//header('Content-type: text/plain');
|
||||
require_once('OracleDb.php');
|
||||
|
||||
class SqliteDb extends SQLite3
|
||||
{
|
||||
private $conn;
|
||||
function __construct($o = 'n')
|
||||
{
|
||||
$odb = new OracleDb();
|
||||
$this->conn = $odb->getConn();
|
||||
if($o == 'n')
|
||||
$this->open('Traitement/test.db');
|
||||
else $this->open('test.db');
|
||||
/*$this->createLogin();
|
||||
$this->createTable();
|
||||
$this->createDemonstration();
|
||||
$this->createQCM();*/
|
||||
}
|
||||
|
||||
|
||||
function createTable(){
|
||||
//Création De La Table
|
||||
$this->exec('DROP TABLE Correct');
|
||||
$this->exec('CREATE TABLE Correct ( bddConcernee STRING,numTp NUMBER, numquestion NUMBER,question STRING, reponse STRING,points NUMBER,aleatoire CHAR)');
|
||||
|
||||
$this->exec('DROP TABLE FunctionCorrect');
|
||||
$this->exec('CREATE TABLE FunctionCorrect (bddConcernee STRING,numTp NUMBER, numquestion NUMBER, question STRING, reponse STRING, type STRING, fonctionCorrect STRING,testUser STRING)');
|
||||
|
||||
$this->exec('DROP TABLE TriggerCorrect');
|
||||
$this->exec('CREATE TABLE TriggerCorrect ( bddConcernee STRING,numTp NUMBER, numquestion NUMBER,question STRING, reponse STRING, type STRING, fonctionCorrect STRING,testUser STRING)');
|
||||
|
||||
$this->exec('DROP TABLE Type');
|
||||
$this->exec('CREATE TABLE Type ( numTp NUMBER,numQuestion NUMBER,type STRING)');
|
||||
|
||||
$this->exec("INSERT INTO Type VALUES(2,1,'query')");
|
||||
$this->exec("INSERT INTO Type VALUES(2,2,'query')");
|
||||
$this->exec("INSERT INTO Type VALUES(2,3,'query')");
|
||||
$this->exec("INSERT INTO Type VALUES(2,4,'query')");
|
||||
$this->exec("INSERT INTO Type VALUES(2,5,'functionCorrect')");
|
||||
|
||||
|
||||
//Question 1
|
||||
$type = 'query';
|
||||
$points =1;
|
||||
$reponse = 'SELECT count(*) FROM STATS WHERE prenomnoms=\'Kevin Durant\' ';
|
||||
$q = "INSERT INTO Correct VALUES ('NBA',2,1,'Trouver le nombre de matchs joués par Kevin Durant', ? ,?,'o')";
|
||||
$stmt = $this->prepare($q);
|
||||
$stmt->bindParam(1,$reponse);
|
||||
$stmt->bindParam(2,$points);
|
||||
$stmt->execute();
|
||||
|
||||
//Question 2
|
||||
$type = 'query';
|
||||
$points =1;
|
||||
$reponse = ' SELECT prenomnoms,datematch,points,equipeadverse FROM STATS WHERE points = (SELECT max(points) FROM STATS)';
|
||||
$q = "INSERT INTO Correct VALUES ('NBA',2,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 ', ? ,?,'o')";
|
||||
$stmt = $this->prepare($q);
|
||||
$stmt->bindParam(1,$reponse);
|
||||
$stmt->bindParam(2,$points);
|
||||
$stmt->execute();
|
||||
|
||||
//Question 3
|
||||
$type = 'query';
|
||||
$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 ('NBA',2,3,'Lister le(s) joueur(s) ayant joué le plus de match pendant la saison', ? ,?,'o')";
|
||||
$stmt = $this->prepare($q);
|
||||
$stmt->bindParam(1,$reponse);
|
||||
$stmt->bindParam(2,$points);
|
||||
$stmt->execute();
|
||||
|
||||
//Question 4
|
||||
$type = 'query';
|
||||
$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 ('NBA',2,4,'Déterminer pour Kevin Durant pour le match du 30-oct-17 quelle est l équipe qui joue à domicile', ?,?,'n' )";
|
||||
$stmt = $this->prepare($q);
|
||||
$stmt->bindParam(1,$reponse);
|
||||
$stmt->bindParam(2,$points);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
//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 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 ('NBA',2,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', ?,?,?,? )";
|
||||
$stmt = $this->prepare($q);
|
||||
$stmt->bindParam(1,$reponse);
|
||||
$stmt->bindParam(2,$type);
|
||||
$stmt->bindParam(3,$fonctionCorrect);
|
||||
$stmt->bindParam(4,$testU);
|
||||
$stmt->execute();
|
||||
|
||||
/* //Question 9
|
||||
$type = 'tablemodification';
|
||||
$fonctionCorrect = 'IDJOUEUR';
|
||||
$testU = null;
|
||||
$testP = 'SELECT data_type FROM all_TAB_COLUMNS WHERE table_name = \'JOUEUR\' '; //pour vérifier l
|
||||
$reponse = 'SELECT column_name FROM all_TAB_COLUMNS WHERE table_name = \'TEST\' ';
|
||||
$q = "INSERT INTO Correct VALUES (6,'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);
|
||||
|
||||
//Question 10
|
||||
$type = 'query';
|
||||
$fonctionCorrect = null;
|
||||
$testU = null;
|
||||
$testP = null;
|
||||
$reponse = 'SELECT id_joueur FROM STATS WHERE table_name = \'TEST\' ';
|
||||
$q = "INSERT INTO Correct VALUES (7,'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();*/
|
||||
|
||||
//QUESITION 1 TP2
|
||||
$type='trigger';
|
||||
$fonctionCorrect = 'CREATE OR REPLACE TRIGGER supprJ BEFORE DELETE ON joueur FOR EACH ROW DECLARE duser varchar2(30); ddate date; BEGIN SELECT user,sysdate INTO duser,ddate FROM DUAL; INSERT INTO TRACE VALUES(ddate, duser,\'Suppression de \' || :old.prenomnomj); END;' ;
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
function createDemonstration(){
|
||||
$this->exec('DROP TABLE Demonstration');
|
||||
$this->exec('CREATE TABLE Demonstration ( bddconcernee STRING ,chapitre NUMBER, numDemo NUMBER, description STRING,reponse STRING)');
|
||||
|
||||
$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')");
|
||||
|
||||
}
|
||||
|
||||
function createQCM(){
|
||||
$this->exec('DROP TABLE QcmQuestion');
|
||||
$this->exec('CREATE TABLE QcmQuestion ( numQuestion NUMBER, question STRING)');
|
||||
|
||||
$this->exec('DROP TABLE QcmReponse');
|
||||
$this->exec('CREATE TABLE QcmReponse ( numReponse NUMBER, reponse STRING, numQuestion NUMBER)');
|
||||
|
||||
$this->exec('DROP TABLE QcmCorrection');
|
||||
$this->exec('CREATE TABLE QcmCorrection ( numQuestion NUMBER, numReponse NUMBER)');
|
||||
|
||||
//Question 1
|
||||
$this->exec("INSERT INTO QcmQuestion VALUES(1,'Ceci est la question 1')");
|
||||
|
||||
$this->exec("INSERT INTO QcmReponse VALUES(1,'Ceci est la reponse 1 de la question 1(fausse)',1)");
|
||||
$this->exec("INSERT INTO QcmReponse VALUES(2,'Ceci est la reponse 2 de la question 1(Vraie)',1)");
|
||||
$this->exec("INSERT INTO QcmReponse VALUES(3,'Ceci est la reponse 3 de la question 1(fausse)',1)");
|
||||
|
||||
$this->exec("INSERT INTO QcmCorrection VALUES(1,2)");
|
||||
|
||||
//Question 2
|
||||
$this->exec("INSERT INTO QcmQuestion VALUES(2,'Ceci est la question 2')");
|
||||
|
||||
$this->exec("INSERT INTO QcmReponse VALUES(1,'Ceci est la reponse 1 de la question 2(Vraie)',2)");
|
||||
$this->exec("INSERT INTO QcmReponse VALUES(2,'Ceci est la reponse 2 de la question 2(fausse)',2)");
|
||||
$this->exec("INSERT INTO QcmReponse VALUES(3,'Ceci est la reponse 3 de la question 2(fausse)',2)");
|
||||
|
||||
$this->exec("INSERT INTO QcmCorrection VALUES(2,1)");
|
||||
|
||||
}
|
||||
|
||||
function createLogin(){
|
||||
$mdp = password_hash('mdptest', PASSWORD_DEFAULT);
|
||||
$username = 'test';
|
||||
$this->exec('DROP TABLE login');
|
||||
$this->exec('CREATE TABLE login ( username STRING, password STRING)');
|
||||
|
||||
$stmt = $this->prepare("INSERT INTO login VALUES(? , ?)");
|
||||
$stmt->bindParam(1, $username);
|
||||
$stmt->bindParam(2, $mdp);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
function joueurEtDateRandom(&$nomRandom, &$dateRandom){
|
||||
|
||||
$listeJoueurQuery = oci_parse($this->conn, 'SELECT prenomnoms,datematch FROM STATS INTERSECT SELECT prenomnoms,datematch FROM randomstats ');
|
||||
oci_execute($listeJoueurQuery);
|
||||
$listeJoueurRows = oci_fetch_all($listeJoueurQuery, $listeJoueurArray);
|
||||
//print_r($listeJoueurArray);
|
||||
$rand_keys = array_rand($listeJoueurArray['PRENOMNOMS'], 1);
|
||||
$nomRandom = $listeJoueurArray['PRENOMNOMS'][$rand_keys];
|
||||
$dateRandom = $listeJoueurArray['DATEMATCH'][$rand_keys];
|
||||
}
|
||||
|
||||
function joueurEtDateRandom2(&$nomRandom, &$dateRandom){
|
||||
$listeJoueurQuery = oci_parse($this->conn, 'SELECT prenomnoms,datematch FROM STATS');
|
||||
oci_execute($listeJoueurQuery);
|
||||
$listeJoueurRows = oci_fetch_all($listeJoueurQuery, $listeJoueurArray);
|
||||
//print_r($listeJoueurArray);
|
||||
$rand_keys = array_rand($listeJoueurArray['PRENOMNOMS'], 1);
|
||||
$nomRandom = $listeJoueurArray['PRENOMNOMS'][$rand_keys];
|
||||
$dateRandom = $listeJoueurArray['DATEMATCH'][$rand_keys];
|
||||
}
|
||||
|
||||
function ajouterRequete($contexte,$tp,$num,$consigne,$requete){
|
||||
$qt = "INSERT INTO Type VALUES(?,?,'query')";
|
||||
$prp=$this->prepare($qt);
|
||||
$prp->bindParam(1, $num);
|
||||
$prp->bindParam(2, $tp);
|
||||
$prp->execute();
|
||||
$q = "INSERT INTO Correct VALUES (?,?,?,?,? ,1,'o')";
|
||||
$stmt = $this->prepare($q);
|
||||
$stmt->bindParam(1,$contexte);
|
||||
$stmt->bindParam(2,$tp);
|
||||
$stmt->bindParam(3,$num);
|
||||
$stmt->bindParam(4,$consigne);
|
||||
$stmt->bindParam(5,$requete);
|
||||
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
function ajouterDemonstration($contexte,$chapitre,$num,$intitule,$requete){
|
||||
$q = "INSERT INTO Demonstration VALUES (?,?,?,?,?)";
|
||||
$stmt = $this->prepare($q);
|
||||
$stmt->bindParam(1,$contexte);
|
||||
$stmt->bindParam(2,$chapitre);
|
||||
$stmt->bindParam(3,$num);
|
||||
$stmt->bindParam(4,$intitule);
|
||||
$stmt->bindParam(5,$requete);
|
||||
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
function supprimerRequete($numQuestion,$numTp){
|
||||
$qt = "DELETE FROM Type WHERE numTp=? AND numQuestion=? ";
|
||||
$prp=$this->prepare($qt);
|
||||
$prp->bindParam(1, $numTp);
|
||||
$prp->bindParam(2, $numQuestion);
|
||||
$prp->execute();
|
||||
|
||||
$qt = "DELETE FROM Correct WHERE numTp=? AND numQuestion=? ";
|
||||
$prp=$this->prepare($qt);
|
||||
$prp->bindParam(1, $numTp);
|
||||
$prp->bindParam(2, $numQuestion);
|
||||
$prp->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once('../BDD/SqliteDb.php');
|
||||
require_once('../BDD/OracleDb.php');
|
||||
header('Content-type: text/plain');
|
||||
$db = new SqliteDb();
|
||||
|
||||
$n = new OracleDb();
|
||||
//$conn = oci_connect('u_prems', '123456','localhost/orcl');
|
||||
//$conn = oci_connect('meelaichao', 'meelaichao', 'kirov:1521/kirov');
|
||||
$conn = $n->getConn();
|
||||
$textbox = $_GET['textbox'];
|
||||
|
||||
$UserQuery = oci_parse($conn, $textbox);
|
||||
$reponseUser = oci_execute($UserQuery);
|
||||
$numLigne = 0;
|
||||
while( ($oracleRow = oci_fetch_array($UserQuery, OCI_NUM))) {
|
||||
$numLigne++;
|
||||
echo '<strong> Ligne '.$numLigne.' : </strong>';
|
||||
for($i=0 ; $i< sizeof($oracleRow) ; $i++){
|
||||
echo $oracleRow[$i].' ; ';
|
||||
}
|
||||
echo '</br>';
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
require_once('../BDD/SqliteDb.php');
|
||||
require_once('controleur/Controleur.php');
|
||||
|
||||
|
||||
$db = new SqliteDb();
|
||||
|
||||
|
||||
$db->ajouterDemonstration($_GET['bdd'],$_GET['tp'],$_GET['num'],$_GET['consigne'], $_GET['reponse']);
|
||||
|
||||
//require_once('index.php');
|
||||
header("Location: index.php");
|
||||
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
require_once('../BDD/SqliteDb.php');
|
||||
require_once('controleur/Controleur.php');
|
||||
|
||||
|
||||
$db = new SqliteDb();
|
||||
|
||||
if(isset($_GET['modif'])){
|
||||
$db->supprimerRequete($_GET['num'], $_GET['tp']);
|
||||
}
|
||||
|
||||
if ($_GET["type"] == 'requete'){
|
||||
|
||||
$db->ajouterRequete($_GET['bdd'],$_GET['tp'],$_GET['num'],$_GET['consigne'], $_GET['reponse']);
|
||||
}
|
||||
//require_once('index.php');
|
||||
header("Location: index.php");
|
||||
|
@ -0,0 +1,349 @@
|
||||
<?php
|
||||
ob_start();
|
||||
|
||||
|
||||
session_start();
|
||||
require_once('../BDD/SqliteDb.php');
|
||||
require_once('../BDD/OracleDb.php');
|
||||
header('Content-type: text/plain');
|
||||
$db = new SqliteDb('o');
|
||||
|
||||
$n = new OracleDb();
|
||||
//$conn = oci_connect('u_prems', '123456','localhost/orcl');
|
||||
//$conn = oci_connect('meelaichao', 'meelaichao', 'kirov:1521/kirov');
|
||||
$conn = $n->getConn();
|
||||
|
||||
$_SESSION['fi'] = array();
|
||||
$cmpt = 0;
|
||||
$numQuestion = 0;
|
||||
header("Cache-Control: no cache");
|
||||
|
||||
|
||||
$textbox = $_GET['textbox'];
|
||||
/*$numQuestion++;
|
||||
$ic = "$numQuestion";*/
|
||||
|
||||
$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, $numQuestion);
|
||||
$typeQuery->bindParam(2, $numTp);
|
||||
$resultType = $typeQuery->execute();
|
||||
$typeRow = $resultType->fetchArray();
|
||||
$err = 0;
|
||||
$verif =0;
|
||||
|
||||
//si la question attend un SELECT
|
||||
|
||||
if($typeRow['type'] == 'query'){
|
||||
// <editor-fold desc="vérification avec la vraie BDD">
|
||||
|
||||
$sqliteQuery = $db->prepare('SELECT reponse FROM Correct WHERE numquestion= ? AND numTp= ? ');
|
||||
$sqliteQuery->bindParam(1, $numQuestion);
|
||||
$sqliteQuery->bindParam(2, $numTp);
|
||||
|
||||
$result = $sqliteQuery->execute();
|
||||
$sqliteRow = $result->fetchArray();
|
||||
|
||||
|
||||
$vraiReponse = oci_parse($conn, $sqliteRow['reponse']);
|
||||
$enAttente = oci_execute($vraiReponse);
|
||||
|
||||
if(oci_num_rows($UserQuery) != oci_num_rows($vraiReponse)){
|
||||
$err=-3;
|
||||
}
|
||||
while( ($oracleRow = oci_fetch_array($UserQuery, OCI_NUM)) && $err == 0 ){
|
||||
$vraiReponseRow = oci_fetch_array($vraiReponse,OCI_NUM );
|
||||
$verif = 1;
|
||||
if(sizeof($oracleRow) == sizeof($vraiReponseRow)){
|
||||
|
||||
for($i=0 ; $i< sizeof($vraiReponseRow) ; $i++){
|
||||
if($oracleRow[$i] != $vraiReponseRow[$i]){
|
||||
$err = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$err = -2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//echo nl2br("\n ------------test : ".$err." test2 : ".$verif."\n");
|
||||
// </editor-fold>
|
||||
|
||||
$aleatoireQuery = $db->prepare('SELECT aleatoire FROM Correct WHERE numQuestion = ? AND numTp= ?');
|
||||
$aleatoireQuery->bindParam(1, $numQuestion);
|
||||
$aleatoireQuery->bindParam(2, $numTp);
|
||||
$resultAleatoire = $aleatoireQuery->execute();
|
||||
$aleatoireRow = $resultAleatoire->fetchArray();
|
||||
if($aleatoireRow['aleatoire'] == 'o'){
|
||||
// <editor-fold desc="vérification avec bdd aléatoire">
|
||||
$nv= $sqliteRow['reponse'];
|
||||
$txt = $textbox;
|
||||
|
||||
if(strpos($sqliteRow['reponse'],"GAME")){
|
||||
$nv = str_replace('GAME', ' randomgame ', $nv);
|
||||
$txt = str_replace('GAME', 'randomgame', $txt);
|
||||
|
||||
}
|
||||
if (strpos($sqliteRow['reponse'],"EQUIPE")){
|
||||
$nv= str_replace('EQUIP', ' randomequipe ', $nv);
|
||||
$txt = str_replace('EQUIPE', 'randomequipe', $txt);
|
||||
}
|
||||
if (strpos($sqliteRow['reponse'],"STATS")){
|
||||
$nv= str_replace('STATS' , ' randomstats ', $nv);
|
||||
$txt = str_replace('STATS', ' randomstats ', $txt);
|
||||
}
|
||||
if (strpos($sqliteRow['reponse'],"JOUEUR")) {
|
||||
$nv = str_replace('JOUEUR', 'randomjoueur', $nv);
|
||||
$txt = str_replace('JOUEUR', 'randomjoueur', $txt);
|
||||
}
|
||||
|
||||
$UserQueryRandom = oci_parse($conn, $txt);
|
||||
$reponseUser = oci_execute($UserQueryRandom);
|
||||
|
||||
$vraiReponseRandom = oci_parse($conn, $nv);
|
||||
$enAttente = oci_execute($vraiReponseRandom);
|
||||
if(oci_num_rows($UserQueryRandom) != oci_num_rows($vraiReponseRandom)){
|
||||
$err=-3;
|
||||
}
|
||||
$verif = 0;
|
||||
while( ($oracleRowRandom = oci_fetch_array($UserQueryRandom, OCI_NUM)) && $err == 0 ){
|
||||
$vraiReponseRowRandom = oci_fetch_array($vraiReponseRandom,OCI_NUM );
|
||||
$verif = 1;
|
||||
|
||||
if(sizeof($oracleRowRandom) == sizeof($vraiReponseRowRandom)){
|
||||
for($i=0 ; $i< sizeof($vraiReponseRowRandom) ; $i++){
|
||||
if($oracleRowRandom[$i] != $vraiReponseRowRandom[$i]){
|
||||
$err = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$err = -2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// </editor-fold>
|
||||
//echo nl2br("\n ------------testerr : ".$err." test2verif : ".$verif."\n");
|
||||
}
|
||||
// <editor-fold desc="Résultat">
|
||||
if($err == 0 && $verif==1){
|
||||
echo "<strong>La réponse à la question " .$numQuestion. " est JUSTE ! \n</strong>";
|
||||
$cmpt++;
|
||||
}
|
||||
else echo "<strong>La réponse à la question " .$numQuestion. " est FAUSSE ! \n</strong>";
|
||||
//</editor-fold>
|
||||
}
|
||||
//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, $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, $numQuestion);
|
||||
$sqliteQuery->bindParam(2, $numTp);
|
||||
$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 FunctionCorrect WHERE numquestion= ? AND numTp= ? ');
|
||||
$fonctionQuery->bindParam(1, $numQuestion);
|
||||
$fonctionQuery->bindParam(2, $numTp);
|
||||
$result = $fonctionQuery->execute();
|
||||
$fonctionRow = $result->fetchArray();
|
||||
|
||||
$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']);
|
||||
$testf = oci_execute($testF);
|
||||
|
||||
if(oci_num_rows($testUser) != oci_num_rows($testF)){
|
||||
$err=-3;
|
||||
}
|
||||
while( ($reponseRow = oci_fetch_array($testUser,OCI_NUM)) && $err == 0){
|
||||
|
||||
$vraiReponseRow = oci_fetch_array($testF,OCI_NUM );
|
||||
|
||||
$verif=1;
|
||||
if(sizeof($reponseRow) == sizeof($vraiReponseRow)){
|
||||
for($i=0 ; $i< sizeof($vraiReponseRow) ; $i++){
|
||||
//echo nl2br('reponse : '.$reponseRow[$i].'question : '.$vraiReponseRow[$i]);
|
||||
if($reponseRow[$i] != $vraiReponseRow[$i]){
|
||||
$err = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$err = -2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold desc="vérification avec bdd aléatoire">
|
||||
|
||||
$nv = $fonctionRow['fonctionCorrect'];
|
||||
$txt = $textbox;
|
||||
|
||||
if(strpos($fonctionRow['fonctionCorrect'],"GAME")){
|
||||
$nv = str_replace('GAME', ' randomgame ', $nv);
|
||||
$txt = str_replace('GAME', 'randomgame', $txt);
|
||||
}
|
||||
if (strpos($fonctionRow['fonctionCorrect'],"EQUIPE")){
|
||||
$nv= str_replace('EQUIPE', ' randomequipe ', $nv);
|
||||
$txt = str_replace('EQUIPE', 'randomequipe', $txt);
|
||||
}
|
||||
if (strpos($fonctionRow['fonctionCorrect'],"STATS")){
|
||||
$nv= str_replace('STATS' , ' randomstats ', $nv);
|
||||
$txt = str_replace('STATS', ' randomstats ', $txt);
|
||||
}
|
||||
if (strpos($fonctionRow['fonctionCorrect'],"JOUEUR")) {
|
||||
$nv = str_replace('JOUEUR', 'randomjoueur', $nv);
|
||||
$txt = str_replace('JOUEUR', 'randomjoueur', $txt);
|
||||
}
|
||||
|
||||
$UserQueryRandom = oci_parse($conn, $txt);
|
||||
$reponseUserRandom = oci_execute($UserQueryRandom);
|
||||
//echo 'bbbb'.$txt;
|
||||
$creationFonctionRandom = oci_parse($conn, $nv);
|
||||
$creatFRandom = oci_execute($creationFonctionRandom);
|
||||
//echo '154789'.$nv;
|
||||
|
||||
$testUserRandom = oci_parse($conn, $fonctionRow['testUser']);
|
||||
$testuR = oci_execute($testUserRandom);
|
||||
//echo 'aaa'.$fonctionRow['testUser'];
|
||||
$testFR = oci_parse($conn, $fonctionRow['reponse']);
|
||||
$testfR = oci_execute($testFR);
|
||||
|
||||
|
||||
if(oci_num_rows($testUserRandom) != oci_num_rows($testFR)){
|
||||
$err=-3;
|
||||
}
|
||||
$verif=0;
|
||||
while( ($reponseRowRandom = oci_fetch_array($testUserRandom,OCI_NUM)) && $err == 0){
|
||||
$vraiReponseRowRandom = oci_fetch_array($testFR,OCI_NUM );
|
||||
$verif=1;
|
||||
if(sizeof($reponseRowRandom) == sizeof($vraiReponseRowRandom)){
|
||||
for($i=0 ; $i< sizeof($vraiReponseRowRandom)-1 ; $i++){
|
||||
if($reponseRowRandom[$i] != $vraiReponseRowRandom[$i]){
|
||||
$err = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$err = -2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//echo '.....'.$verif;
|
||||
// </editor-fold>
|
||||
|
||||
if($err == 0 && $verif==1 ){
|
||||
echo "La réponse à la question " .$numQuestion. " est JUSTE ! \n";
|
||||
$cmpt++;
|
||||
}
|
||||
else echo "La réponse à la question " .$numQuestion. " est FAUSSE ! \n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Eléments d'authentification LDAP
|
||||
/*$ldaprdn = 'cn=web_bind,OU=DSI,dc=iut,dc=local'; // DN ou RDN LDAP
|
||||
$ldappass = 'ldap'; // Mot de passe associé
|
||||
|
||||
// Connexion au serveur LDAP
|
||||
$ldapconn = ldap_connect("ldap://192.168.105.5",389)
|
||||
or die("Impossible de se connecter au serveur LDAP.");
|
||||
|
||||
if ($ldapconn) {
|
||||
|
||||
// Connexion au serveur LDAP
|
||||
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
|
||||
|
||||
// Vérification de l'authentification
|
||||
if ($ldapbind) {
|
||||
// echo "Connexion LDAP réussie...";
|
||||
} else {
|
||||
// echo "Connexion LDAP échouée...";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$dn="OU=ITC,OU=uca,OU=etudiants,OU=utilisateurs,DC=iut,
|
||||
DC=local";
|
||||
|
||||
$filter = "cn=".$_SERVER['REMOTE_USER'];
|
||||
$sr = ldap_search($ldapconn, $dn, $filter);
|
||||
|
||||
|
||||
/* echo 'Le résultat de la recherche est ' . $sr . '<br />';
|
||||
|
||||
echo 'Le nombre d\'entrées retournées est ' . ldap_count_entries($ldapconn,$sr)
|
||||
. '<br />';
|
||||
|
||||
echo 'Lecture des entrées ...<br />';
|
||||
|
||||
echo 'Données pour ' . $info["count"] . ' entrées:<br />';
|
||||
for ($i=0; $i<$info["count"]; $i++) {
|
||||
echo 'dn est : ' . $info[$i]["dn"] . '<br />';
|
||||
echo 'premiere entree cn : ' . $info[$i]["cn"][0] . '<br />';
|
||||
echo 'premier date de naissance : ' . $info[$i]["postofficebox"][0] . '<br />';
|
||||
}
|
||||
$info = ldap_get_entries($ldapconn, $sr);
|
||||
$_SESSION["sn"] = $info[0]["sn"][0];
|
||||
|
||||
$txt = 'Résultat de '.$info[0]["sn"][0] .' : '. $cmpt . '/' . $numQuestion;
|
||||
echo $txt;
|
||||
|
||||
|
||||
|
||||
//file_put_contents('resultat.html', ob_get_contents());
|
||||
|
||||
$fic = fopen("result.txt", "w");
|
||||
fwrite($fic, $txt);
|
||||
fclose($fic);*/
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
require_once('../BDD/SqliteDb.php');
|
||||
require_once('../BDD/OracleDb.php');
|
||||
$db = new SqliteDb();
|
||||
|
||||
$oracleDb = new OracleDb();
|
||||
$conn = $oracleDb->getConn();
|
||||
|
||||
|
||||
$query = $db->prepare('SELECT numReponse FROM QcmCorrection WHERE numQuestion=?');
|
||||
$query->bindParam(1, $_GET['numQuestion']);
|
||||
$result = $query->execute();
|
||||
$numReponseRow = $result->fetchArray();
|
||||
|
||||
$reponseQuery = $db->prepare('SELECT reponse FROM QcmReponse WHERE numReponse=? AND numQuestion=?');
|
||||
$reponseQuery->bindParam(1, $numReponseRow['numReponse']);
|
||||
$reponseQuery->bindParam(2, $_GET['numQuestion']);
|
||||
$reponseResult = $reponseQuery->execute();
|
||||
$reponseRow = $reponseResult->fetchArray();
|
||||
|
||||
if($_GET['textbox'] == $reponseRow['reponse']){
|
||||
echo 'Bonne réponse !';
|
||||
}
|
||||
else echo $reponseRow['reponse'].'Mauvaise Réponse.';
|
||||
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
require_once('../BDD/SqliteDb.php');
|
||||
require_once('../BDD/OracleDb.php');
|
||||
header('Content-type: text/plain');
|
||||
$db = new SqliteDb();
|
||||
|
||||
$n = new OracleDb();
|
||||
//$conn = oci_connect('u_prems', '123456','localhost/orcl');
|
||||
//$conn = oci_connect('meelaichao', 'meelaichao', 'kirov:1521/kirov');
|
||||
$conn = $n->getConn();
|
||||
|
||||
$textbox = $_GET['textbox'];
|
||||
$UserQuery = oci_parse($conn, $textbox);
|
||||
$reponseUser = oci_execute($UserQuery);
|
||||
echo 'Table créee';
|
@ -0,0 +1,56 @@
|
||||
|
||||
|
||||
<link rel="stylesheet" href="css/VueAdmin.css">
|
||||
|
||||
<form style="border:1px solid #ccc" method="GET" action="AjoutQuestion.php">
|
||||
<div class="container">
|
||||
<?php require_once('../BDD/SqliteDb.php');
|
||||
require_once('../BDD/OracleDb.php');
|
||||
$db = new SqliteDb();
|
||||
$stmt = $db->prepare('SELECT question,reponse FROM Correct WHERE numQuestion= ? AND numTp = ?');
|
||||
$stmt->bindParam(1, $_GET['numQuestion']);
|
||||
$stmt->bindParam(2, $_GET['numTp']);
|
||||
$resultQuestion = $stmt->execute();
|
||||
$questionRow = $resultQuestion->fetchArray();
|
||||
|
||||
|
||||
echo 'AAAAAAAAAAAAAAAA'.$_GET['numTp'].$questionRow['reponse'];
|
||||
|
||||
?>
|
||||
<h1>Ajouter une question</h1>
|
||||
<hr>
|
||||
|
||||
<label><b>TP n° : </b></label>
|
||||
<input type="text" placeholder="Numéro du TP" name="tp" value="<?php echo $_GET['numTp']; ?>" required>
|
||||
|
||||
<label><b>Numéro de question : </b></label>
|
||||
<input type="text" placeholder="Saisir le numéro de question..." name="num" value="<?php echo $_GET['numQuestion']; ?>" required>
|
||||
|
||||
<label><b>Barème : </b></label>
|
||||
<input type="text" placeholder="Barème..." name="points" required>
|
||||
|
||||
<label><b>Consigne : </b></label>
|
||||
<input type="text" placeholder="Ecrire la consigne..." name="consigne" value="<?php echo $questionRow['question']; ?>" required>
|
||||
|
||||
<label><b>Réponse : </b></label>
|
||||
<input type="text" placeholder="SELECT ..." name="reponse" value="<?php echo $questionRow['reponse']; ?>" required>
|
||||
|
||||
|
||||
<label> <b>Choisir le type de la question : </b><br/>
|
||||
<input type="radio" name="type" value="requete" style="margin-bottom:15px" checked> requête simple
|
||||
<input type="radio" name="type" value="fonction" style="margin-bottom:15px"> fonction
|
||||
</label><br/>
|
||||
<label><b>Verification avec BDD aléatoire? </b><br/>
|
||||
<input type="radio" name="aleatoire" value="o" style="margin-bottom:15px"> oui
|
||||
<input type="radio" name="aleatoire" value="n" style="margin-bottom:15px" checked> non
|
||||
</label><br/>
|
||||
<label><b>Base de données conçernée </b><br/>
|
||||
<input type="radio" name="bdd" value="o" style="margin-bottom:15px" checked> NBA
|
||||
</label>
|
||||
<input type="hidden" name="modif" value="modif" >
|
||||
<div class="clearfix">
|
||||
<button type="submit" class="btnvalider"> Valider</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
require_once('../BDD/SqliteDb.php');
|
||||
$db = new SqliteDb('o');
|
||||
|
||||
|
||||
$numQuestion = $_GET['numQuestion'];
|
||||
$numTp = $_GET['numTp'];
|
||||
$numQuestionPrec = $numQuestion-1;
|
||||
$test = 999;
|
||||
|
||||
$Correct = 'Correct';
|
||||
$function = 'functionCorrect';
|
||||
if($numQuestion!=1){
|
||||
|
||||
$typeQuery = $db->prepare('SELECT type FROM Type WHERE numQuestion = ? AND numTp= ?');
|
||||
$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, $numQuestionPrec);
|
||||
$typeQuery->bindParam(2, $numTp);
|
||||
$resultType = $typeQuery->execute();
|
||||
$type2Row = $resultType->fetchArray();
|
||||
|
||||
|
||||
|
||||
|
||||
if($typeRow['type'] == 'query'){
|
||||
$table = 'Correct';
|
||||
}
|
||||
else $table = 'FunctionCorrect';
|
||||
|
||||
|
||||
$sqliteQuery = $db->prepare('UPDATE '.$table.' SET numQuestion=? WHERE numQuestion=? AND numTp=?');
|
||||
|
||||
|
||||
$sqliteQuery->bindParam(1, $test);
|
||||
$sqliteQuery->bindParam(2, $numQuestion);
|
||||
$sqliteQuery->bindParam(3, $numTp);
|
||||
$result = $sqliteQuery->execute();
|
||||
|
||||
if($type2Row['type'] == 'query'){
|
||||
$table2 = 'Correct';
|
||||
}
|
||||
else $table2 = 'FunctionCorrect';
|
||||
|
||||
$sqliteQuery = $db->prepare('UPDATE '.$table2.' 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 '.$table.' SET numQuestion=? WHERE numQuestion=? AND numTp=?');
|
||||
|
||||
$sqliteQuery->bindParam(1, $numQuestionPrec);
|
||||
$sqliteQuery->bindParam(2, $test);
|
||||
$sqliteQuery->bindParam(3, $numTp);
|
||||
$resultp = $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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
//header("Location: index.php");
|
||||
|
||||
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
|
||||
require_once('../BDD/SqliteDb.php');
|
||||
$db = new SqliteDb();
|
||||
|
||||
|
||||
$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();
|
||||
|
||||
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();
|
||||
}
|
||||
else {
|
||||
$sqliteQueryF = $db->prepare('DELETE FROM FunctionCorrect WHERE numquestion= ? AND numTp=?');
|
||||
$sqliteQueryF->bindParam(1, $_GET['numQuestion']);
|
||||
$sqliteQueryF->bindParam(2, $_GET['numTp']);
|
||||
$result = $sqliteQueryF->execute();
|
||||
}
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
Résultat : 1/5
|
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../css/VueAdmin.css">
|
||||
|
||||
<form style="border:1px solid #ccc" method="GET" action="../Traitement/AjoutDemonstration.php">
|
||||
<div class="container">
|
||||
|
||||
|
||||
<h1>Ajouter une démonstration</h1>
|
||||
<hr>
|
||||
|
||||
<label><b>Chapitre : </b></label>
|
||||
<input type="text" placeholder="Numéro du chapitre" name="tp" required>
|
||||
|
||||
<label><b>Numéro de démonstration : </b></label>
|
||||
<input type="text" placeholder="Saisir le numéro de démonstration..." name="num" required>
|
||||
|
||||
<label><b>Intitulé : </b></label>
|
||||
<input type="text" placeholder="Ecrire l'intitulé..." name="consigne" required>
|
||||
|
||||
<label><b>Réponse : </b></label>
|
||||
<input type="text" placeholder="SELECT ..." name="reponse" required>
|
||||
|
||||
<label><b>Base de données conçernée </b><br/>
|
||||
<input type="radio" name="bdd" value="o" style="margin-bottom:15px" checked> NBA
|
||||
</label>
|
||||
|
||||
<div class="clearfix">
|
||||
<button type="submit" class="btnvalider"> Valider</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
Loading…
Reference in new issue