feat : random question + loginPlayer (début)

pull/37/head
Jeremy DUCOURTHIAL 1 year ago
parent d64ab6c94b
commit c116fb230f

@ -56,7 +56,16 @@ class ControllerUser
echo $this->twig->render($this->vues["multiplayer"]);
}
function login()
function loginAdmin()
{
echo $this->twig->render($this->vues["loginAdmin"], [
'error' => $_SESSION["error"],
]);
$_SESSION["error"] = "";
}
function loginPlayer()
{
echo $this->twig->render($this->vues["loginAdmin"], [
'error' => $_SESSION["error"],

@ -0,0 +1,76 @@
<?php
class ControllerUserPlayers
{
private $mdPlayer;
private $twig;
private $vues;
function __construct()
{
global $dns, $user, $pass, $vues, $twig;
session_start();
try {
if($_SESSION["idAdminConnected"] != null){
$this->twig =$twig;
$this->vues = $vues;
$this->mdPlayer = new ModelPlayer();
}
else {
header("Location:/login");
}
} catch (PDOException $e) {
// Gérez les erreurs PDO ici
} catch (Exception $e2) {
// Gérez d'autres erreurs ici
}
}
function delete($param) {
$this->mdPlayer->deleteAdministratorByID($param["id"]);
header("Location:/admin/administrators");
}
function add($param) {
$username = $_POST['username'];
$password = $_POST['password'];
$Player = [
'username' => $username,
'password' => $password,
];
$this->mdPlayer->addAdministrator($Player);
header("Location:/loginPlayer");
}
function updatemodal($param) {
$administrator = $this->mdPlayer->getAdministratorByID($param["id"]);
echo $this->twig->render($this->vues["adminAdministratorsModal"], [
'administrator' => $administrator,
]);
}
function update($param) {
$id = $_POST['id'];
$username = $_POST['username'];
$password = $_POST['password'];
$Admin = [
'username' => $username,
'password' => $password,
];
$this->mdPlayer->updateAdministrator($id,$Admin);
header("Location:/admin/administrators");
}
}

@ -25,6 +25,8 @@ class FrontController
$router->map('GET', '/admin/questions', 'ControllerAdminQuestions');
$router->map('POST', '/admin/questions/[a:action]', 'ControllerAdminQuestions');
$router->map('GET', '/admin/questions/[a:action]/[i:id]', 'ControllerAdminQuestions');
$router->map('POST', '/user/players/[a:action]', 'ControllerAdminQuestions');
$router->map('GET', '/user/players/[a:action]/[i:id]', 'ControllerAdminQuestions');
// Match the current request
$match = $router->match();

@ -65,7 +65,7 @@ class GatewayQuestion
public function getQuestionsByChapterAndDifficulty($idChapter, $difficulty)
{
$query = "SELECT * FROM questions WHERE idchapter = :idChapter AND difficulty = :difficulty;";
$query = "SELECT * FROM questions WHERE idchapter = :idChapter AND difficulty = :difficulty ORDER BY RAND() LIMIT 10;";
$this->con->executeQuery(
$query,
array(

@ -10,6 +10,9 @@
</head>
<body id="bodyStyle">
<div>
<a href="/loginPlayer">CONNEXION</a>
</div>
<div class="d-flex flex-column align-items-center justify-content-between" style="height:95vh">
<img src="Media/Logo.png" style="margin-top:50px; object-fit:fill;" class="h-25">
<a href="/themeChoice" class="text-white m-3 container text-center d-flex align-items-center w-75 rounded border border-white text-center" style="background-color:green;text-decoration: none;color: black; height:20vh;">
@ -26,7 +29,7 @@
</h1>
</div>
</a>
<a href="/login" class="text-white m-3 container text-center d-flex align-items-center w-75 rounded border border-white text-center" style="background-color:blue;text-decoration: none;color: black;height:20vh;">
<a href="/loginAdmin" class="text-white m-3 container text-center d-flex align-items-center w-75 rounded border border-white text-center" style="background-color:blue;text-decoration: none;color: black;height:20vh;">
<div class="container text-center d-flex align-items-center text-center">
<h1 class="mx-auto fs-1">
ADMINISTRATION

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Math'Educ - Connexion</title>
<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">
</head>
<body>
<div class="container mt-5">
<div class="row">
<div class="col-md-4 offset-md-4">
<div class="card">
<div class="card-body">
<h2 class="card-title">Connexion</h2>
<form action="/login/verifyPlayer" method="post">
<div class="mb-3">
<label for="username" class="form-label">Nom d'utilisateur</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Mot de passe</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary">Se connecter</button>
<a href="/user/player/add">S'inscrire</a>
<p>{{error}}</p>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

@ -11,7 +11,7 @@
</head>
<body id="bodyStyle">
<div class="mt-5 border border-1 border-black p-3 bg-success text-white d-flex flex-column align-items-center">
<div class="mt-5 border border-1 border-black p-3 bg-success text-white d-flex flex-column align-items-center fs-5">
<p>🏆 Score : 🏆</p>
<p>{{ score }}</p>
</div>

Loading…
Cancel
Save