feat : Poggers code 🔥
continuous-integration/drone/push Build is failing Details

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

@ -7,7 +7,7 @@ class ControllerUser
private $mdAnswer;
private $mdPlayer;
private $mdLobby;
private $mdAdministrator;
private $mdAdministrator;
private $twig;
private $vues;
@ -18,7 +18,7 @@ class ControllerUser
session_start();
try {
$this->twig =$twig;
$this->twig = $twig;
$this->vues = $vues;
$this->mdQuestion = new ModelQuestion();
@ -27,7 +27,6 @@ class ControllerUser
$this->mdPlayer = new ModelPlayer();
$this->mdLobby = new ModelLobby();
$this->mdAdministrator = new ModelAdministrator();
} catch (PDOException $e) {
// $dataVueEreur[] = "Erreur inattendue!!! ";
// require(__DIR__.'/../vues/erreur.php');
@ -41,7 +40,13 @@ class ControllerUser
{
echo $this->twig->render($this->vues["home"]);
}
function themeChoice()
{
$chapters = $this->mdChapter->getChapters();
echo $this->twig->render($this->vues["themeChoice"], [
'chapters' => $chapters,
]);
}
function singleplayer()
{
echo $this->twig->render($this->vues["singleplayer"]);
@ -58,10 +63,11 @@ class ControllerUser
'error' => $_SESSION["error"],
]);
$_SESSION["error"]="";
$_SESSION["error"] = "";
}
function verifyAdmin(){
function verifyAdmin()
{
$username = $_POST['username'];
$password = $_POST['password'];
@ -69,16 +75,44 @@ class ControllerUser
'username' => $username,
'password' => $password,
];
$AdministratorIsOk = $this->mdAdministrator->verifyAdministrator($Administrator);
var_dump($AdministratorIsOk);
if($AdministratorIsOk != null) {
$_SESSION["idAdminConnected"]=$AdministratorIsOk;
if ($AdministratorIsOk != null) {
$_SESSION["idAdminConnected"] = $AdministratorIsOk;
header("Location:/admin/administrators");
}
else {
$_SESSION["error"]="utilisateur introuvable.";
} else {
$_SESSION["error"] = "utilisateur introuvable.";
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
//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
{
function __construct()
@ -39,7 +13,7 @@ class FrontController
// Define routes
$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('POST', '/login/[a:action]', 'ControllerUser');
$router->map('GET', '/admin/chapters', 'ControllerAdminChapters');
@ -52,7 +26,6 @@ class FrontController
$router->map('POST', '/admin/questions/[a:action]', 'ControllerAdminQuestions');
$router->map('GET', '/admin/questions/[a:action]/[i:id]', 'ControllerAdminQuestions');
// Match the current request
$match = $router->match();

@ -26,7 +26,7 @@ class GatewayChapter
$query = "SELECT * FROM chapters";
$this->con->executeQuery($query);
$results = $this->con->getResults();
return $results;
}
@ -39,7 +39,7 @@ class GatewayChapter
return $results[0];
}
public function updateChapter($id,$chapter)
public function updateChapter($id, $chapter)
{
$query = "UPDATE chapters SET name = :name WHERE id = :id;";
$this->con->executeQuery(
@ -56,4 +56,18 @@ class GatewayChapter
$query = "DELETE FROM chapters WHERE id = :id;";
$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)
{
var_dump($question);
$query = "insert into questions(content,idchapter,difficulty,nbfails) values (:content,:idchapter,:difficulty,:nbfails);";
$this->con->executeQuery(
$query,
@ -64,4 +63,19 @@ class GatewayQuestion
$query = "DELETE FROM questions WHERE id = :id;";
$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;
}
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;
}
}

@ -15,25 +15,31 @@ class ModelQuestion
return $questions;
}
function deleteQuestionByID($id)
function deleteQuestionByID($id)
{
$this->gwQuestion->deleteQuestionByID($id);
}
function addQuestion($Question)
function addQuestion($Question)
{
$questionId = $this->gwQuestion->addQuestion($Question);
return $questionId;
}
function getQuestionByID($id) {
function getQuestionByID($id)
{
$question = $this->gwQuestion->getQuestionByID($id);
return $question;
}
function updateQuestion($id, $Question)
function 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">
<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="/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">
<h1 class="mx-auto fs-1">
SOLO

@ -25,49 +25,51 @@
<div class="container text-center text-white">
<div class="container border border-white rounded mt-5">
<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>
</div>
<div class="row g-5">
<div class="col pt-5">
<input type="radio" class="btn-check" name="reponse" id="reponse1" autocomplete="off">
<label class="btn fs-2 container text-white" for="reponse1" style="background-color:blue;">
Lorem, ipsum.
</label>
<form action="/verifQuestion" method="post">
<div class="row g-5">
<div class="col pt-5">
<input type="radio" class="btn-check" name="reponse" value="0" autocomplete="off">
<label class="btn fs-2 container text-white" for="reponse1" style="background-color:blue;">
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 class="col pt-5">
<input type="radio" class="btn-check" name="reponse" id="reponse2" autocomplete="off">
<label class="btn fs-2 container text-white" for="reponse2" style="background-color:green;">
Lorem, ipsum.
</label>
<div class="row g-5">
<div class="col pt-5">
<input type="radio" class="btn-check" name="reponse" value="2" 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" 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 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="col-1 pt-5">
<button type="button" class="fs-2 btn btn-danger btn-lg">
Passer
</button>
</div>
<div class="col-1 pt-5">
<button type="button" class="fs-2 btn btn-success btn-lg">
Valider
</button>
<div class="row justify-content-center">
<div class="col-1 pt-5">
<button type="button" class="fs-2 btn btn-danger btn-lg">
Passer
</button>
</div>
<div class="col-1 pt-5">
<button type="button" class="fs-2 btn btn-success btn-lg">
Valider
</button>
</div>
</div>
</div>
</form>
</div>
</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["home"]="home.twig";
$vues["connexion"]="connexion.twig";
$vues["choixSolo"]="choixThemeSolo.twig";
$vues["themeChoice"]="themeChoice.twig";
$vues["loginAdmin"]="loginAdmin.twig";
$vues["adminAdministrators"]="adminAdministrators.twig";
$vues["adminAdministratorsModal"]="adminAdministratorsModal.twig";

Loading…
Cancel
Save