diff --git a/index.php b/index.php index a4837a8..a92283c 100644 --- a/index.php +++ b/index.php @@ -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'); diff --git a/src/Controleur/FrontControler.php b/src/Controleur/FrontControler.php index eef610d..826751a 100644 --- a/src/Controleur/FrontControler.php +++ b/src/Controleur/FrontControler.php @@ -62,7 +62,7 @@ Class FrontControler{ $action = NULL; if(!$match){ - $dVueEreur = [404,"Page inconue"]; + $dVueEreur = [404,"Page non trouvée"]; $this->vueErreur($dVueEreur); } else{ @@ -72,7 +72,7 @@ Class FrontControler{ //Si existe, on l’appelle if(!$this->ifExisteAction($action)){ - $dVueEreur = [404,"Action inconue"]; + $dVueEreur = [404,"Action non trouvée"]; $this->vueErreur($dVueEreur); } diff --git a/src/Entity/QuizEntity.php b/src/Entity/QuizEntity.php index 8299b80..d440b2c 100644 --- a/src/Entity/QuizEntity.php +++ b/src/Entity/QuizEntity.php @@ -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; } } diff --git a/src/Gateway/QuizGateway.php b/src/Gateway/QuizGateway.php index 5edce73..00c6a8d 100644 --- a/src/Gateway/QuizGateway.php +++ b/src/Gateway/QuizGateway.php @@ -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(); } diff --git a/src/Model/QuizModel.php b/src/Model/QuizModel.php index 2284a83..8cc3383 100644 --- a/src/Model/QuizModel.php +++ b/src/Model/QuizModel.php @@ -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; } } \ No newline at end of file diff --git a/vue/accueilQuiz.php b/vue/accueilQuiz.php index 98eed7b..2a5572b 100644 --- a/vue/accueilQuiz.php +++ b/vue/accueilQuiz.php @@ -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 ]); ?> \ No newline at end of file diff --git a/vue/templates/accueilQuiz.html.twig b/vue/templates/accueilQuiz.html.twig index 47083ee..99c2876 100644 --- a/vue/templates/accueilQuiz.html.twig +++ b/vue/templates/accueilQuiz.html.twig @@ -1,11 +1,11 @@

Liste des Quiz

- +