ajout de fonctionnalités dont l'ajout manuel de questions

master
Mehdi 5 years ago
parent 30054c6273
commit d43ca84aa0

@ -0,0 +1,14 @@
<?php
require_once('SqliteDb.php');
require_once('controleur/Controleur.php');
require_once('controleur/Controleur.php');
$db = new SqliteDb();
if ($_POST["type"] == 'requete')
$db->ajouterRequete($_POST['num'],$_POST['consigne'], $_POST['reponse']);
else
//require_once('index.php');
header("Location: index.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;

@ -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()');

@ -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();
}

@ -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();
}
}

@ -5,7 +5,7 @@ class Modele {
function afficherQuestions(){
$db = new SqliteDb();
$db->createTable();
//$db->createTable();
$qg = new QuestionsGateway($db);
$tabQuestions = $qg->afficherQuestions();

@ -3,10 +3,16 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/C:/xampp/htdocs/BddCorrect/vues/VueAdmin.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/metier/Question.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/index.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/controleur/Controleur.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/SqliteDb.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/vues/VuePrincipale.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/OracleDb.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/modeles/Modele.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/DAL/QuestionsGateway.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/AjoutQuestion.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/Correcteur.php</file>
</group>
</open-files>

Binary file not shown.

@ -2,22 +2,29 @@
<link rel="stylesheet" href="../css/VueAdmin.css">
<form style="border:1px solid #ccc" method="POST">
<form style="border:1px solid #ccc" method="POST" action="../AjoutQuestion.php">
<div class="container">
<h1>Ajouter Une Question</h1>
<hr>
<label><b>Num de Question : </b></label>
<input type="text" placeholder="Saisir le numéro de question..." name="num" required>
<label><b>Consigne : </b></label>
<input type="text" placeholder="Ecrire la consigne..." name="consigne" required>
<label><b>Réponse : </b></label>
<input type="text" placeholder="SELECT ..." name="reponse" required>
<label><b>Points : </b></label>
<input type="text" placeholder="Nombre de points..." name="points" required>
<label>
<input type="radio" name="type" style="margin-bottom:15px"> requête
<input type="radio" name="type" style="margin-bottom:15px"> fonction
<input type="radio" name="type" value="requete" style="margin-bottom:15px"> requête
<input type="radio" name="type" value="fonction" style="margin-bottom:15px"> fonction
</label>
<div class="clearfix">
<a href="?action=Valider" class="btnvalider"> Se déconnecter</a>
<button type="submit" class="btnvalider"> Valider</button>
</div>
</div>
</form>

@ -67,7 +67,7 @@
</section>
<form method="post" class="frm">
<input type="submit" name="test" id="test" value="Générer Base de données aléatoire" /><br/>
<input type="submit" name="regenerer" id="test" value="Réintiliser les questions" /><br/>
</form>
<a href="vues/VueAdmin.php"><button>Ajouter Une Question</button></a>
@ -77,12 +77,17 @@
if(array_key_exists('test',$_POST)){
$oraDb = new OracleDb;
}
if(array_key_exists('regenerer',$_POST)){
$db = new SqliteDb();
$db->createTable();
$URL="index.php";
echo '<META HTTP-EQUIV="refresh" content="0;URL=' . $URL . '">';
}
?>
<script type="text/javascript">
var tempsMin =0.5 ;
var tempsMin =50 ;
var total_secondes =60*tempsMin;
tempsMin = parseInt(total_secondes/60);
secondes = parseInt(total_secondes%60);

Loading…
Cancel
Save