From 494d036377e199f9918721c126abd26d17f05351 Mon Sep 17 00:00:00 2001 From: Mehdi Date: Tue, 28 Jul 2020 17:50:32 +0200 Subject: [PATCH] =?UTF-8?q?Vue=20d=C3=A9monstration(et=20correction)=20+?= =?UTF-8?q?=20Vue=20QCM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BddCorrect/AffichageDemo.php | 23 ++++ BddCorrect/Correcteur.php | 57 +++++++++- BddCorrect/DAL/QCMGateway.php | 41 +++++++ BddCorrect/DAL/QuestionsGateway.php | 13 +++ BddCorrect/OracleDb.php | 4 +- BddCorrect/SqliteDb.php | 31 ++++++ BddCorrect/ValidationQCM.php | 16 +++ BddCorrect/config/config.php | 7 +- BddCorrect/controleur/Controleur.php | 57 ++++++++-- BddCorrect/metier/QCM.php | 45 ++++++++ BddCorrect/metier/ReponseQCM.php | 37 ++++++ BddCorrect/modeles/Modele.php | 19 ++++ BddCorrect/nbproject/private/private.xml | 9 +- BddCorrect/resultat.html | 14 ++- BddCorrect/test.db | Bin 24576 -> 40960 bytes BddCorrect/vues/VueAdmin.php | 22 ++-- BddCorrect/vues/VueDemonstration.php | 136 +++++++++++++++++++++++ BddCorrect/vues/VueNbQuestions.php | 5 +- BddCorrect/vues/VuePrincipale.php | 74 +++++++++--- BddCorrect/vues/VueQCM.php | 111 ++++++++++++++++++ 20 files changed, 676 insertions(+), 45 deletions(-) create mode 100644 BddCorrect/AffichageDemo.php create mode 100644 BddCorrect/DAL/QCMGateway.php create mode 100644 BddCorrect/ValidationQCM.php create mode 100644 BddCorrect/metier/QCM.php create mode 100644 BddCorrect/metier/ReponseQCM.php create mode 100644 BddCorrect/vues/VueDemonstration.php create mode 100644 BddCorrect/vues/VueQCM.php diff --git a/BddCorrect/AffichageDemo.php b/BddCorrect/AffichageDemo.php new file mode 100644 index 0000000..a979565 --- /dev/null +++ b/BddCorrect/AffichageDemo.php @@ -0,0 +1,23 @@ + Ligne '.$numLigne.' : '; + for($i=0 ; $i< sizeof($oracleRow) ; $i++){ + echo $oracleRow[$i].' ; '; + } + echo '
'; +} \ No newline at end of file diff --git a/BddCorrect/Correcteur.php b/BddCorrect/Correcteur.php index 5b3b098..624efec 100644 --- a/BddCorrect/Correcteur.php +++ b/BddCorrect/Correcteur.php @@ -8,8 +8,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; @@ -285,10 +285,59 @@ foreach ($_POST['textbox'] as $textbox) { } -$txt = 'Résultat : ' . $cmpt . '/' . $numQuestion; + // 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"; + //$dn="OU=enseignants,OU=UIT,OU=uca,OU=personnels,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 . '
'; + + echo 'Le nombre d\'entrées retournées est ' . ldap_count_entries($ldapconn,$sr) + . '
'; + + echo 'Lecture des entrées ...
'; + + echo 'Données pour ' . $info["count"] . ' entrées:
'; +for ($i=0; $i<$info["count"]; $i++) { + echo 'dn est : ' . $info[$i]["dn"] . '
'; + echo 'premiere entree cn : ' . $info[$i]["cn"][0] . '
'; + echo 'premier date de naissance : ' . $info[$i]["postofficebox"][0] . '
'; + }*/ + $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()); + + +//file_put_contents('resultat.html', ob_get_contents()); + $fic = fopen("result.txt", "w"); fwrite($fic, $txt); fclose($fic); diff --git a/BddCorrect/DAL/QCMGateway.php b/BddCorrect/DAL/QCMGateway.php new file mode 100644 index 0000000..ce62f71 --- /dev/null +++ b/BddCorrect/DAL/QCMGateway.php @@ -0,0 +1,41 @@ +db=$db; + } + + public function afficherQCM() { + $i = 0; + $query = 'SELECT * FROM QcmQuestion'; + $query = $this->db->prepare($query); + $result = $query->execute(); + $tabReponses =array(); + $tabQuestions = array(); + //$resultats = $this->db->query('SELECT found_rows()'); + while($q = $result->fetchArray()){ + $i= $i+1; + $reponseQuery = 'SELECT * FROM QcmReponse WHERE numQuestion=?'; + $stmt = $this->db->prepare($reponseQuery); + $stmt->bindParam(1, $q['numQuestion']); + $reponseResult = $stmt->execute(); + $i=0; + while ($r = $reponseResult->fetchArray()){ + + $i++; + $tabReponses[] = new ReponseQCM($r['numReponse'], $r['reponse'], $r['numQuestion']) ; + + } + //die(print_r($i, true )); + $tabQuestions[] = new QCM($q['numQuestion'],$q['question'],$tabReponses); + } + //die(print_r($tabQuestions, true )); + return $tabQuestions; + } + +} + + diff --git a/BddCorrect/DAL/QuestionsGateway.php b/BddCorrect/DAL/QuestionsGateway.php index ccc1184..06fe7d5 100644 --- a/BddCorrect/DAL/QuestionsGateway.php +++ b/BddCorrect/DAL/QuestionsGateway.php @@ -20,4 +20,17 @@ class QuestionsGateway { } return $tabQuestions; } + + public function afficherDemonstrations() { + $i = 0; + $query = 'SELECT * 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($q['numDemo'],$q['description'],$q['reponse']); + } + return $tabDemo; + } } 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 4ca5675..75dd5c2 100644 --- a/BddCorrect/SqliteDb.php +++ b/BddCorrect/SqliteDb.php @@ -8,6 +8,8 @@ class SqliteDb extends SQLite3 $this->open('test.db'); $this->createLogin(); $this->createTable(); + $this->createDemonstration(); + $this->createQCM(); } function createTable(){ @@ -120,6 +122,35 @@ class SqliteDb extends SQLite3 } + function createDemonstration(){ + $this->exec('DROP TABLE Demonstration'); + $this->exec('CREATE TABLE Demonstration ( numDemo NUMBER, description STRING,reponse STRING)'); + + $this->exec("INSERT INTO Demonstration VALUES(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(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)'); + + $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)"); + + } + function createLogin(){ $mdp = password_hash('mdptest', PASSWORD_DEFAULT); $username = 'test'; diff --git a/BddCorrect/ValidationQCM.php b/BddCorrect/ValidationQCM.php new file mode 100644 index 0000000..f5a6b3b --- /dev/null +++ b/BddCorrect/ValidationQCM.php @@ -0,0 +1,16 @@ +afficherQuestions(); break; - + case 'Afficher les questions': + //require ($rep.$vues['vueLogin']); + $this->afficherQuestions(); + break; case 'login' : //$this->verificationConnexion(); require ($rep.$vues['vueLogin']); @@ -26,18 +29,33 @@ class Controleur { $this->Correction(); break; + case 'Afficher les demonstrations' : + //$this->verificationConnexion(); + + $this->afficherDemonstrations(); + break; + + case 'ok' : + //$this->verificationConnexion(); + + $this->afficherDemonstrations(); + break; + + case 'Afficher les QCM' : + $this->afficherQCM(); + break; + default: - $dVueEreur[] ="Erreur d'appel php"; - require ($rep.$vues['erreur']); + $dVueEreur[] ="Erreur d'appel php"; + require ($rep.$vues['erreur']); break; + } } catch (PDOException $e) { - - $dVueEreur[] = "Erreur inattendue!!! "; - //require ($rep.$vues['erreur']); - + $dVueEreur[] = "Erreur inattendue!!! "; + //require ($rep.$vues['erreur']); } @@ -45,7 +63,7 @@ class Controleur { } function afficherQuestions(){ - global $rep,$vues; + global $rep,$vues,$css; $model = new Modele(); $dVueQuestions = $model->afficherQuestions(); @@ -56,6 +74,29 @@ class Controleur { //session_destroy(); } + function afficherDemonstrations(){ + global $rep,$vues; + + $model = new Modele(); + $dVueDemonstrations = $model->afficherDemonstrations(); + $_SESSION['arrayDemo']=$dVueDemonstrations; + //require ($rep.$vues['vueSupression']); + //require ($rep.$vues['vuePrincipale']); + require ($rep.$vues['vueDemonstration']); + //session_destroy(); + } + + function afficherQCM(){ + global $rep,$vues; + + $model = new Modele(); + $tabQCM = $model->afficherQCM(); + $_SESSION['arrayQCM']=$tabQCM; + + require ($rep.$vues['vueQCM']); + //session_destroy(); + } + function verificationConnexion(){ global $rep,$vues; diff --git a/BddCorrect/metier/QCM.php b/BddCorrect/metier/QCM.php new file mode 100644 index 0000000..04e7a4f --- /dev/null +++ b/BddCorrect/metier/QCM.php @@ -0,0 +1,45 @@ +numQuestion = $numQuestion; + $this->question = $question; + $this->reponse = $reponse; + } + + // Getters + function getNumQuestion() { + return $this->numQuestion; + } + + function getQuestion() { + return $this->question; + } + + function getReponse() { + return $this->reponse; + } + + // Setters + function setNumQuestion($numQuestion) { + $this->numQuestion = $numQuestion; + } + + function setQuestion($question) { + $this->question = $question; + } + + function setReponse($reponse) { + $this->reponse = $reponse; + } + + +} + + + diff --git a/BddCorrect/metier/ReponseQCM.php b/BddCorrect/metier/ReponseQCM.php new file mode 100644 index 0000000..6605b50 --- /dev/null +++ b/BddCorrect/metier/ReponseQCM.php @@ -0,0 +1,37 @@ +numReponse = $numReponse; + $this->reponse = $reponse; + $this->numQuestion = $numQuestion; + } + + function getNumReponse() { + return $this->numReponse; + } + + function getReponse() { + + return $this->reponse; + } + + function getNumQuestion() { + return $this->numQuestion; + } + + public function __toString(){ + $output = ''.$this->getReponse(); + + return $output; + } + + +} + + diff --git a/BddCorrect/modeles/Modele.php b/BddCorrect/modeles/Modele.php index 43ccb26..340ba99 100644 --- a/BddCorrect/modeles/Modele.php +++ b/BddCorrect/modeles/Modele.php @@ -12,6 +12,25 @@ class Modele { return $tabQuestions; } + function afficherDemonstrations(){ + $db = new SqliteDb(); + //$db->createTable(); + $qg = new QuestionsGateway($db); + + $tabDemo = $qg->afficherDemonstrations(); + return $tabDemo; + } + + function afficherQCM(){ + $db = new SqliteDb(); + //$db->createTable(); + $qg = new QCMGateway($db); + + $tabQCM = $qg->afficherQCM(); + //die(print_r($tabQCM, true )); + return $tabQCM; + } + function connection($id, $mdp){ $ug = new UserGateway(new SqliteDb()); $vraiMdp = $ug->getPassword($id); diff --git a/BddCorrect/nbproject/private/private.xml b/BddCorrect/nbproject/private/private.xml index e4f7560..6d10592 100644 --- a/BddCorrect/nbproject/private/private.xml +++ b/BddCorrect/nbproject/private/private.xml @@ -3,13 +3,14 @@ + file:/C:/xampp/htdocs/BddCorrect/vues/VueQCM.php file:/C:/xampp/htdocs/BddCorrect/controleur/Controleur.php - file:/C:/xampp/htdocs/BddCorrect/Suppression.php - file:/C:/xampp/htdocs/BddCorrect/vues/VueSupression.php + file:/C:/xampp/htdocs/BddCorrect/vues/VueNbQuestions.php + file:/C:/xampp/htdocs/BddCorrect/AffichageDemo.php file:/C:/xampp/htdocs/BddCorrect/vues/VuePrincipale.php - file:/C:/xampp/htdocs/BddCorrect/SqliteDb.php + file:/C:/xampp/htdocs/BddCorrect/config/Autoload.php + file:/C:/xampp/htdocs/BddCorrect/vues/VueDemonstration.php file:/C:/xampp/htdocs/BddCorrect/Correcteur.php - file:/C:/xampp/htdocs/BddCorrect/vues/vueLogin.php diff --git a/BddCorrect/resultat.html b/BddCorrect/resultat.html index 47c425a..7aa96fb 100644 --- a/BddCorrect/resultat.html +++ b/BddCorrect/resultat.html @@ -1,8 +1,20 @@ La réponse à la question 1 est JUSTE ! +
+Warning: oci_execute(): ORA-00900: invalid SQL statement in C:\xampp\htdocs\BddCorrect\Correcteur.php on line 35
+
+Warning: oci_fetch_array(): ORA-24374: define not done before fetch or execute and fetch in C:\xampp\htdocs\BddCorrect\Correcteur.php on line 62
+
+Warning: oci_execute(): ORA-00900: invalid SQL statement in C:\xampp\htdocs\BddCorrect\Correcteur.php on line 110
+
+Warning: oci_fetch_array(): ORA-24374: define not done before fetch or execute and fetch in C:\xampp\htdocs\BddCorrect\Correcteur.php on line 119
La réponse à la question 2 est FAUSSE !
+Warning: oci_execute(): ORA-00900: invalid SQL statement in C:\xampp\htdocs\BddCorrect\Correcteur.php on line 35
+
Warning: oci_fetch_array(): ORA-24374: define not done before fetch or execute and fetch in C:\xampp\htdocs\BddCorrect\Correcteur.php on line 62

+Warning: oci_execute(): ORA-00900: invalid SQL statement in C:\xampp\htdocs\BddCorrect\Correcteur.php on line 110
+
Warning: oci_fetch_array(): ORA-24374: define not done before fetch or execute and fetch in C:\xampp\htdocs\BddCorrect\Correcteur.php on line 119
La réponse à la question 3 est FAUSSE !
@@ -12,7 +24,7 @@ La réponse à la question 3 est FAUSSE ! La réponse à la question 4 est FAUSSE !
Warning: oci_execute(): ORA-00900: invalid SQL statement in C:\xampp\htdocs\BddCorrect\Correcteur.php on line 35
-qdsdqdsqdqsreponse : 7question : 23
+qdsdqdsqdqsreponse : 1question : 5
Warning: oci_execute(): ORA-00900: invalid SQL statement in C:\xampp\htdocs\BddCorrect\Correcteur.php on line 244
La réponse à la question 5 est FAUSSE ! Résultat : 1/5 \ No newline at end of file diff --git a/BddCorrect/test.db b/BddCorrect/test.db index 53146bc723c17a60a255deab1b93b54a14b838e8..5379e7f3dc317ba1740223549447c597dfca623e 100644 GIT binary patch delta 1340 zcmb_c%}*0S6yMpFmhJ9#Kn{%tb?~bcTA{@+`~=D(BBiozCB%a%%YdufZrQei2UAyx z@u=xRBWDw1;(_hSc#y=CiGKknIe7Ns2@`d;yQ{XCcyY3ueecctz2E%a%g+PM!z?3 z@F37xht$a+q}`6)+Dz+A*y5^daDOFq+vu~p)myJMigQF>Nz0nL8ys&#xrQmLpc(qr zsd-$KG`Udko~@)&SV*UhUT^g-f1fsbs=%M1jic2o{!6qGsjm6gX(L>lf_K}JnUx#a zaY-AWkp@o|7Q~CA%IxiVoJ=hC9iJQ%HFbG;R-ElG=hBzwk|%DBDbmbfU&=foZZ1s0 zNB(PkfeUk;9LG`YR}QS}pP1TqXd9gJwR!*m3}jhW^?5DZ=kuw4j|X&gFwj$|57pn| z0We_tMXX>+t%bvzF83D2Z`In{KJcBZJ%9!GR}TSp6_K~o^rCvl-Uq7QUj26N_1@tt zVkCMh7)HSvSy5z+;@Pr-??h51Eaz+Q&hG>NNcno<#r^~AQW)Opj%H zOtbp-y1<#rX~_&W0IV$2EkN&`riB%pD<~MvW2E7w^7~gMj0$R5Lv>l^M&+@F z6kJ3xRM2ove*aPCmh^J8x8WWQVD}-jo1yMj`Pslwv zJFo&;7(G%+{XgP~WJbt{jm%c8iQ4P}fS)Py)OHPR!q9HuVg}<_k`cMlrV`RO>uN{M zTo;rm_z^yX66sk6Rt8*dATzE%0nX_iuv_uFK=(qnTrA>HjCO-XhW;BUwi9$!%gO`; h+>FdLL%Pi$Omrv4CbHCRQ*gW1KJ*28DK}9E=%4;^`Po{p($+P)3GWBz8_T#S=@Gr^>_6#fb^D{RsHPy>0*N^aZ%}n>t zDlyI~2=gvWb~N;L4oJ*4$t#FVH7rdvH22Q-3^W2cn1x4&fxm+&I=7fv-ZJpM1$zG^uSSa&BR6AHiwcM|Y?PL5k!q1>5d(_}K*ZQ(oAVo4 zC%?B{EAHzUq-$uQuA`vto0wOs;GUV6pOl%Cxp}9Z93xK2FZN62mDmeQQ;RA&Ihgsy RQy@%s1d|QKoV+{U6#$HPceMZj diff --git a/BddCorrect/vues/VueAdmin.php b/BddCorrect/vues/VueAdmin.php index eb48c3a..e434545 100644 --- a/BddCorrect/vues/VueAdmin.php +++ b/BddCorrect/vues/VueAdmin.php @@ -4,10 +4,19 @@
-

Ajouter Une Question

+ + +

Ajouter une question


- + + + + + + + + @@ -15,14 +24,9 @@ - - - - - -
+ +


@@ -79,7 +83,12 @@ - + +
+
+
+
+
- +