Merge branch 'master' of https://codefirst.iut.uca.fr/git/nathan.boileau/Scripted
continuous-integration/drone/push Build is passing Details

ServeurDeTest
Noé GARNIER 2 years ago
commit 0adbae8e90

@ -1,6 +1,6 @@
<?php
include_once "EnigmeGateway";
include_once "../Factory/PartieFactory.php";
class PartieGateway
{
private Connection $con;
@ -12,15 +12,47 @@ class PartieGateway
{
$this->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);

@ -1,12 +1,22 @@
<?php
include_once "EnigmeFactory.php";
include_once "../Model/Partie.php";
class PartieFactory{
public static function create($results)
public static function createPartie($idMax,$resultsEnigme) : Partie
{
$tabPartie=array();
foreach($results as $row)
$tempsResolutionPartie=0;
$tabEnigme=array();
$tabIndex=range(0,strlen($resultsEnigme)-1);
$randomNumber=0;
while($tempsResolutionPartie <= 30)
{
$tabPartie= new Partie($row['id']);
$randomNumber=$tabIndex[array_rand($tabIndex)];
$tabEnigme=EnigmeFactory::create($resultsEnigme[$randomNumber]);
$TempsResolutionPartie+=$resultsEnigme[$randomNumber]['tempsDeResolution'];
unset($tabIndex[$randomNumber]);
}
return $tabPartie;
$partie=new Partie($idMax,$resultsEnigme);
return $partie;
}
//public static function createListePartie()
}

@ -12,11 +12,11 @@ class Partie
* @param string $idPartie
* @param array $datePartie
*/
public function __construct(string $idPartie)
public function __construct(string $idPartie, array $listeEnigme)
{
$this->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;
}
}

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

@ -5,7 +5,6 @@
/*Default CSS*/
/*Ace CSS */
.ace{

@ -22,43 +22,53 @@
integrity="sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
crossorigin="anonymous"></script>
</head>
<body style="background-color: black;background-image: none;">
<body style="background-color: #050e15;background-image: none;">
<div class="container-fluid">
<div class="row">
<div class="col-3">
<div class="retour">
<a class="material-icons" id="home" href="../Home.html" style="font-size:36px;color:white;">home</a>
<div class="col-3" style="height: auto; min-height: 100vh;">
<div class="row">
<div class="col-2 text-center pt-3">
<a id="home" href="../Home.html" >
<svg xmlns="http://www.w3.org/2000/svg" style="color: white;" width="32" height="32" fill="currentColor" class="bi bi-house-fill" viewBox="0 0 16 16">
<path d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L8 2.207l6.646 6.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.707 1.5Z"/>
<path d="m8 3.293 6 6V13.5a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 2 13.5V9.293l6-6Z"/>
</svg>
</a>
</div>
<div class="col-10 pt-1">
<h1 class="display-5" style="letter-spacing: 0.1rem;""> <!--Mettre responsive si moins de 1500px-->
Palindrome
</h1><br>
</div>
</div>
<div class="sign">
<h1>
<span class="fast-flicker">p</span>
<span>alin</span>
<span class="flicker">d</span>
<span>rome</span>
</h1>
</div><br>
<div>
<section class="row mt-3 ">
<h2>Consigne</h2><br>
<p class="enonce">
Écrire une fonction estPalindrome qui prend en argument un entier et qui renvoie True si cest un palindrome et False sinon.
</p><br><br>
<p class="enonce">Écrire une fonction estPalindrome qui prend en argument un entier et qui renvoie True si cest un palindrome et False sinon.</p><br><br>
</section>
<section class="row mt-3">
<h2>Rappel</h2><br>
<p class="rappel">Un palindrome est un nombre qui peut se lire dans les deux sens. Par exemple 111.</p><br><br>
</section>
<section class="row mt-3">
<h2>Exemple</h2><br>
<p>Entrée :&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;Sortie :</p>
<p>[1,0,1]&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&ensp;True</p>
<p>[1,1,9,1]&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;False</p><br><br>
</section>
<section class="row mt-3">
<h2>Aide</h2><br>
<p>En python linstruction [::-1] permet dinverse une chaine de caractère. Par exemple print("ae"[::-1]) affiche : ea.</p>
</section>
</div>
</div>
<div class="col-5">
<div class="col-5 h-auto py-3">
<div class='ace' id='editor'>def estPalindrome(var):
return var == var[::-1]
print(estPalindrome("abba"))
</div>
</div>
<div class="col-4">
<div class="col-4 py-3">
<div class='compiler_class'>
<textarea id='console' readonly cols="100" rows="30"></textarea>
</div>

13
package-lock.json generated

@ -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=="
}
}
}

@ -1,5 +1,6 @@
{
"dependencies": {
"bootstrap": "^5.2.2"
"bootstrap": "^5.2.2",
"bootstrap-icons": "^1.10.2"
}
}

Loading…
Cancel
Save