From c06c60efa7e0b7cf09d37f79afe19ad4c5cbc00a Mon Sep 17 00:00:00 2001 From: Johan LACHENAL Date: Tue, 22 Nov 2022 15:12:57 +0100 Subject: [PATCH 1/2] Partie gw + partie factory --- WEB/Controller/PartieGateway.php | 42 ++++++++++++++++++++++++++++---- WEB/Factory/PartieFactory.php | 20 +++++++++++---- WEB/Model/Partie.php | 17 +++++++++++-- WEB/Model/bd.sql | 8 +++--- 4 files changed, 72 insertions(+), 15 deletions(-) diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php index afb471df..d51fe7f0 100644 --- a/WEB/Controller/PartieGateway.php +++ b/WEB/Controller/PartieGateway.php @@ -1,6 +1,6 @@ con = $con; } - public function insert(Partie $partie){ - - $query= "INSERT INTO Game VALUES (:idPartie)"; + public function creerPartie(){ + $query = "SELECT * FROM Enigme"; + $this->con->executeQuery($query); + $results = $this->con->getResults(); + $query= "SELECT max(p.id) + FROM PARTIE p;"; + $this->con->executeQuery($query); + $max=$this->con->getResults()[0]; + $partie=PartieFactory::createPartie($max,$results); + $query= "INSERT INTO Partie VALUES (:idPartie,:idEnigme)"; $this->con->executeQuery($query, array(':idPartie' => array($partie->getIdPartie(), PDO::PARAM_STR))); + foreach($partie->getListeEnigme() as $Enigme){ + $query= "INSERT INTO Contenir VALUES (:idPartie, :idEnigme)"; + $this->con->executeQuery($query, array( + ':idPartie' => array($partie->getIdPartie(), PDO::PARAM_STR), + ':idEnigme' => array($Enigme->getIdEnigme(), PDO::PARAM_STR))); + } } public function delete(string $idPartie){ - $query= "DELETE FROM Game WHERE idGame = :idPartie"; + $query= "DELETE FROM Partie WHERE id = :idPartie"; $this->con->executeQuery($query, array(':idPartie' => array($idPartie, PDO::PARAM_STR))); } + + public function findOldListeEnigme(string $partie) : array{ + $query= "SELECT * FROM Enigme e,Contenir c + AND c.partie = :idPartie + AND c.enigme = e.id"; + $this->con->executeQuery($query, array(':idPartie' => array( + ':idPartie' => array($partie, PDO::PARAM_STR), + ))); + $results=$this->con->getResults(); + $tabEnigme=EnigmeFactory::create($results); + return $tabEnigme; + } + public function findIdMax(){ + $query= "SELECT max(p.id) + FROM PARTIE p;"; + $this->con->executeQuery($query); + $results=$this->con->getResults(); + return $results[0]->max; + } public function showAll() : void{ $query= "SELECT * FROM Partie"; $this->con->executeQuery($query); diff --git a/WEB/Factory/PartieFactory.php b/WEB/Factory/PartieFactory.php index 0a43d733..64f7774b 100644 --- a/WEB/Factory/PartieFactory.php +++ b/WEB/Factory/PartieFactory.php @@ -1,12 +1,22 @@ idPartie = $idPartie; $this->datePartie = getdate(); - $listeEnigme = []; + $this->$listeEnigme = $listeEnigme; } /** @@ -50,4 +50,17 @@ class Partie { $this->datePartie = $datePartie; } + + /** + * @param array $listeEnigme + */ + + public function getListeEnigme(): array + { + return $this->listeEnigme; + } + public function setListeEnigme(array $listeEnigme): void + { + $this->listeEnigme = $listeEnigme; + } } \ No newline at end of file diff --git a/WEB/Model/bd.sql b/WEB/Model/bd.sql index 667225ff..1e4f8eca 100644 --- a/WEB/Model/bd.sql +++ b/WEB/Model/bd.sql @@ -26,18 +26,19 @@ mdp varchar(50) ); CREATE TABLE Enigme( -id char(5) PRIMARY KEY, +id int PRIMARY KEY AUTO_INCREMENT, admin varchar(50) REFERENCES Admin(email), enonce varchar(250) NOT NULL, aide varchar(250), rappel varchar(250), solution varchar(250) NOT NULL, test varchar(250) NOT NULL, -tempsDeResolution numeric CHECK (tempsDeResolution >0) +tempsDeResolution numeric CHECK (tempsDeResolution >0), +points numeric ); CREATE TABLE Partie( -id char(5) PRIMARY KEY +id int PRIMARY KEY AUTO_INCREMENT, ); CREATE TABLE ResoudreEnSolo( @@ -52,6 +53,7 @@ joueur varchar(50) REFERENCES Joueur(email), enigme char(5) REFERENCES Enigme(id), partie char(5) REFERENCES Partie(id), indexEnigme numeric UNIQUE, +temps time, PRIMARY KEY(joueur, enigme, partie) ); From 235c0637ac4b87665616dc4874d1958e7234c678 Mon Sep 17 00:00:00 2001 From: Pierre BALLANDRAS Date: Tue, 22 Nov 2022 15:16:45 +0100 Subject: [PATCH 2/2] Page enigme --- WEB/View/src/CSS/Enigmev2.css | 1 - .../src/pages/Enigme/Enigmebootstrap.html | 62 +++++++++++-------- package-lock.json | 13 +++- package.json | 3 +- 4 files changed, 50 insertions(+), 29 deletions(-) diff --git a/WEB/View/src/CSS/Enigmev2.css b/WEB/View/src/CSS/Enigmev2.css index 83e4f2d3..14b2a092 100644 --- a/WEB/View/src/CSS/Enigmev2.css +++ b/WEB/View/src/CSS/Enigmev2.css @@ -5,7 +5,6 @@ /*Default CSS*/ - /*Ace CSS */ .ace{ diff --git a/WEB/View/src/pages/Enigme/Enigmebootstrap.html b/WEB/View/src/pages/Enigme/Enigmebootstrap.html index e8558723..2728cdeb 100644 --- a/WEB/View/src/pages/Enigme/Enigmebootstrap.html +++ b/WEB/View/src/pages/Enigme/Enigmebootstrap.html @@ -22,43 +22,53 @@ integrity="sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/" crossorigin="anonymous"> - +
-
-
- home +
+
+ +
+

+ Palindrome +


+
-
-

- p - alin - d - rome -

-

-

Consigne


-

- Écrire une fonction estPalindrome qui prend en argument un entier et qui renvoie True si c’est un palindrome et False sinon. -



-

Rappel


-

Un palindrome est un nombre qui peut se lire dans les deux sens. Par exemple 111.



-

Exemple


-

Entrée :      Sortie :

-

[1,0,1]        True

-

[1,1,9,1]       False



-

Aide


-

En python l’instruction [::-1] permet d’inverse une chaine de caractère. Par exemple print("ae"[::-1]) affiche : ea.

+
+

Consigne


+

Écrire une fonction estPalindrome qui prend en argument un entier et qui renvoie True si c’est un palindrome et False sinon.



+
+
+

Rappel


+

Un palindrome est un nombre qui peut se lire dans les deux sens. Par exemple 111.



+
+
+

Exemple


+

Entrée :      Sortie :

+

[1,0,1]        True

+

[1,1,9,1]       False



+
+
+

Aide


+

En python l’instruction [::-1] permet d’inverse une chaine de caractère. Par exemple print("ae"[::-1]) affiche : ea.

+
-
+
def estPalindrome(var): return var == var[::-1] print(estPalindrome("abba"))
-
+
diff --git a/package-lock.json b/package-lock.json index 46bc4e52..4603894c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,8 @@ "packages": { "": { "dependencies": { - "bootstrap": "^5.2.2" + "bootstrap": "^5.2.2", + "bootstrap-icons": "^1.10.2" } }, "node_modules/@popperjs/core": { @@ -35,6 +36,11 @@ "peerDependencies": { "@popperjs/core": "^2.11.6" } + }, + "node_modules/bootstrap-icons": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.10.2.tgz", + "integrity": "sha512-PTPYadRn1AMGr+QTSxe4ZCc+Wzv9DGZxbi3lNse/dajqV31n2/wl/7NX78ZpkvFgRNmH4ogdIQPQmxAfhEV6nA==" } }, "dependencies": { @@ -49,6 +55,11 @@ "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.2.tgz", "integrity": "sha512-dEtzMTV71n6Fhmbg4fYJzQsw1N29hJKO1js5ackCgIpDcGid2ETMGC6zwSYw09v05Y+oRdQ9loC54zB1La3hHQ==", "requires": {} + }, + "bootstrap-icons": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.10.2.tgz", + "integrity": "sha512-PTPYadRn1AMGr+QTSxe4ZCc+Wzv9DGZxbi3lNse/dajqV31n2/wl/7NX78ZpkvFgRNmH4ogdIQPQmxAfhEV6nA==" } } } diff --git a/package.json b/package.json index bfafe910..0091e3c1 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "dependencies": { - "bootstrap": "^5.2.2" + "bootstrap": "^5.2.2", + "bootstrap-icons": "^1.10.2" } }