From 8a1f697aa8e2039815abab7b77b616264ece1ca9 Mon Sep 17 00:00:00 2001 From: johan Date: Tue, 6 Dec 2022 13:58:54 +0100 Subject: [PATCH 1/4] =?UTF-8?q?Premi=C3=A8res=20correction=20de=20la=20cr?= =?UTF-8?q?=C3=A9ation=20de=20partie=20multijoueur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WEB/Controller/UtilisateurGateway.php | 15 ++++++++++----- WEB/Model/scripted.db | Bin 53248 -> 53248 bytes 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/WEB/Controller/UtilisateurGateway.php b/WEB/Controller/UtilisateurGateway.php index 0482fc2b..3f34802a 100644 --- a/WEB/Controller/UtilisateurGateway.php +++ b/WEB/Controller/UtilisateurGateway.php @@ -74,24 +74,29 @@ class UtilisateurGateway ':email' => array($email,SQLITE3_TEXT) )); $results=$this->con->getResults(); - $estAdmin=$results['estAdmin']; + $estAdmin=$results[0]['estAdmin']; return $estAdmin; } public function addToQueue(Utilisateur $utilisateur,Partie $partie){ $query = "INSERT INTO Participer VALUES (:idUtilisateur,:idPartie,0)"; $this->con->executeQuery($query,array( - 'idUtilisateur' => array($utilisateur->getEmail(),SQLITE3_TEXT), - 'idPartie' => array($partie->getIdPartie(), SQLITE3_INTEGER) + ':idUtilisateur' => array($utilisateur->getEmail(),SQLITE3_TEXT), + ':idPartie' => array($partie->getIdPartie(), SQLITE3_INTEGER) )); } - public function isAlreadyInqueue(Utilisateur $utilisateur){ + public function isAlreadyInqueue(Utilisateur $utilisateur) : bool{ $query="SELECT utilisateur FROM Participer WHERE utilisateur=:utilisateur"; $this->con->executeQuery($query, array( - 'utilisateur' => array($utilisateur->getEmail()) + ':utilisateur' => array($utilisateur->getEmail(),SQLITE3_TEXT) ) ); + $results=$this->con->getResults(); + if ($results != array()) + return false; + else + return true; } public function queueFilled(){ diff --git a/WEB/Model/scripted.db b/WEB/Model/scripted.db index 7a3e031eee019591e01a84939d79ddafbfc0b726..8bad5f78a7b2a51b6852954d8ecd863b5ee63eaa 100644 GIT binary patch delta 287 zcmZozz}&Ead4e>f{zMsPM*WQmOZeFs`PVY=uiY#tu$VtKkdaMYu#uG`D?cMK&mlK4 zGey`<2)$f+{h*~g!Yfq{XM|2+f$d!Q9h`Go|S)j3g&=iSVxz$^fC##aXZuRt}g z`9(PynI$;`5{pVQQ+dJKKQi!t1WG;U=jUZ)W>7RTFf!6LG}1LNTO?qxNI_te0t?81 oHw^r5fT|wx%Ly^EsPm)x!Vuz+w+#GmfodM}3kw02pt{5m09z4H;Q#;t delta 42 scmZozz}&Ead4e>f&O{k!MxBibOZYdlB>d4|)F1#x3Y!{O3_v3C06!@YfB*mh From f76b96ecb99fff8a17d0d5c03f990ce87c25fac2 Mon Sep 17 00:00:00 2001 From: Pierre BALLANDRAS Date: Tue, 6 Dec 2022 14:29:39 +0100 Subject: [PATCH 2/4] 2 enigme + correction d'un bug python --- WEB/View/src/JS/Affiche.js | 12 ----------- WEB/View/src/JS/FirstFunction.js | 29 +++++++++++++++++++++++++ WEB/View/src/JS/Hanoi.js | 1 + WEB/View/src/JS/If.js | 0 WEB/View/src/JS/String.js | 35 +++++++++++++++++++++++++++++++ WEB/View/src/JS/TrianglePascal.js | 1 + WEB/View/src/JS/Variable.js | 10 --------- WEB/View/src/JS/cesarDecrypt.js | 2 ++ WEB/View/src/JS/cesarEncrypt.js | 2 ++ WEB/View/src/JS/chouette.js | 1 + WEB/View/src/JS/chuckNorris.js | 1 + 11 files changed, 72 insertions(+), 22 deletions(-) delete mode 100644 WEB/View/src/JS/Affiche.js create mode 100644 WEB/View/src/JS/FirstFunction.js create mode 100644 WEB/View/src/JS/If.js create mode 100644 WEB/View/src/JS/String.js delete mode 100644 WEB/View/src/JS/Variable.js diff --git a/WEB/View/src/JS/Affiche.js b/WEB/View/src/JS/Affiche.js deleted file mode 100644 index 15a53b9e..00000000 --- a/WEB/View/src/JS/Affiche.js +++ /dev/null @@ -1,12 +0,0 @@ -//~ Function that test the user code - -async function submit(){ - var test = editor.getValue(); - exec("print('Hello World !')", "code"); - exec(test, "solution"); - result.innerHTML = "Test en cours..."; - await new Promise(r => setTimeout(r, 1500)); - check(); - } - - \ No newline at end of file diff --git a/WEB/View/src/JS/FirstFunction.js b/WEB/View/src/JS/FirstFunction.js new file mode 100644 index 00000000..82e1670d --- /dev/null +++ b/WEB/View/src/JS/FirstFunction.js @@ -0,0 +1,29 @@ +//~ Function that test the user code + +async function submit(){ + var test = editor.getValue()+`\n +import random as r + +def multiVerif(a,b): + return a+b + +def multiTest(x): + multi(1,1) + for i in range(x): + a=r.randint(0,100) + b=r.randint(0,100) + if(multi(a,b) != multiVerif(a,b)): + return False + return True + +print(multiTest(5)) + + `; + exec("print('True')", "code"); + exec(test, "solution"); + result.innerHTML = "Test en cours..."; + await new Promise(r => setTimeout(r, 1500)); + check(); + } + + \ No newline at end of file diff --git a/WEB/View/src/JS/Hanoi.js b/WEB/View/src/JS/Hanoi.js index 845484c5..54452ff3 100644 --- a/WEB/View/src/JS/Hanoi.js +++ b/WEB/View/src/JS/Hanoi.js @@ -17,6 +17,7 @@ def hanoiVerif(nb_disks,start, middle, end): return l def testhanoi(x): + hanoi(1,"A","B","C") if(hanoi(3,"A","B","C")!=[['A','C'],['A','B'],['C','B'],['A','C'],['B','A'],['B','C'],['A','C']]): return False for i in range(x): diff --git a/WEB/View/src/JS/If.js b/WEB/View/src/JS/If.js new file mode 100644 index 00000000..e69de29b diff --git a/WEB/View/src/JS/String.js b/WEB/View/src/JS/String.js new file mode 100644 index 00000000..a5c56857 --- /dev/null +++ b/WEB/View/src/JS/String.js @@ -0,0 +1,35 @@ +//~ Function that test the user code + +async function submit(){ + var test = editor.getValue()+`\n +import random as r + +def triVerif(a,b): + s = "" + i = 0 + while len(s)i): + s += a[i] + if(len(b)>i): + s += b[i] + i += 1 + return s + +def triTest(x): + tri(a,b) + a = "Hlowrd" + b = "el ol" + if(triVerif(a,b)!=tri(a,b)): + return False + return True + +print(triTest(5)) + `; + exec("print('True')", "code"); + exec(test, "solution"); + result.innerHTML = "Test en cours..."; + await new Promise(r => setTimeout(r, 1500)); + check(); + } + + \ No newline at end of file diff --git a/WEB/View/src/JS/TrianglePascal.js b/WEB/View/src/JS/TrianglePascal.js index 73b9a44c..614e749a 100644 --- a/WEB/View/src/JS/TrianglePascal.js +++ b/WEB/View/src/JS/TrianglePascal.js @@ -18,6 +18,7 @@ def estTriangleDePascal(n): return triangle def testTriangleDePascal(n): + TriangleDePascal(0) listTest=[0,1] for i in range(0,n): listTest.append(r.randint(5,140)) diff --git a/WEB/View/src/JS/Variable.js b/WEB/View/src/JS/Variable.js deleted file mode 100644 index 9dd0185c..00000000 --- a/WEB/View/src/JS/Variable.js +++ /dev/null @@ -1,10 +0,0 @@ -async function submit(){ - var test = editor.getValue(); - exec("print([1,'Oui'])", "code"); - exec(test, "solution"); - result.innerHTML = "Test en cours..."; - await new Promise(r => setTimeout(r, 1500)); - check(); - } - - \ No newline at end of file diff --git a/WEB/View/src/JS/cesarDecrypt.js b/WEB/View/src/JS/cesarDecrypt.js index 19526772..61377bfa 100644 --- a/WEB/View/src/JS/cesarDecrypt.js +++ b/WEB/View/src/JS/cesarDecrypt.js @@ -3,6 +3,7 @@ async function submit(){ var test = editor.getValue()+`\n import random as r + def DecryptVerif(text, key): result = "" for i in range(len(text)): @@ -16,6 +17,7 @@ def DecryptVerif(text, key): return result def testDecrypte(x): + Decrypt("",1) if(Decrypt("Jgnnq yqtnf",2)!="Hello world"): return False if(Decrypt("Blarycnm",9)!="Scripted"): diff --git a/WEB/View/src/JS/cesarEncrypt.js b/WEB/View/src/JS/cesarEncrypt.js index d6e15a2a..8f83e954 100644 --- a/WEB/View/src/JS/cesarEncrypt.js +++ b/WEB/View/src/JS/cesarEncrypt.js @@ -3,6 +3,7 @@ async function submit(){ var test = editor.getValue()+`\n import random as r + def EncryptVerif(text, key): result = "" for i in range(len(text)): @@ -16,6 +17,7 @@ def EncryptVerif(text, key): return result def testEncrypte(x): + Encrypt("",1) if(Encrypt("Hello world",2)!="Jgnnq yqtnf"): return False if(Encrypt("Scripted",9)!="Blarycnm"): diff --git a/WEB/View/src/JS/chouette.js b/WEB/View/src/JS/chouette.js index c347ea58..ee951e5b 100644 --- a/WEB/View/src/JS/chouette.js +++ b/WEB/View/src/JS/chouette.js @@ -13,6 +13,7 @@ def chouetteVerif(valeur): return res def test_chouette(n): + chouette(1) listTest=[] for i in range(0,n): listTest.append(r.randint(3,18)) diff --git a/WEB/View/src/JS/chuckNorris.js b/WEB/View/src/JS/chuckNorris.js index 16e24af4..017c682b 100644 --- a/WEB/View/src/JS/chuckNorris.js +++ b/WEB/View/src/JS/chuckNorris.js @@ -30,6 +30,7 @@ def binaire2unitaireVerif(x): def testChuckNorris(x): l="0000000" + binaire2unitaire(l) if(binaire2unitaire(l)!="00 0000000"): return False l="1111111" From 9d06149272b26312b9342edb4e4c4dd7940c6984 Mon Sep 17 00:00:00 2001 From: johan Date: Tue, 6 Dec 2022 15:15:21 +0100 Subject: [PATCH 3/4] =?UTF-8?q?Corrections=20suppl=C3=A9mentaires=20de=20l?= =?UTF-8?q?a=20fil=20d'attente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WEB/Controller/PartieGateway.php | 7 ++++++- WEB/Controller/UtilisateurGateway.php | 12 +++++++++--- WEB/Model/UserModel.php | 23 ++++++++++++++++------- WEB/Model/scripted.db | Bin 53248 -> 53248 bytes 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php index de3204af..0e983213 100644 --- a/WEB/Controller/PartieGateway.php +++ b/WEB/Controller/PartieGateway.php @@ -57,8 +57,13 @@ class PartieGateway return $partie; } + public function rejoindrePartieMulti(int $idPartieInQueue,array $tabEnigme) : Partie{ + $partie = PartieFactory::createPartieMulti($idPartieInQueue,$tabEnigme); + return $partie; + } + public function findPartieInQueue(){ - $query = "SELECT id + $query = "SELECT p.id FROM Partie p, Participer pa WHERE pa.etat=0 AND pa.partie=p.id"; diff --git a/WEB/Controller/UtilisateurGateway.php b/WEB/Controller/UtilisateurGateway.php index 3f34802a..76211171 100644 --- a/WEB/Controller/UtilisateurGateway.php +++ b/WEB/Controller/UtilisateurGateway.php @@ -79,11 +79,11 @@ class UtilisateurGateway } public function addToQueue(Utilisateur $utilisateur,Partie $partie){ - $query = "INSERT INTO Participer VALUES (:idUtilisateur,:idPartie,0)"; + $query = "INSERT INTO Participer VALUES (:idPartie,:idUtilisateur,0)"; $this->con->executeQuery($query,array( ':idUtilisateur' => array($utilisateur->getEmail(),SQLITE3_TEXT), ':idPartie' => array($partie->getIdPartie(), SQLITE3_INTEGER) - )); + )); } public function isAlreadyInqueue(Utilisateur $utilisateur) : bool{ @@ -93,7 +93,7 @@ class UtilisateurGateway ) ); $results=$this->con->getResults(); - if ($results != array()) + if (empty($results)) return false; else return true; @@ -108,6 +108,12 @@ class UtilisateurGateway return False; } + private function launchGame(Utilisateur $utilisateur){ + $query = "UPDATE Participer SET etat=1 WHERE etat=0 AND utilisateur=:utilisateur"; + $this->con->executeQuery($query,array( + 'utilisateur' => array($utilisateur->getEmail(),SQLITE3_TEXT))); + } + /*public function resoudreEnigmeMulti(string $emailUtilisateur) { $query="SELECT c.partie FROM Contenir diff --git a/WEB/Model/UserModel.php b/WEB/Model/UserModel.php index c2ae4b1c..4f4d55d9 100644 --- a/WEB/Model/UserModel.php +++ b/WEB/Model/UserModel.php @@ -64,30 +64,39 @@ class UserModel } public function addToQueue(){ + echo '1'; if($this->utilisateur_gateway->isAlreadyInqueue($_SESSION['utilisateur'])) { + if ($this->utilisateur_gateway->queueFilled()) + { + echo "Partie is launched"; + $this->utilisateur_gateway->launchGame($_SESSION['utilisateur']); + } return; } - echo '1'; + echo '2'; if (!$this->partie_gateway->partieInQueueExists()) { - echo '2'; - $tabEnigme = $this->enigme_gateway->findMultiEnigma(); echo '3'; + $tabEnigme = $this->enigme_gateway->findMultiEnigma(); $idNewPartie = $this->partie_gateway->findPartieMaxId(); - echo '4'; $partie=$this->partie_gateway->creerPartieMulti($idNewPartie,$tabEnigme); } else{ + echo '4'; $idPartieInQueue = $this->partie_gateway->findPartieInQueue(); + echo '5'; $tabEnigme = $this->enigme_gateway->findEnigmaFromPartie($idPartieInQueue); - $partie = $this->partie_gateway->creerPartieMulti($idPartieInQueue, $tabEnigme); + echo '6'; + $partie = $this->partie_gateway->rejoindrePartieMulti($idPartieInQueue, $tabEnigme); + echo '7'; } - echo '6'; + echo '8'; $this->utilisateur_gateway->addToQueue($_SESSION['utilisateur'],$partie); + echo '9'; if ($this->utilisateur_gateway->queueFilled()) { echo "Partie is launched"; - /*$this->launchGame();*/ + $this->utilisateur_gateway->launchGame($_SESSION['utilisateur']); } } public function logout() diff --git a/WEB/Model/scripted.db b/WEB/Model/scripted.db index 8bad5f78a7b2a51b6852954d8ecd863b5ee63eaa..c43c9bfd2247ed178e2823ba43deaee0aeafb040 100644 GIT binary patch delta 259 zcmZozz}&Ead4jZH3IhWJFA&3k;Y1x{#*~c-OZYjM_@f#4*YZbi78LO34+>ynQx$Av z<;cpG6)KvyjDIOXvsYW{`dU%HVZ0T;ujQPR%JxCfNAr4 zeQ^PnFAV%&HVYcO;^*OFWR_$MNGvMJOl8^>z?QI??Z9(>SwTh?PIaKmG7|G(PU8Z4 Wh>`yt1OGdq#wYwjf-FA&3k%tReyM*WQmOZeFs`PVY=uiY%Du$X`HTKRAw|2+f$ z`^|y|Px&{$*B2LH`O3im707+f&&|omEXf&=SX7dkx+#Dyf#nSY{~MspBYsgKMizB` gj;#EQ#5{-G#LOJMv?4>U&5Rq~@Cyq8WjIk~0Ed+-J^%m! From dc3cd2eb62980b70da6a780f6c63954aeb326bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Garnier?= Date: Tue, 6 Dec 2022 15:23:59 +0100 Subject: [PATCH 4/4] page FistTest --- WEB/View/src/JS/FirstFunction.js | 6 +- WEB/View/src/pages/FirstTests/FirstTest1.html | 10 +- WEB/View/src/pages/FirstTests/FirstTest2.html | 12 +- WEB/View/src/pages/FirstTests/FirstTest3.html | 42 ++-- WEB/View/src/pages/FirstTests/FirstTest4.html | 159 ++++++++++++++ WEB/View/src/pages/FirstTests/FirstTest5.html | 149 +++++++++++++ WEB/View/src/pages/FirstTests/FirstTest6.html | 197 ++++++++++++++++++ 7 files changed, 549 insertions(+), 26 deletions(-) create mode 100644 WEB/View/src/pages/FirstTests/FirstTest4.html create mode 100644 WEB/View/src/pages/FirstTests/FirstTest5.html create mode 100644 WEB/View/src/pages/FirstTests/FirstTest6.html diff --git a/WEB/View/src/JS/FirstFunction.js b/WEB/View/src/JS/FirstFunction.js index 82e1670d..0a830ef6 100644 --- a/WEB/View/src/JS/FirstFunction.js +++ b/WEB/View/src/JS/FirstFunction.js @@ -5,14 +5,14 @@ async function submit(){ import random as r def multiVerif(a,b): - return a+b + return a*b def multiTest(x): - multi(1,1) + multiplication(1,1) for i in range(x): a=r.randint(0,100) b=r.randint(0,100) - if(multi(a,b) != multiVerif(a,b)): + if(multiplication(a,b) != multiVerif(a,b)): return False return True diff --git a/WEB/View/src/pages/FirstTests/FirstTest1.html b/WEB/View/src/pages/FirstTests/FirstTest1.html index 8f5e2f9e..1287fa3d 100644 --- a/WEB/View/src/pages/FirstTests/FirstTest1.html +++ b/WEB/View/src/pages/FirstTests/FirstTest1.html @@ -28,12 +28,18 @@ -
+
- Northgan + Test de qualification +
+
+ 1/12