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 __DIR__ . '/vendor/autoload.php';
//$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=wikifantasy3;', 'postgres', 'sucepute');
//$co = new \Gateway\Connection('pgsql:host=localhost;dbname=dbkekentin;', 'kekentin', 'passwd');
//twig
$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{
text-align: center;
font-size: 2em;
margin-top: 2em;
margin-bottom: 2em;
padding-top: 15px;
font-weight: bolder;
}
.quizCard {
background: var(--main-dark-gradient);
border-radius: 15px;
padding: 1em;
display: flex;
flex-direction: column;
align-items: center;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
h3{
text-align: center;
margin-left: 15px;
margin-right: 15px;
margin-top: -5px;
text-decoration: none;
}
a{
text-decoration: none;
}
.quizCard img {
border-radius: 15px 15px 0 0;
width: 100%;
height: auto;
.linkQuiz img{
width: 14vw;
height: 22vh;
object-fit: cover;
border-radius: 10px 10px 0px 0px;
margin : 10px;
}
.quizCard h3 {
margin: 1em 0 0;
font-size: 1.5em;
.quizCard{
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;
justify-content: center;
list-style: none;
padding: 0;
margin: 1em 0 0;
justify-content: start;
align-items: self-start;
gap: 2vw;
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 {
margin: 0 0.5em;
.light-mode .quiz-container {
background: #46BE73;
}

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

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

@ -4,18 +4,26 @@ namespace Entity;
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 $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->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
{
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
{
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 = "
INSERT INTO Quiz
VALUES (:id_q, :nb_q)
VALUES (:id_q, :nb_q, :id_img, :title)
";
return $this -> co -> executeQuery($query, [
':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
{
$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);
return $this -> co -> getResults();
}

@ -8,9 +8,9 @@ use Gateway\Gateway;
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
@ -19,7 +19,9 @@ class QuizModel extends Model{
if ($q) {
return new quizEntity(
$q[0]['id_quiz'],
$q[0]['nb_quest']
$q[0]['nb_quest'],
$q[0]['id_img'],
$q[0]['title']
);
}
return null;
@ -32,6 +34,20 @@ class QuizModel extends Model{
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('quiz.html.twig', [
'quizList' => $quizIds
echo $twig->render('accueilQuiz.html.twig', [
'quizs' => $quizs
]);
?>

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

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