Merge branch 'ajoutQuiz'

pull/30/head^2
Maxime ROCHER 3 months ago
commit 00a9cc3641

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

@ -15,8 +15,8 @@ if(!isset($_SESSION['theme'])){
require_once __DIR__ . '/config/config.php'; require_once __DIR__ . '/config/config.php';
require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/vendor/autoload.php';
//$co = new \Gateway\Connection('pgsql:host=localhost;dbname=wikifantasy3;', 'postgres', 'sucepute'); $co = new \Gateway\Connection('pgsql:host=localhost;dbname=wikifantasy3;', 'postgres', 'sucepute');
$co = new \Gateway\Connection('pgsql:host=localhost;dbname=dbkekentin;', 'kekentin', 'passwd'); //$co = new \Gateway\Connection('pgsql:host=localhost;dbname=dbkekentin;', 'kekentin', 'passwd');
//twig //twig
$loader = new \Twig\Loader\FilesystemLoader('vue/templates'); $loader = new \Twig\Loader\FilesystemLoader('vue/templates');

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

After

Width:  |  Height:  |  Size: 28 KiB

@ -3,40 +3,74 @@
h2{ h2{
text-align: center; text-align: center;
font-size: 2em; font-size: 2em;
margin-top: 2em; padding-top: 15px;
margin-bottom: 2em; font-weight: bolder;
} }
.quizCard { h3{
background: var(--main-dark-gradient); text-align: center;
border-radius: 15px; margin-left: 15px;
padding: 1em; margin-right: 15px;
display: flex; margin-top: -5px;
flex-direction: column; text-decoration: none;
align-items: center; }
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
a{
text-decoration: none;
} }
.quizCard img { .linkQuiz img{
border-radius: 15px 15px 0 0; width: 14vw;
width: 100%; height: 22vh;
height: auto; object-fit: cover;
border-radius: 10px 10px 0px 0px;
margin : 10px;
} }
.quizCard h3 { .quizCard{
margin: 1em 0 0;
font-size: 1.5em;
text-align: center; text-align: center;
border-radius: 15px;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.2);
} }
.quizCard ul { .quiz-container{
margin-left: auto;
margin-right: auto;
display: flex; display: flex;
justify-content: center; justify-content: start;
list-style: none; align-items: self-start;
padding: 0; gap: 2vw;
margin: 1em 0 0; margin-top: 2em;
min-height: 68vh;
width: 95vw;
padding: 15px;
border-radius: 15px;
}
/* Dark mode */
.dark-mode h3 {
color: white;
}
.dark-mode .quizCard {
background: var(--main-dark-gradient);
}
.dark-mode .quiz-container {
background: black;
}
/* Light mode */
.light-mode h3 {
color: black;
}
.light-mode .quizCard {
background: var(--main-light-gradient);
} }
.quizCard ul li { .light-mode .quiz-container {
margin: 0 0.5em; background: #46BE73;
} }

@ -117,6 +117,13 @@ body.dark-mode .filtre label {
body.light-mode .search-container { body.light-mode .search-container {
background: #ccc; background: #ccc;
} }
.light-mode form {
background-color: #fff;
margin-top: -30px;
padding-top: 35px;
}
body.light-mode .search-container input[type="search"] { body.light-mode .search-container input[type="search"] {
color: #000; color: #000;
} }

@ -68,7 +68,7 @@ Class FrontControler{
$action = NULL; $action = NULL;
if(!$match){ if(!$match){
$dVueEreur = [404,"Page inconue"]; $dVueEreur = [404,"Page non troue"];
$this->vueErreur($dVueEreur); $this->vueErreur($dVueEreur);
} }
else{ else{
@ -78,7 +78,7 @@ Class FrontControler{
//Si existe, on lappelle //Si existe, on lappelle
if(!$this->ifExisteAction($action)){ if(!$this->ifExisteAction($action)){
$dVueEreur = [404,"Action inconue"]; $dVueEreur = [404,"Action non troue"];
$this->vueErreur($dVueEreur); $this->vueErreur($dVueEreur);
} }

@ -4,18 +4,26 @@ namespace Entity;
class QuizEntity class QuizEntity
{ {
private int $id_quiz; public int $id_quiz;
private int $nb_questions; public int $nb_quest;
public string $imgPath;
public string $title;
/** /**
* @param int $id_quiz * @param int $id_quiz
* @param int $nb_questions * @param int $nb_quest
* @param string $imgPath
* @param string $title
*/ */
public function __construct(int $id_quiz, int $nb_questions) public function __construct(int $id_quiz, int $nb_quest, string $imgPath, string $title)
{ {
$this->id_quiz = $id_quiz; $this->id_quiz = $id_quiz;
$this->nb_questions = $nb_questions; $this->nb_quest = $nb_quest;
$this->imgPath = $imgPath;
$this->title = $title;
} }
/** /**
@ -39,14 +47,46 @@ class QuizEntity
*/ */
public function getNbQuestions(): int public function getNbQuestions(): int
{ {
return $this->nb_questions; return $this->nb_quest;
}
/**
* @param int $nb_quest
*/
public function setNbQuestions(int $nb_quest): void
{
$this->nb_quest = $nb_quest;
}
/**
* @return string
*/
public function getIdImg(): string
{
return $this->imgPath;
}
/**
* @param string $imgPath
*/
public function setIdImg(string $imgPath): void
{
$this->imgPath = $imgPath;
}
/**
* @return string
*/
public function getTitle(): string
{
return $this->title;
} }
/** /**
* @param int $nb_questions * @param string $title
*/ */
public function setNbQuestions(int $nb_questions): void public function setTitle(string $title): void
{ {
$this->nb_questions = $nb_questions; $this->title = $title;
} }
} }

@ -8,16 +8,18 @@ use PDO;
class QuizGateway extends Gateway class QuizGateway extends Gateway
{ {
public function create(int $id_quiz, int $nb_questions) : bool public function create(int $id_quiz, int $nb_questions, string $id_img, string $title) : bool
{ {
$query = " $query = "
INSERT INTO Quiz INSERT INTO Quiz
VALUES (:id_q, :nb_q) VALUES (:id_q, :nb_q, :id_img, :title)
"; ";
return $this -> co -> executeQuery($query, [ return $this -> co -> executeQuery($query, [
':id_q' => array($id_quiz, PDO::PARAM_INT), ':id_q' => array($id_quiz, PDO::PARAM_INT),
':nb_q' => array($nb_questions, PDO::PARAM_INT) ':nb_q' => array($nb_questions, PDO::PARAM_INT),
':id_img' => array($id_img, PDO::PARAM_STR),
':title' => array($title, PDO::PARAM_STR)
]); ]);
} }
@ -36,7 +38,7 @@ class QuizGateway extends Gateway
public function findAll() : array public function findAll() : array
{ {
$query = "SELECT id_quiz, title, imgPath FROM Quiz q JOIN Image i on q.img = i.id_img"; $query = "SELECT id_quiz, title, imgPath, nb_quest FROM Quiz q JOIN Image i on q.img = i.id_img";
$this -> co -> executeQuery($query); $this -> co -> executeQuery($query);
return $this -> co -> getResults(); return $this -> co -> getResults();
} }

@ -8,9 +8,9 @@ use Gateway\Gateway;
class QuizModel extends Model{ class QuizModel extends Model{
public function createQuiz(int $id_quiz, int $nb_questions) : bool public function createQuiz(int $id_quiz, int $nb_questions, String $id_img, string $title) : bool
{ {
return $this -> gateway -> create($id_quiz, $nb_questions); return $this -> gateway -> create($id_quiz, $nb_questions, $id_img, $title);
} }
public function getQuiz(int $id_quiz): ?quizEntity public function getQuiz(int $id_quiz): ?quizEntity
@ -19,7 +19,9 @@ class QuizModel extends Model{
if ($q) { if ($q) {
return new quizEntity( return new quizEntity(
$q[0]['id_quiz'], $q[0]['id_quiz'],
$q[0]['nb_quest'] $q[0]['nb_quest'],
$q[0]['id_img'],
$q[0]['title']
); );
} }
return null; return null;
@ -32,6 +34,20 @@ class QuizModel extends Model{
public function listQuiz() : array public function listQuiz() : array
{ {
$res = $this -> gateway -> findAll();
$quizs = [];
foreach ($res as $quiz)
{
$quizs[] = new quizEntity(
$quiz['id_quiz'],
$quiz['nb_quest'],
$quiz['imgpath'],
$quiz['title']
);
}
return $quizs;
} }
} }

@ -10,7 +10,7 @@ echo $twig->render('head.html.twig', [
echo $twig->render('bandeau.html.twig'); echo $twig->render('bandeau.html.twig');
echo $twig->render('quiz.html.twig', [ echo $twig->render('accueilQuiz.html.twig', [
'quizList' => $quizIds 'quizs' => $quizs
]); ]);
?> ?>

@ -1,17 +1,15 @@
<h2>Liste des Quiz</h2> <h2>Liste des Quiz</h2>
<ul> <div class="quiz-container">
{% for quiz in quizList %} {% for quiz in quizs %}
<li>
<div class="quizCard"> <div class="quizCard">
<a href="{{ racine }}/quote/{{ quizIds.id_quiz }}"> <a href="{{ racine }}/quiz/{{ quiz.id_quiz }}" class="linkQuiz">
<img src="{{ quizIds.image }}" alt="Image du quiz {{ quiz.title }}"> <img src="{{ quiz.imgPath }}" alt="Image du quiz {{ quiz.title }}">
<h3>{{ quizIds.title }}</h3> <h3>{{ quiz.title }} ({{ quiz.nb_quest }} questions)</h3>
</a> </a>
</div> </div>
</li>
{% else %} {% else %}
<li>Aucun quiz disponible pour le moment.</li> <h3>Aucun quiz disponible pour le moment.</h3>
{% endfor %} {% endfor %}
</ul> </div>
</body> </body>
</html> </html>

@ -1,3 +1,4 @@
<div class="content">
<form action="{{racine}}/search" method="post"> <form action="{{racine}}/search" method="post">
<div class="search-container"> <div class="search-container">
<input type="search" placeholder="Recherche" id="filtre" name="search" value="{{ search }}"/> <input type="search" placeholder="Recherche" id="filtre" name="search" value="{{ search }}"/>
@ -43,4 +44,5 @@
</div> </div>
--> -->
</form> </form>
</div>
Loading…
Cancel
Save