Merge branch 'master' of https://codefirst.iut.uca.fr/git/jade.van_brabandt/3.01-QCM_MuscuMaths
continuous-integration/drone/push Build is passing Details

pull/37/head
Jade VAN BRABANDT 1 year ago
commit 022bc0d2b8

@ -139,6 +139,7 @@ class ControllerUser
$_SESSION["Score"] = 0;
$difficulty = $_POST['difficulty'];
$chapter = $_POST['chapter'];
$_SESSION['id_chapter'] = $_POST['chapter'];
$difficultyIsOk = TRUE;
$chapterIsOk = TRUE;
@ -228,9 +229,13 @@ class ControllerUser
$Final[$c]["PlayerAnswer"] = $answer;
$c = $c + 1;
}
// $idPlayer = $_SESSION["idPlayerConnected"];
// $idChapter = $_SESSION["chapter"];
// $numScore = $this->mdPlayer->getJouerByPlayerAndChapter( $idPlayer, $idChapter);
echo $this->twig->render($this->vues["viewScore"], [
'score' => $_SESSION["Score"],
'Final' => $Final,
// 'numScore' => $numScore,
]);
}
}

@ -0,0 +1,71 @@
<?php
namespace gateways;
use usages\Connection;
use \PDO;
class GatewayJouer
{
private $con;
public function __construct()
{
global $dns, $user, $pass;
$this->con = new Connection($dns, $user, $pass);
}
public function addJouer($jouer)
{
$query = "INSERT into jouer(idChapter,idPlayer,numScore) values (:idChapter,:idPlayer,:numScore);";
$this->con->executeQuery(
$query,
array(
'idChapter' => array($jouer['idChapter'], PDO::PARAM_STR),
'idPlayer' => array($jouer['idPlayer'], PDO::PARAM_STR),
':numScore' => array($jouer['numScore'], PDO::PARAM_INT)
)
);
}
public function getJouerByPlayerAndChapter(int $idPlayer, int $idChapter)
{
$query = "SELECT jouer.numScore FROM jouer,player WHERE jouer.idPlayer = :idPlayer AND jouer.idPlayer = player.id AND jouer.idChapter = :idChapter AND jouer.idChapter = chapter.id ;";
$this->con->executeQuery(
$query,
array(
':idChapter' => array($idChapter, PDO::PARAM_INT),
':idPlayer' => array($idPlayer, PDO::PARAM_INT)
)
);
$results = $this->con->getResults();
return $results[0];
}
public function updateJouer($idPlayer, $idChapter, $jouer)
{
$query = "UPDATE jouer SET numScore = :numScore WHERE idPlayer = :idPlayer AND idChapter = :idChapter;";
$this->con->executeQuery(
$query,
array(
':idChapter' => array($idChapter, PDO::PARAM_INT),
':idPlayer' => array($idPlayer, PDO::PARAM_INT),
':numScore' => array($jouer['numScore'], PDO::PARAM_INT)
)
);
}
public function verifyJouer($idChapter, $idPlayer)
{
$query = "SELECT jouer.idChapter, jouer.idPlayer FROM jouer WHERE idPlayer = :idPlayer AND idChapter = :idChapter";
$this->con->executeQuery(
$query,
array(
':idChapter' => array($idChapter, PDO::PARAM_STR),
':idPlayer' => array($idPlayer, PDO::PARAM_STR)
)
);
$results = $this->con->getResults();
return $results[0];
}
}

@ -3,15 +3,18 @@
namespace models;
use gateways\GatewayPlayer;
use gateways\GatewayJouer;
use classes\Player;
class ModelPlayer
{
private $gwPlayer;
private $gwJouer;
public function __construct()
{
$this->gwPlayer = new GatewayPlayer();
$this->gwJouer = new GatewayJouer();
}
public function addPlayer($player)
@ -40,4 +43,20 @@ class ModelPlayer
{
$this->gwPlayer->deletePlayerByID($id);
}
public function addJouer($jouer)
{
$this->gwJouer->addJouer($jouer);
}
public function getJouerByPlayerAndChapter( $idPlayer, $idChapter)
{
$jouerDataArray = $this->gwJouer->getJouerByPlayerAndChapter($idPlayer,$idChapter);
return $jouerDataArray;
}
public function updateJouer($idPlayer, $idChapter, $jouer)
{
$this->gwJouer->updateJouer($idPlayer, $idChapter, $jouer);
}
}

@ -1,6 +1,5 @@
<!DOCTYPE html>
<html lang="fr">
<html>
<head>
<meta charset=utf-8>

Loading…
Cancel
Save