feat : Poggers code 🔥

master
Jade VAN BRABANDT 1 year ago
parent 7f17e6ab3e
commit a0ac56ff4a

@ -18,7 +18,7 @@ class ControllerUser
session_start(); session_start();
try { try {
$this->twig =$twig; $this->twig = $twig;
$this->vues = $vues; $this->vues = $vues;
$this->mdQuestion = new ModelQuestion(); $this->mdQuestion = new ModelQuestion();
@ -27,7 +27,6 @@ class ControllerUser
$this->mdPlayer = new ModelPlayer(); $this->mdPlayer = new ModelPlayer();
$this->mdLobby = new ModelLobby(); $this->mdLobby = new ModelLobby();
$this->mdAdministrator = new ModelAdministrator(); $this->mdAdministrator = new ModelAdministrator();
} catch (PDOException $e) { } catch (PDOException $e) {
// $dataVueEreur[] = "Erreur inattendue!!! "; // $dataVueEreur[] = "Erreur inattendue!!! ";
// require(__DIR__.'/../vues/erreur.php'); // require(__DIR__.'/../vues/erreur.php');
@ -41,7 +40,13 @@ class ControllerUser
{ {
echo $this->twig->render($this->vues["home"]); echo $this->twig->render($this->vues["home"]);
} }
function themeChoice()
{
$chapters = $this->mdChapter->getChapters();
echo $this->twig->render($this->vues["themeChoice"], [
'chapters' => $chapters,
]);
}
function singleplayer() function singleplayer()
{ {
echo $this->twig->render($this->vues["singleplayer"]); echo $this->twig->render($this->vues["singleplayer"]);
@ -58,10 +63,11 @@ class ControllerUser
'error' => $_SESSION["error"], 'error' => $_SESSION["error"],
]); ]);
$_SESSION["error"]=""; $_SESSION["error"] = "";
} }
function verifyAdmin(){ function verifyAdmin()
{
$username = $_POST['username']; $username = $_POST['username'];
$password = $_POST['password']; $password = $_POST['password'];
@ -71,14 +77,42 @@ class ControllerUser
]; ];
$AdministratorIsOk = $this->mdAdministrator->verifyAdministrator($Administrator); $AdministratorIsOk = $this->mdAdministrator->verifyAdministrator($Administrator);
var_dump($AdministratorIsOk); if ($AdministratorIsOk != null) {
if($AdministratorIsOk != null) { $_SESSION["idAdminConnected"] = $AdministratorIsOk;
$_SESSION["idAdminConnected"]=$AdministratorIsOk;
header("Location:/admin/administrators"); header("Location:/admin/administrators");
} } else {
else { $_SESSION["error"] = "utilisateur introuvable.";
$_SESSION["error"]="utilisateur introuvable.";
header("Location:/login"); header("Location:/login");
} }
} }
function verifySingleplayer()
{
$difficulty = $_POST['difficulty'];
$chapter = $_POST['chapter'];
$difficultyIsOk = TRUE;
$chapterIsOk = TRUE;
if (!($difficulty == 0 or $difficulty == 1 or $difficulty == 2)) {
$_SESSION["error"] = "Valeur de difficulté invalide";
$difficultyIsOk = FALSE;
}
if ($this->mdChapter->verifyChapter($chapter) == NULL) {
$_SESSION["error"] = "Valeur de chapitre invalide";
$chapterIsOk = FALSE;
}
if ($difficultyIsOk and $chapterIsOk) {
$questions = $this->mdQuestion->getQuestionsByChapterAndDifficulty($chapter,$difficulty);
var_dump($questions);
echo $this->twig->render($this->vues["singleplayer"], [
'questions' => $questions,
'numQuestion' => 0,
]);
} else {
$_SESSION["error"] = "Valeur de choix de thème invalide";
header("Location:/themeChoice");
}
}
} }

@ -1,30 +1,4 @@
<?php <?php
//require 'usages/AltoRouter.php';
/*class FrontController
{
function __construct()
{
global $dsn, $user, $pass, $vues;
$listeAction_Acceuil = array('goToSolo', 'goToMulti', 'goToAdmin');
try {
$action = "";
if (isset($_REQUEST['action'])) {
$action = $_REQUEST['action'];
}
if (in_array($action, $listeAction_Acceuil)) {
}
} catch (Exception $e) {
header("Location:" . $vues["erreur"]);
}
}
}*/
class FrontController class FrontController
{ {
function __construct() function __construct()
@ -39,7 +13,7 @@ class FrontController
// Define routes // Define routes
$router->map('GET', '/', 'ControllerUser#home'); // Route pour la page d'accueil $router->map('GET', '/', 'ControllerUser#home'); // Route pour la page d'accueil
$router->map('GET', '/[a:action]', 'ControllerUser'); $router->map('GET|POST', '/[a:action]', 'ControllerUser');
//$router->map('GET', '/admin', 'ControllerAdminAdministrators'); //$router->map('GET', '/admin', 'ControllerAdminAdministrators');
$router->map('POST', '/login/[a:action]', 'ControllerUser'); $router->map('POST', '/login/[a:action]', 'ControllerUser');
$router->map('GET', '/admin/chapters', 'ControllerAdminChapters'); $router->map('GET', '/admin/chapters', 'ControllerAdminChapters');
@ -52,7 +26,6 @@ class FrontController
$router->map('POST', '/admin/questions/[a:action]', 'ControllerAdminQuestions'); $router->map('POST', '/admin/questions/[a:action]', 'ControllerAdminQuestions');
$router->map('GET', '/admin/questions/[a:action]/[i:id]', 'ControllerAdminQuestions'); $router->map('GET', '/admin/questions/[a:action]/[i:id]', 'ControllerAdminQuestions');
// Match the current request // Match the current request
$match = $router->match(); $match = $router->match();

@ -39,7 +39,7 @@ class GatewayChapter
return $results[0]; return $results[0];
} }
public function updateChapter($id,$chapter) public function updateChapter($id, $chapter)
{ {
$query = "UPDATE chapters SET name = :name WHERE id = :id;"; $query = "UPDATE chapters SET name = :name WHERE id = :id;";
$this->con->executeQuery( $this->con->executeQuery(
@ -56,4 +56,18 @@ class GatewayChapter
$query = "DELETE FROM chapters WHERE id = :id;"; $query = "DELETE FROM chapters WHERE id = :id;";
$this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT)));
} }
public function verifyChapter($idChapter)
{
$query = "SELECT chapters.id FROM chapters WHERE id = :id";
$this->con->executeQuery(
$query,
array(
':id' => array($idChapter, PDO::PARAM_STR),
)
);
$results = $this->con->getResults();
return $results[0];
}
} }

@ -12,7 +12,6 @@ class GatewayQuestion
public function addQuestion($question) public function addQuestion($question)
{ {
var_dump($question);
$query = "insert into questions(content,idchapter,difficulty,nbfails) values (:content,:idchapter,:difficulty,:nbfails);"; $query = "insert into questions(content,idchapter,difficulty,nbfails) values (:content,:idchapter,:difficulty,:nbfails);";
$this->con->executeQuery( $this->con->executeQuery(
$query, $query,
@ -64,4 +63,19 @@ class GatewayQuestion
$query = "DELETE FROM questions WHERE id = :id;"; $query = "DELETE FROM questions WHERE id = :id;";
$this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT)));
} }
public function getQuestionsByChapterAndDifficulty($idChapter,$difficulty)
{
var_dump($idChapter,$difficulty);
$query = "SELECT * FROM questions WHERE idchapter = :idChapter AND difficulty = :difficulty;";
$this->con->executeQuery($query,
array(
':idChapter' => array($idChapter, PDO::PARAM_INT),
':difficulty' => array($difficulty, PDO::PARAM_INT),
)
);
$results = $this->con->getResults();
return $results[0];
}
} }

@ -31,8 +31,13 @@ class ModelChapter
return $chapter; return $chapter;
} }
function updateChapter($id,$Chapter) function updateChapter($id,$chapter)
{ {
$this->gwChapter->updateChapter($id,$Chapter); $this->gwChapter->updateChapter($id,$chapter);
}
public function verifyChapter($chapter)
{
$id = $this->gwChapter->verifyChapter($chapter);
return $id;
} }
} }

@ -26,8 +26,8 @@ class ModelQuestion
return $questionId; return $questionId;
} }
function getQuestionByID($id) { function getQuestionByID($id)
{
$question = $this->gwQuestion->getQuestionByID($id); $question = $this->gwQuestion->getQuestionByID($id);
return $question; return $question;
} }
@ -36,4 +36,10 @@ class ModelQuestion
{ {
$this->gwQuestion->updateQuestion($id, $Question); $this->gwQuestion->updateQuestion($id, $Question);
} }
function getQuestionsByChapterAndDifficulty($chapter, $difficulty)
{
$questions = $this->gwQuestion->getQuestionsByChapterAndDifficulty($chapter, $difficulty);
return $questions;
}
} }

@ -1,44 +0,0 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Maths Educ</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/global.css">
<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">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
</head>
<body id="bodyStyle">
<div class="text-center" style="padding-top: 30vh">
<h1 style="color: white; font-size: 50px">Difficulte :</h1>
<input type="radio" class="btn-check" name="difficulte" id="facile" autocomplete="off" checked>
<label class="btn btn-outline-success fs-1" for="facile" style="margin-right: 20px">Facile</label>
<input type="radio" class="btn-check" name="difficulte" id="moyen" autocomplete="off">
<label class="btn btn-outline-warning fs-1" for="moyen" style="margin-right: 20px">Moyen</label>
<input type="radio" class="btn-check" name="difficulte" id="difficulte" autocomplete="off">
<label class="btn btn-outline-danger fs-1" for="difficulte">Difficile</label>
</div>
<div class="dropdown d-flex flex-column align-items-center p-5">
<button class="btn btn-secondary dropdown-toggle btn-lg fs-1" type="button" data-bs-toggle="dropdown" aria-expanded="false">
Theme
</button>
<ul class="dropdown-menu">
<li><button class="dropdown-item fs-1" type="button">Theme1</button></li>
<li><button class="dropdown-item fs-1" type="button">Theme2</button></li>
<li><button class="dropdown-item fs-1" type="button">Theme3</button></li>
</ul>
</div>
<div class="d-flex flex-column align-items-center">
<button type="button" class="btn btn-success btn-lg fs-1" >Jouer</button>
</div>
</body>
</html>

@ -12,7 +12,7 @@
<body id="bodyStyle"> <body id="bodyStyle">
<div class="d-flex flex-column align-items-center justify-content-between" style="height:95vh"> <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"> <img src="Media/Logo.png" style="margin-top:50px; object-fit:fill;" class="h-25">
<a href="/singleplayer" 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;"> <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;">
<div class="container text-center d-flex align-items-center text-center"> <div class="container text-center d-flex align-items-center text-center">
<h1 class="mx-auto fs-1"> <h1 class="mx-auto fs-1">
SOLO SOLO

@ -25,49 +25,51 @@
<div class="container text-center text-white"> <div class="container text-center text-white">
<div class="container border border-white rounded mt-5"> <div class="container border border-white rounded mt-5">
<p class="fs-2"> <p class="fs-2">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident fuga cum soluta iure libero! Ullam, expedita excepturi! Odio distinctio quos quasi commodi libero ratione corrupti, unde iste explicabo suscipit consequatur ipsum! Id beatae corrupti ipsa totam deserunt, vel tenetur, iusto quaerat asperiores veritatis quidem! Vel dolorem recusandae necessitatibus ullam laborum! {{ questions[nbQuestion]['content'] }}
</p> </p>
</div> </div>
<div class="row g-5"> <form action="/verifQuestion" method="post">
<div class="col pt-5"> <div class="row g-5">
<input type="radio" class="btn-check" name="reponse" id="reponse1" autocomplete="off"> <div class="col pt-5">
<label class="btn fs-2 container text-white" for="reponse1" style="background-color:blue;"> <input type="radio" class="btn-check" name="reponse" value="0" autocomplete="off">
Lorem, ipsum. <label class="btn fs-2 container text-white" for="reponse1" style="background-color:blue;">
</label> Lorem, ipsum.
</label>
</div>
<div class="col pt-5">
<input type="radio" class="btn-check" name="reponse" value="1" autocomplete="off">
<label class="btn fs-2 container text-white" for="reponse2" style="background-color:green;">
Lorem, ipsum.
</label>
</div>
</div> </div>
<div class="col pt-5"> <div class="row g-5">
<input type="radio" class="btn-check" name="reponse" id="reponse2" autocomplete="off"> <div class="col pt-5">
<label class="btn fs-2 container text-white" for="reponse2" style="background-color:green;"> <input type="radio" class="btn-check" name="reponse" value="2" autocomplete="off">
Lorem, ipsum. <label class="btn fs-2 container text-white" for="reponse3" style="background-color:red;">
</label> Lorem, ipsum.
</label>
</div>
<div class="col pt-5">
<input type="radio" class="btn-check" name="reponse" value="3" autocomplete="off">
<label class="btn fs-2 container text-white" for="reponse4" style="background-color:orange;">
Lorem, ipsum.
</label>
</div>
</div> </div>
</div>
<div class="row g-5">
<div class="col pt-5">
<input type="radio" class="btn-check" name="reponse" id="reponse3" autocomplete="off">
<label class="btn fs-2 container text-white" for="reponse3" style="background-color:red;">
Lorem, ipsum.
</label>
</div>
<div class="col pt-5">
<input type="radio" class="btn-check" name="reponse" id="reponse4" autocomplete="off">
<label class="btn fs-2 container text-white" for="reponse4" style="background-color:orange;">
Lorem, ipsum.
</label>
</div>
</div>
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-1 pt-5"> <div class="col-1 pt-5">
<button type="button" class="fs-2 btn btn-danger btn-lg"> <button type="button" class="fs-2 btn btn-danger btn-lg">
Passer Passer
</button> </button>
</div> </div>
<div class="col-1 pt-5"> <div class="col-1 pt-5">
<button type="button" class="fs-2 btn btn-success btn-lg"> <button type="button" class="fs-2 btn btn-success btn-lg">
Valider Valider
</button> </button>
</div>
</div> </div>
</div> </form>
</div> </div>
</body> </body>

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Maths Educ</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/global.css">
<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">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
</head>
<body id="bodyStyle">
<form action="/verifySingleplayer" method="post">
<div class="text-center" style="padding-top: 30vh">
<h1 style="color: white; font-size: 50px">Difficulte :</h1>
<input type="radio" class="btn-check" name="difficulty" id="Facile" value="1">
<label class="btn btn-outline-success fs-1" for="Facile" style="margin-right: 20px">Facile</label>
<input type="radio" class="btn-check" name="difficulty" id="Moyen" value="2">
<label class="btn btn-outline-warning fs-1" for="Moyen" style="margin-right: 20px">Moyen</label>
<input type="radio" class="btn-check" name="difficulty" id="Difficile" value="3">
<label class="btn btn-outline-danger fs-1" for="Difficile">Difficile</label>
</div>
<div class="dropdown d-flex flex-column align-items-center p-5">
{% for chapter in chapters %}
<input type="radio" class="btn-check" name="chapter" id="{{ chapter.name }}" value="{{ chapter.id }}">
<label class="btn btn-outline-warning fs-1" for="{{ chapter.name }}">{{ chapter.name }}</label>
{% endfor %}
</div>
<div class="d-flex flex-column align-items-center">
<button type="submit" class="btn btn-success btn-lg fs-1" >Jouer</button>
</div>
</form>
</body>
</html>

@ -12,7 +12,7 @@ $vues["singleplayer"]="singleplayer.twig";
$vues["multiplayer"]="multiplayer.twig"; $vues["multiplayer"]="multiplayer.twig";
$vues["home"]="home.twig"; $vues["home"]="home.twig";
$vues["connexion"]="connexion.twig"; $vues["connexion"]="connexion.twig";
$vues["choixSolo"]="choixThemeSolo.twig"; $vues["themeChoice"]="themeChoice.twig";
$vues["loginAdmin"]="loginAdmin.twig"; $vues["loginAdmin"]="loginAdmin.twig";
$vues["adminAdministrators"]="adminAdministrators.twig"; $vues["adminAdministrators"]="adminAdministrators.twig";
$vues["adminAdministratorsModal"]="adminAdministratorsModal.twig"; $vues["adminAdministratorsModal"]="adminAdministratorsModal.twig";

Loading…
Cancel
Save