feat : page user

pull/37/head
Jade VAN BRABANDT 1 year ago
parent 844f3c06a1
commit d31c2c90f3

@ -50,7 +50,6 @@ class ControllerAdminAdministrators
function add($param) function add($param)
{ {
var_dump($_SERVER['REQUEST_METHOD'] !== 'POST');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') { if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
$_SESSION["error"]="Méthode non autorisée."; $_SESSION["error"]="Méthode non autorisée.";
} else { } else {
@ -58,7 +57,6 @@ class ControllerAdminAdministrators
$password = $_POST['password']; $password = $_POST['password'];
$username = trim($_POST['username']); $username = trim($_POST['username']);
$password = trim($_POST['password']); $password = trim($_POST['password']);
var_dump(!isset($_POST['username']) || !isset($_POST['password']) || empty($username) || empty($password));
if (!isset($username) || !isset($password) || empty($username) || empty($password)) { if (!isset($username) || !isset($password) || empty($username) || empty($password)) {
$_SESSION["error"]="Veuillez remplir tous les champs."; $_SESSION["error"]="Veuillez remplir tous les champs.";
} else { } else {

@ -94,6 +94,25 @@ class ControllerUser
$_SESSION["error"] = ""; $_SESSION["error"] = "";
} }
function userStatus(){
if($_SESSION["idPlayerConnected"] != null){
$this->mdPlayer = new ModelPlayer();
$player = $this->mdPlayer->getPlayerByID($_SESSION["idPlayerConnected"]);
$maxscores = $this->mdPlayer->getMaxScoresWithChapter($player);
foreach ($maxscores as $maxscore) {
$maxscore["chapter"]=$this->mdChapter->getChapterByID($maxscore["idchapter"])->getName();
}
echo $this->twig->render($this->vues["userStatus"],
[
'player' => $player,
'maxscores' => $maxscores,
]);
}
else {
header("Location:/loginPlayer");
}
}
function verifyAdmin() function verifyAdmin()
{ {
$username = $_POST['username']; $username = $_POST['username'];
@ -241,20 +260,6 @@ class ControllerUser
} }
} }
function userStatus(){
if($_SESSION["idPlayerConnected"] != null){
//$this->mdPlayer = new ModelPlayer();
//$player = $this->mdPlayer->getPlayerByID($_SESSION["idAdminConnected"]);
echo $this->twig->render($this->vues["userStatus"]);
}
else {
header("Location:/loginPlayer");
}
}
function passer() function passer()
{ {
$numQuestion = $_POST["numQuestion"]; $numQuestion = $_POST["numQuestion"];

@ -68,4 +68,16 @@ class GatewayJouer
$results = $this->con->getResults(); $results = $this->con->getResults();
return $results[0]; return $results[0];
} }
public function getMaxScoresWithChapter($player)
{
$query = "SELECT maxscore,idchapter FROM jouer WHERE idplayer = :idplayer;";
$this->con->executeQuery(
$query,
array(
':idplayer' => array($player->getId(), PDO::PARAM_STR)
)
);
$results = $this->con->getResults();
return $results;
}
} }

@ -93,7 +93,6 @@ class GatewayPlayer
) )
); );
$results = $this->con->getResults(); $results = $this->con->getResults();
return $results[0][0];
return $results[0];
} }
} }

@ -32,6 +32,7 @@ class ModelPlayer
{ {
$playerDataArray = $this->gwPlayer->getPlayerByID($id); $playerDataArray = $this->gwPlayer->getPlayerByID($id);
$player = new Player($playerDataArray["id"], $playerDataArray["nickname"], $playerDataArray["password"]); $player = new Player($playerDataArray["id"], $playerDataArray["nickname"], $playerDataArray["password"]);
return $player;
} }
public function updatePlayer($id, $player) public function updatePlayer($id, $player)
@ -59,4 +60,10 @@ class ModelPlayer
{ {
$this->gwJouer->updateJouer($idPlayer, $idChapter, $jouer); $this->gwJouer->updateJouer($idPlayer, $idChapter, $jouer);
} }
public function getMaxScoresWithChapter($player)
{
$maxScores = $this->gwJouer->getMaxScoresWithChapter($player);
return $maxScores;
}
} }

@ -5,7 +5,6 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
</script>
<link rel="stylesheet" href="css/global.css"> <link rel="stylesheet" href="css/global.css">
</head> </head>

@ -1,17 +1,24 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<head> <head>
<meta charset=utf-8> <title>Maths Educ</title>
<title>Math'Educ</title> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="stylesheet" href="/css/global.css"> <link rel="stylesheet" href="css/global.css">
</head> </head>
<body id="bodyStyle"> <body id="bodyStyle">
<div class="container mt-5"> <div class="container mt-5">
<div> <div class="col-5 bg-light border border-warning rounded">
<p>test</p> <p> Player Nickname : </p>
<p>{{ player.nickname }} </p>
</div> </div>
{% for maxscore in maxscores %}
<div class="col-5 bg-light border border-warning rounded">
<p> Maxscore pour le chapitre {{ maxscore["chapter"] }} : </p>
<p>{{ maxscore["maxscore"] }} </p>
</div>
{% endfor %}
</body> </body>
</html> </html>
Loading…
Cancel
Save