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) ); 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"> -
+- Écrire une fonction estPalindrome qui prend en argument un entier et qui renvoie True si c’est un palindrome et False sinon. -
Un palindrome est un nombre qui peut se lire dans les deux sens. Par exemple 111.
Entrée : Sortie :
-[1,0,1] True
-[1,1,9,1] False
En python l’instruction [::-1] permet d’inverse une chaine de caractère. Par exemple print("ae"[::-1]) affiche : ea.
+Écrire une fonction estPalindrome qui prend en argument un entier et qui renvoie True si c’est un palindrome et False sinon.
Un palindrome est un nombre qui peut se lire dans les deux sens. Par exemple 111.
Entrée : Sortie :
+[1,0,1] True
+[1,1,9,1] False
En python l’instruction [::-1] permet d’inverse une chaine de caractère. Par exemple print("ae"[::-1]) affiche : ea.
+