Compare commits
6 Commits
master
...
documentat
Author | SHA1 | Date |
---|---|---|
|
9aaf918073 | 3 months ago |
|
959b47d273 | 3 months ago |
![]() |
06a68268e2 | 3 months ago |
![]() |
91ffe63c93 | 3 months ago |
|
ce9f60c9e5 | 3 months ago |
|
da6d77f78d | 3 months ago |
@ -1,73 +1,2 @@
|
|||||||
# Projet web What the Fantasy
|
# WikiFantasyWeb
|
||||||
|
|
||||||
Current deployment state : [](https://codefirst.iut.uca.fr/WhatTheFantasy/WF-Website)
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
Le site **What the Fantasy** est une application web permettant aux utilisateurs de découvrir des citations célèbres du monde de la fantasy. En plus de pouvoir lire et apprécier les citations, les utilisateurs peuvent créer un compte pour interagir avec elles en les likant, en les commentant, et en participant à des quiz à thème ou aléatoires.
|
|
||||||
|
|
||||||
### Fonctionnalités principales
|
|
||||||
|
|
||||||
- **Découverte de citations** : Parcourez une large sélection de citations tirées de l'univers de la fantasy.
|
|
||||||
- **Interaction avec les citations** : Les utilisateurs connectés peuvent **liker** et **commenter** les citations.
|
|
||||||
- **Création de compte utilisateur** : Inscription et connexion des utilisateurs pour accéder à des fonctionnalités supplémentaires.
|
|
||||||
- **Quiz interactifs** : Les utilisateurs peuvent participer à des quiz à thème (par exemple, quiz sur les personnages de la fantasy) ou un quiz aléatoire pour deviner qui a dit une citation parmi une liste d'auteurs célèbres.
|
|
||||||
|
|
||||||
|
|
||||||
## Prérequis
|
|
||||||
|
|
||||||
Avant d'exécuter le site, vous devez avoir installé les éléments suivants sur votre machine :
|
|
||||||
|
|
||||||
- **Apache2** : Le serveur web Apache2 pour héberger le site.
|
|
||||||
- [Installation d'Apache2](https://httpd.apache.org/docs/)
|
|
||||||
|
|
||||||
- **PHP** : Le langage côté serveur utilisé pour gérer la logique d'interaction et les données dynamiques.
|
|
||||||
- Vous pouvez installer PHP sur votre serveur via [ces instructions](https://www.php.net/manual/en/install.php).
|
|
||||||
|
|
||||||
- **PostgreSQL** : La base de données pour stocker les utilisateurs, citations et résultats des quiz.
|
|
||||||
- [Installation de PostgreSQL](https://www.postgresql.org/download/)
|
|
||||||
|
|
||||||
- **JavaScript** : Pour les fonctionnalités interactives côté client.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
### 1. Cloner le dépôt
|
|
||||||
|
|
||||||
Clonez le dépôt Git sur votre machine locale avec la commande suivante :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://codefirst.iut.uca.fr/git/WhatTheFantasy/WF-Website.git
|
|
||||||
```
|
|
||||||
### 2. Installer Apache2, PHP et MySQL/MariaDB
|
|
||||||
**Sur Ubuntu/Debian (exemple d'installation) :**
|
|
||||||
```bash
|
|
||||||
sudo apt update
|
|
||||||
sudo apt install apache2
|
|
||||||
```
|
|
||||||
Cela installera Apache2.
|
|
||||||
|
|
||||||
**Lancer le serveur Apache**
|
|
||||||
|
|
||||||
Assurez-vous que le serveur Apache2 est en fonctionnement. Sur Ubuntu/Debian, vous pouvez redémarrer Apache avec la commande suivante :
|
|
||||||
```bash
|
|
||||||
sudo systemctl restart apache2
|
|
||||||
```
|
|
||||||
|
|
||||||
**Sur Windows :**<br/>
|
|
||||||
Téléchargez et installez [XAMPP](https://www.apachefriends.org/download.html), qui inclut Apache, PHP
|
|
||||||
|
|
||||||
|
|
||||||
## Auteurs
|
|
||||||
BRONGNIART Kentin<br/>
|
|
||||||
BEAULATON Léni<br/>
|
|
||||||
ROCHER Maxime<br/>
|
|
||||||
MONDEJAR Kevin<br/>
|
|
||||||
GUICHARD-MONTGUERS Louis<br/>
|
|
||||||
NGUYEN Tommy<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 1.7 MiB |
Before Width: | Height: | Size: 135 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 152 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 152 KiB |
@ -1,76 +0,0 @@
|
|||||||
@import url(./style.css); /* Import de style.css */
|
|
||||||
|
|
||||||
h2{
|
|
||||||
text-align: center;
|
|
||||||
font-size: 2em;
|
|
||||||
padding-top: 15px;
|
|
||||||
font-weight: bolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
h3{
|
|
||||||
text-align: center;
|
|
||||||
margin-left: 15px;
|
|
||||||
margin-right: 15px;
|
|
||||||
margin-top: -5px;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
a{
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.linkQuiz img{
|
|
||||||
width: 14vw;
|
|
||||||
height: 22vh;
|
|
||||||
object-fit: cover;
|
|
||||||
border-radius: 10px 10px 0px 0px;
|
|
||||||
margin : 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.quizCard{
|
|
||||||
text-align: center;
|
|
||||||
border-radius: 15px;
|
|
||||||
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.quiz-container{
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
display: flex;
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
.light-mode .quiz-container {
|
|
||||||
background: #46BE73;
|
|
||||||
}
|
|
@ -1,70 +1 @@
|
|||||||
@import url(./style.css);
|
@import url(./style.css); /* Import de style.css */
|
||||||
|
|
||||||
body.dark-mode .creation form.add {
|
|
||||||
background-color: var(--main-dark-other-color);
|
|
||||||
border-radius: 25px;
|
|
||||||
padding: 20px;
|
|
||||||
max-width: 600px;
|
|
||||||
margin: 40px auto;
|
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
||||||
color: var(--main-dark-text-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
body.light-mode .creation form.add {
|
|
||||||
background-color: var(--main-light-other-color);
|
|
||||||
border-radius: 25px;
|
|
||||||
padding: 20px;
|
|
||||||
max-width: 600px;
|
|
||||||
margin: 40px auto;
|
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
||||||
color: var(--main-light-text-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.creation form.add input[type="text"],
|
|
||||||
.creation form.add input[type="number"],
|
|
||||||
.creation form.add textarea {
|
|
||||||
width: 100%;
|
|
||||||
padding: 10px;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
border-radius: 5px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.creation form.add input[type="file"] {
|
|
||||||
width: 100%;
|
|
||||||
padding: 10px;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
border-radius: 5px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.creation form.add input[type="radio"] {
|
|
||||||
width: auto;
|
|
||||||
margin-right: 5px;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
.creation form.add label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.creation form.add input[type="submit"] {
|
|
||||||
width: 100%;
|
|
||||||
padding: 10px;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
border-radius: 5px;
|
|
||||||
background-color: #ffffff;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.creation form.add input[type="submit"]:hover {
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.creation form.add h1 {
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
@ -0,0 +1,120 @@
|
|||||||
|
/* Conteneur pour les suggestions en deux colonnes */
|
||||||
|
.suggestions-container {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: space-around;
|
||||||
|
width: 100%;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
a.link-citation {
|
||||||
|
text-decoration: none;
|
||||||
|
color: white;
|
||||||
|
width: 47.5%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Citations */
|
||||||
|
.citation-container {
|
||||||
|
background: linear-gradient(to right, #4a148c, #7b1fa2);
|
||||||
|
border-radius: 12px;
|
||||||
|
color: white;
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
align-items: flex-start;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 0;
|
||||||
|
height: 150px;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
word-wrap: break-word; /* Permet de couper les mots trop longs */
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fixe la taille pour s'assurer que toutes les citations restent cohérentes */
|
||||||
|
.citation-container .text-content {
|
||||||
|
flex-grow: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
height: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote {
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.citation-image {
|
||||||
|
width: 150px;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
margin: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-content {
|
||||||
|
flex: 1;
|
||||||
|
padding: 10px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center; /* Centre verticalement le texte */
|
||||||
|
word-wrap: break-word; /* Permet de couper les mots trop longs */
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quoteContent {
|
||||||
|
font-size: 1.2em;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.citation .movie, .character, .year {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mode sombre */
|
||||||
|
body.dark-mode .quote {
|
||||||
|
background: linear-gradient(45deg, #4a148c, #7b1fa2);
|
||||||
|
color:white;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mode clair */
|
||||||
|
body.light-mode .quote {
|
||||||
|
background-image: linear-gradient(-28deg, #f3e7e9 0%, #e3eeff 99%, #e3eeff 100%);
|
||||||
|
color:black; /* Changer le texte en noir pour le mode clair */
|
||||||
|
}
|
||||||
|
|
||||||
|
body.light-mode .citation,
|
||||||
|
body.light-mode .movie,
|
||||||
|
body.light-mode .character,
|
||||||
|
body.light-mode .year {
|
||||||
|
color: black; /* Forcer le texte en noir pour le mode clair */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsive design */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.suggestions-container {
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.citation-container {
|
||||||
|
width: 100%; /* Chaque citation prend toute la largeur sur mobile */
|
||||||
|
max-width: 100%;
|
||||||
|
height: 100px; /* Supprimer la hauteur fixe sur mobile */
|
||||||
|
}
|
||||||
|
|
||||||
|
.citation-image {
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quote {
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
/* header.css */
|
||||||
|
|
||||||
|
/* Styles généraux */
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: #120b1d;
|
||||||
|
font-family: "Lemon", serif;
|
||||||
|
margin-top: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Header */
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
position: fixed;
|
||||||
|
background-color: #000000;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
vertical-align: center;
|
||||||
|
gap: 30px;
|
||||||
|
width: 40%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 20%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: flex-end;
|
||||||
|
align-items: center;
|
||||||
|
vertical-align: center;
|
||||||
|
gap: 30px;
|
||||||
|
width: 40%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
vertical-align: center;
|
||||||
|
margin: 10px;
|
||||||
|
width: 70px;
|
||||||
|
height: 70px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Mode sombre */
|
||||||
|
body.dark-mode {
|
||||||
|
background-color: #120B1D;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .header {
|
||||||
|
background-color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .header img {
|
||||||
|
filter: invert(0%);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .nav img:hover {
|
||||||
|
filter: invert(59%) sepia(96%) saturate(6733%) hue-rotate(275deg) brightness(112%) contrast(122%);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .search {
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mode clair */
|
||||||
|
body.light-mode {
|
||||||
|
background-color: #ffffff;
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.light-mode .header {
|
||||||
|
background-color: #F4F1DE;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.light-mode .header img {
|
||||||
|
filter: invert(100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.light-mode .nav img:hover {
|
||||||
|
filter: invert(22%) sepia(6%) saturate(2269%) hue-rotate(193deg) brightness(98%) contrast(106%);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.light-mode .search {
|
||||||
|
background: black;
|
||||||
|
}
|
@ -1,148 +1,175 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Entity;
|
namespace Entity;
|
||||||
|
|
||||||
|
class QuestionEntity
|
||||||
|
{
|
||||||
|
private int $id_question;
|
||||||
|
private string $question;
|
||||||
|
private string $answerA;
|
||||||
|
private string $answerB;
|
||||||
|
private string $answerC;
|
||||||
|
private string $answerD;
|
||||||
|
private string $cAnswer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor to initialize the QuestionEntity object.
|
||||||
|
*
|
||||||
|
* @param int $id_question The ID of the question.
|
||||||
|
* @param string $question The question text.
|
||||||
|
* @param string $answerA The text for answer A.
|
||||||
|
* @param string $answerB The text for answer B.
|
||||||
|
* @param string $answerC The text for answer C.
|
||||||
|
* @param string $answerD The text for answer D.
|
||||||
|
* @param string $cAnswer The correct answer.
|
||||||
|
*/
|
||||||
|
public function __construct(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer)
|
||||||
|
{
|
||||||
|
$this->id_question = $id_question;
|
||||||
|
$this->question = $question;
|
||||||
|
$this->answerA = $answerA;
|
||||||
|
$this->answerB = $answerB;
|
||||||
|
$this->answerC = $answerC;
|
||||||
|
$this->answerD = $answerD;
|
||||||
|
$this->cAnswer = $cAnswer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ID of the question.
|
||||||
|
*
|
||||||
|
* @return int The ID of the question.
|
||||||
|
*/
|
||||||
|
public function getIdQuestion(): int
|
||||||
|
{
|
||||||
|
return $this->id_question;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the ID of the question.
|
||||||
|
*
|
||||||
|
* @param int $id_question The ID of the question.
|
||||||
|
*/
|
||||||
|
public function setIdQuestion(int $id_question): void
|
||||||
|
{
|
||||||
|
$this->id_question = $id_question;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the question text.
|
||||||
|
*
|
||||||
|
* @return string The question text.
|
||||||
|
*/
|
||||||
|
public function getQuestion(): string
|
||||||
|
{
|
||||||
|
return $this->question;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the question text.
|
||||||
|
*
|
||||||
|
* @param string $question The question text.
|
||||||
|
*/
|
||||||
|
public function setQuestion(string $question): void
|
||||||
|
{
|
||||||
|
$this->question = $question;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the text for answer A.
|
||||||
|
*
|
||||||
|
* @return string The text for answer A.
|
||||||
|
*/
|
||||||
|
public function getAnswerA(): string
|
||||||
|
{
|
||||||
|
return $this->answerA;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the text for answer A.
|
||||||
|
*
|
||||||
|
* @param string $answerA The text for answer A.
|
||||||
|
*/
|
||||||
|
public function setAnswerA(string $answerA): void
|
||||||
|
{
|
||||||
|
$this->answerA = $answerA;
|
||||||
|
}
|
||||||
|
|
||||||
class QuestionEntity
|
/**
|
||||||
|
* Get the text for answer B.
|
||||||
|
*
|
||||||
|
* @return string The text for answer B.
|
||||||
|
*/
|
||||||
|
public function getAnswerB(): string
|
||||||
{
|
{
|
||||||
private int $id_question;
|
return $this->answerB;
|
||||||
private string $question;
|
}
|
||||||
private string $answerA;
|
|
||||||
private string $answerB;
|
/**
|
||||||
private string $answerC;
|
* Set the text for answer B.
|
||||||
private string $answerD;
|
*
|
||||||
private string $cAnswer;
|
* @param string $answerB The text for answer B.
|
||||||
|
*/
|
||||||
/**
|
public function setAnswerB(string $answerB): void
|
||||||
* @param int $id_question
|
{
|
||||||
* @param string $question
|
$this->answerB = $answerB;
|
||||||
* @param string $answerA
|
}
|
||||||
* @param string $answerB
|
|
||||||
* @param string $answerC
|
|
||||||
* @param string $answerD
|
|
||||||
* @param string $cAnswer
|
|
||||||
*/
|
|
||||||
public function __construct(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer)
|
|
||||||
{
|
|
||||||
$this->id_question = $id_question;
|
|
||||||
$this->question = $question;
|
|
||||||
$this->answerA = $answerA;
|
|
||||||
$this->answerB = $answerB;
|
|
||||||
$this->answerC = $answerC;
|
|
||||||
$this->answerD = $answerD;
|
|
||||||
$this->cAnswer = $cAnswer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getIdQuestion(): int
|
|
||||||
{
|
|
||||||
return $this->id_question;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $id_question
|
|
||||||
*/
|
|
||||||
public function setIdQuestion(int $id_question): void
|
|
||||||
{
|
|
||||||
$this->id_question = $id_question;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getQuestion(): string
|
|
||||||
{
|
|
||||||
return $this->question;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $question
|
|
||||||
*/
|
|
||||||
public function setQuestion(string $question): void
|
|
||||||
{
|
|
||||||
$this->question = $question;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getAnswerA(): string
|
|
||||||
{
|
|
||||||
return $this->answerA;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $answerA
|
|
||||||
*/
|
|
||||||
public function setAnswerA(string $answerA): void
|
|
||||||
{
|
|
||||||
$this->answerA = $answerA;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getAnswerB(): string
|
|
||||||
{
|
|
||||||
return $this->answerB;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $answerB
|
|
||||||
*/
|
|
||||||
public function setAnswerB(string $answerB): void
|
|
||||||
{
|
|
||||||
$this->answerB = $answerB;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getAnswerC(): string
|
|
||||||
{
|
|
||||||
return $this->answerC;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $answerC
|
|
||||||
*/
|
|
||||||
public function setAnswerC(string $answerC): void
|
|
||||||
{
|
|
||||||
$this->answerC = $answerC;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getAnswerD(): string
|
|
||||||
{
|
|
||||||
return $this->answerD;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $answerD
|
|
||||||
*/
|
|
||||||
public function setAnswerD(string $answerD): void
|
|
||||||
{
|
|
||||||
$this->answerD = $answerD;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCAnswer(): string
|
|
||||||
{
|
|
||||||
return $this->cAnswer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $cAnswer
|
|
||||||
*/
|
|
||||||
public function setCAnswer(string $cAnswer): void
|
|
||||||
{
|
|
||||||
$this->cAnswer = $cAnswer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the text for answer C.
|
||||||
|
*
|
||||||
|
* @return string The text for answer C.
|
||||||
|
*/
|
||||||
|
public function getAnswerC(): string
|
||||||
|
{
|
||||||
|
return $this->answerC;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the text for answer C.
|
||||||
|
*
|
||||||
|
* @param string $answerC The text for answer C.
|
||||||
|
*/
|
||||||
|
public function setAnswerC(string $answerC): void
|
||||||
|
{
|
||||||
|
$this->answerC = $answerC;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the text for answer D.
|
||||||
|
*
|
||||||
|
* @return string The text for answer D.
|
||||||
|
*/
|
||||||
|
public function getAnswerD(): string
|
||||||
|
{
|
||||||
|
return $this->answerD;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the text for answer D.
|
||||||
|
*
|
||||||
|
* @param string $answerD The text for answer D.
|
||||||
|
*/
|
||||||
|
public function setAnswerD(string $answerD): void
|
||||||
|
{
|
||||||
|
$this->answerD = $answerD;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the correct answer.
|
||||||
|
*
|
||||||
|
* @return string The correct answer.
|
||||||
|
*/
|
||||||
|
public function getCAnswer(): string
|
||||||
|
{
|
||||||
|
return $this->cAnswer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the correct answer.
|
||||||
|
*
|
||||||
|
* @param string $cAnswer The correct answer.
|
||||||
|
*/
|
||||||
|
public function setCAnswer(string $cAnswer): void
|
||||||
|
{
|
||||||
|
$this->cAnswer = $cAnswer;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -1,125 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Gateway;
|
|
||||||
|
|
||||||
use PDO;
|
|
||||||
|
|
||||||
class ResultsGateway extends Gateway
|
|
||||||
{
|
|
||||||
|
|
||||||
public function createResultsGateway(int $idQuiz, int $idUser, int $nbPts, int $time) : bool
|
|
||||||
{
|
|
||||||
$query = "
|
|
||||||
INSERT INTO Results
|
|
||||||
VALUES (:id_quiz, :id_user, :nb_pts, :time)
|
|
||||||
";
|
|
||||||
|
|
||||||
return $this -> co -> executeQuery($query, [
|
|
||||||
'id_quiz' => array($idQuiz, PDO::PARAM_INT),
|
|
||||||
'id_user' => array($idUser, PDO::PARAM_INT),
|
|
||||||
'nb_pts' => array($nbPts, PDO::PARAM_INT),
|
|
||||||
'time' => array($time, PDO::PARAM_INT)
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findResultsByQuiz(int $idQuiz) : array
|
|
||||||
{
|
|
||||||
$query = "
|
|
||||||
SELECT * FROM Results
|
|
||||||
WHERE quiz_r = :id_quiz
|
|
||||||
";
|
|
||||||
|
|
||||||
$this -> co -> executeQuery($query, ['id_quiz' => array($idQuiz, PDO::PARAM_INT)]);
|
|
||||||
|
|
||||||
return $this -> co -> getResults();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findResultsByUser(int $idUser) : array
|
|
||||||
{
|
|
||||||
$query = "
|
|
||||||
SELECT * FROM Results
|
|
||||||
WHERE user_r = :id_user
|
|
||||||
";
|
|
||||||
|
|
||||||
$this -> co -> executeQuery($query, ['id_user' => array($idUser, PDO::PARAM_INT)]);
|
|
||||||
|
|
||||||
return $this -> co -> getResults();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findResultsById(int $idQuiz, int $idUser) : array
|
|
||||||
{
|
|
||||||
$query = "
|
|
||||||
SELECT * FROM Results
|
|
||||||
WHERE quiz_r = :id_quiz AND user_r = :id_user
|
|
||||||
";
|
|
||||||
|
|
||||||
$this -> co -> executeQuery($query, [
|
|
||||||
'id_user' => array($idUser, PDO::PARAM_INT),
|
|
||||||
'id_quiz' => array($idQuiz, PDO::PARAM_INT)
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $this -> co -> getResults();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findAllResults() : array
|
|
||||||
{
|
|
||||||
$query = "SELECT * FROM Results";
|
|
||||||
|
|
||||||
$this -> co -> executeQuery($query);
|
|
||||||
|
|
||||||
return $this -> co -> getResults();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateResults(int $idQuiz, int $idUser, ?int $score, ?int $time) : bool
|
|
||||||
{
|
|
||||||
if ($score && !$time)
|
|
||||||
{
|
|
||||||
$query = "
|
|
||||||
UPDATE Results
|
|
||||||
SET score = :score
|
|
||||||
WHERE quiz_r = :id_quiz AND user_r = :id_user
|
|
||||||
";
|
|
||||||
|
|
||||||
return $this -> co -> executeQuery($query, [
|
|
||||||
'id_quiz' => array($idQuiz, PDO::PARAM_INT),
|
|
||||||
'id_user' => array($idUser, PDO::PARAM_INT),
|
|
||||||
'score' => array($score, PDO::PARAM_INT)
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
else if (!$score && $time)
|
|
||||||
{
|
|
||||||
$query = "
|
|
||||||
UPDATE Results
|
|
||||||
SET time = :time
|
|
||||||
WHERE quiz_r = :id_quiz AND user_r = :id_user
|
|
||||||
";
|
|
||||||
|
|
||||||
return $this -> co -> executeQuery($query, [
|
|
||||||
'id_quiz' => array($idQuiz, PDO::PARAM_INT),
|
|
||||||
'id_user' => array($idUser, PDO::PARAM_INT),
|
|
||||||
'time' => array($time, PDO::PARAM_INT)
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$query = "
|
|
||||||
UPDATE Results
|
|
||||||
SET score = :score AND time = :time
|
|
||||||
WHERE quiz_r = :id_quiz AND user_r = :id_user
|
|
||||||
";
|
|
||||||
|
|
||||||
return $this -> co -> executeQuery($query, [
|
|
||||||
'id_quiz' => array($idQuiz, PDO::PARAM_INT),
|
|
||||||
'id_user' => array($idUser, PDO::PARAM_INT),
|
|
||||||
'score' => array($score, PDO::PARAM_INT),
|
|
||||||
'time' => array($time, PDO::PARAM_INT)
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,45 +1,56 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Model;
|
namespace Model;
|
||||||
use Entity\CommentaryEntity;
|
use Entity\CommentaryEntity;
|
||||||
use Gateway\CommentaryGateway;
|
use Gateway\CommentaryGateway;
|
||||||
use Gateway\Gateway;
|
use Gateway\Gateway;
|
||||||
|
|
||||||
|
|
||||||
class CommentaryModel extends Model {
|
class CommentaryModel extends Model {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new comment associated with a specific quote and user.
|
||||||
|
*
|
||||||
|
* @param string $comment The content of the comment.
|
||||||
|
* @param string $idQuote The identifier of the quote the comment is associated with.
|
||||||
|
* @param string $idUser The identifier of the user who is creating the comment.
|
||||||
|
*
|
||||||
|
* @return bool Returns true if the comment was successfully created, otherwise false.
|
||||||
|
*/
|
||||||
public function createComment(string $comment, string $idQuote, string $idUser): bool {
|
public function createComment(string $comment, string $idQuote, string $idUser): bool {
|
||||||
|
// Calls the gateway's create method to insert the new comment into the data source.
|
||||||
return $this->gateway->create($comment, $idUser, $idQuote);
|
return $this->gateway->create($comment, $idUser, $idQuote);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all comments associated with a specific quote.
|
||||||
|
*
|
||||||
|
* @param int $id The unique identifier of the quote.
|
||||||
|
*
|
||||||
|
* @return CommentaryEntity[] Returns an array of CommentaryEntity objects representing all the comments for the given quote.
|
||||||
|
*/
|
||||||
public function getComment(int $id): array {
|
public function getComment(int $id): array {
|
||||||
|
// Initialize an empty array to store the comment objects.
|
||||||
$com = [];
|
$com = [];
|
||||||
|
|
||||||
|
// Fetch all comments related to the given quote ID using the gateway's findByQuote method.
|
||||||
$res = $this->gateway->findByQuote($id);
|
$res = $this->gateway->findByQuote($id);
|
||||||
foreach ($res as $comments){
|
|
||||||
$com[] = new CommentaryEntity($comments["id_comment"], $comments["comment"], $comments["datec"], $comments["username"], $comments["imgpath"]);
|
|
||||||
}
|
|
||||||
return $com;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getComments(): array {
|
// Loop through each comment in the result and create a CommentaryEntity object for each.
|
||||||
$res = $this->gateway->findAll();
|
|
||||||
foreach ($res as $comments) {
|
foreach ($res as $comments) {
|
||||||
$com[] = new CommentaryEntity($comments["id_comment"], $comments["comment"], $comments["date"]);
|
$com[] = new CommentaryEntity(
|
||||||
|
$comments["id_comment"], // Comment ID
|
||||||
|
$comments["comment"], // The content of the comment
|
||||||
|
$comments["datec"], // The date the comment was created
|
||||||
|
$comments["username"], // The username of the user who made the comment
|
||||||
|
$comments["imgpath"] // The image path associated with the user who made the comment
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return $com;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteComment(int $id_comment): bool {
|
// Return the array of CommentaryEntity objects.
|
||||||
return $this -> gateway -> delete($id_comment);
|
return $com;
|
||||||
}
|
|
||||||
|
|
||||||
public function updateComment(int $id_comment, string $comment): bool {
|
|
||||||
|
|
||||||
$c = $this -> getComment($id_comment);
|
|
||||||
|
|
||||||
if($c){
|
|
||||||
$c -> setComment($comment);
|
|
||||||
return $this->gateway -> update($c);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
@ -1,65 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Model;
|
|
||||||
use Gateway\FavoriteGateway;
|
|
||||||
use Entity\FavoriteEntity;
|
|
||||||
use Gateway\Gateway;
|
|
||||||
|
|
||||||
class FavoriteModel extends Model
|
|
||||||
{
|
|
||||||
public function createFavoriteModel(int $idUser, int $idQuote) : bool
|
|
||||||
{
|
|
||||||
return $this -> gateway -> createFavoriteGateway($idUser, $idQuote);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFavoriteById(int $idUser, int $idQuote) : ?FavoriteEntity
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findFavoriteById($idUser, $idQuote);
|
|
||||||
|
|
||||||
if ($res)
|
|
||||||
{
|
|
||||||
return new FavoriteEntity (
|
|
||||||
$res[0]['user_f'],
|
|
||||||
$res[0]['quote_f'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFavoriteByUser(int $idUser) : array
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findFavoriteByUser($idUser);
|
|
||||||
|
|
||||||
$favorites = [];
|
|
||||||
|
|
||||||
foreach ($res as $favorite)
|
|
||||||
{
|
|
||||||
$favorites = new FavoriteEntity (
|
|
||||||
$favorite['user_f'],
|
|
||||||
$favorite['quote_f']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $favorites;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAllFavorite() : array
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findAllFavorite();
|
|
||||||
|
|
||||||
$favorites = [];
|
|
||||||
|
|
||||||
foreach ($res as $favorite)
|
|
||||||
{
|
|
||||||
$favorites = new FavoriteEntity (
|
|
||||||
$favorite['user_f'],
|
|
||||||
$favorite['quote_f']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $favorites;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeFavorite(int $idUser, int $idQuote) : bool
|
|
||||||
{
|
|
||||||
return $this -> gateway -> deleteFavoriteGateway($idUser, $idQuote);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Model;
|
namespace Model;
|
||||||
|
|
||||||
use Entity\ImageEntity;
|
use Entity\ImageEntity;
|
||||||
use Gateway\ImageGateway;
|
use Gateway\ImageGateway;
|
||||||
use Gateway\Gateway;
|
use Gateway\Gateway;
|
||||||
|
|
||||||
|
|
||||||
class ImageModel extends Model
|
class ImageModel extends Model
|
||||||
{
|
{
|
||||||
public function createImgModel(int $idImg, string $imgPath) : bool
|
|
||||||
{
|
|
||||||
return $this -> gateway -> createImgGateway($idImg, $imgPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createImgModelWithoutId (string $imgPath) : int
|
|
||||||
{
|
|
||||||
$idImg = $this->gateway ->getLastId() ;
|
|
||||||
$this -> gateway -> createImgGateway($idImg, $imgPath, false);
|
|
||||||
return $idImg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getImgById(int $idImg) : ?ImageEntity
|
/**
|
||||||
{
|
* Retrieves all images from the database.
|
||||||
$res = $this -> gateway -> findImgById($idImg);
|
*
|
||||||
|
* @return ImageEntity[] Returns an array of ImageEntity objects representing all the images.
|
||||||
if ($res)
|
*/
|
||||||
{
|
public function getAllImg() : array {
|
||||||
return new ImageEntity(
|
// Fetch all images using the gateway's findAllImg method.
|
||||||
$res[0]['id_img'],
|
$res = $this->gateway->findAllImg();
|
||||||
$res[0]['imgpath']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAllImg() : array
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findAllImg();
|
|
||||||
|
|
||||||
|
// Initialize an empty array to store the ImageEntity objects.
|
||||||
$images = [];
|
$images = [];
|
||||||
|
|
||||||
foreach ($res as $img)
|
// Loop through each image in the result and create an ImageEntity object for each.
|
||||||
{
|
foreach ($res as $img) {
|
||||||
$images[] = new ImageEntity(
|
$images[] = new ImageEntity(
|
||||||
$img['id_img'],
|
$img['id_img'], // Image ID
|
||||||
$img['imgpath']
|
$img['imgpath'] // Image path (location or URL of the image)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $images;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Return the array of ImageEntity objects.
|
||||||
public function deleteImgModel(int $idImg) : bool
|
return $images;
|
||||||
{
|
|
||||||
return $this -> gateway -> deleteImgGateway($idImg);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function updateImgModel(int $idImg, string $imgPath) : bool
|
?>
|
||||||
{
|
|
||||||
return $this -> gateway -> updateImgGateway($idImg, $imgPath);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +1,60 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Model;
|
namespace Model;
|
||||||
|
use Entity\quizEntity;
|
||||||
use Entity\QuizEntity;
|
|
||||||
use Gateway\QuizGateway;
|
use Gateway\QuizGateway;
|
||||||
use Gateway\Gateway;
|
use Gateway\Gateway;
|
||||||
|
|
||||||
|
|
||||||
class QuizModel extends Model{
|
class QuizModel extends Model{
|
||||||
|
|
||||||
public function createQuiz(int $id_quiz, int $nb_questions, String $id_img, string $title) : bool
|
|
||||||
{
|
|
||||||
return $this -> gateway -> create($id_quiz, $nb_questions, $id_img, $title);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getQuiz(int $id_quiz): ?QuizEntity
|
/**
|
||||||
{
|
* Retrieves a quiz by its unique identifier.
|
||||||
$q = $this -> gateway -> findQuizById($id_quiz);
|
*
|
||||||
|
* @param int $id_quiz The unique identifier of the quiz to retrieve.
|
||||||
|
*
|
||||||
|
* @return quizEntity|null Returns a quizEntity object if found, otherwise null.
|
||||||
|
*/
|
||||||
|
public function getQuiz(int $id_quiz): ?quizEntity{
|
||||||
|
// Attempt to find the quiz by its ID using the gateway's findQuizById method.
|
||||||
|
$q = $this->gateway->findQuizById($id_quiz);
|
||||||
|
|
||||||
|
// If the quiz is found, create and return a new quizEntity object with the quiz details.
|
||||||
if ($q) {
|
if ($q) {
|
||||||
return new QuizEntity(
|
return new quizEntity(
|
||||||
$q[0]['id_quiz'],
|
$q[0]['id_quiz'], // Quiz ID
|
||||||
$q[0]['nb_quest'],
|
$q[0]['nb_quest'] // The number of questions in the quiz
|
||||||
$q[0]['imgpath'],
|
|
||||||
$q[0]['title']
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteQuiz(int $id_quiz) : bool
|
// If no quiz is found, return null.
|
||||||
{
|
return null;
|
||||||
return $this -> gateway -> delete($id_quiz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listQuiz() : array
|
/**
|
||||||
{
|
* Retrieves all quizzes from the database.
|
||||||
$res = $this -> gateway -> findAll();
|
*
|
||||||
|
* @return quizEntity[] Returns an array of quizEntity objects representing all the quizzes.
|
||||||
$quizs = [];
|
*/
|
||||||
|
public function getAllQuiz() : array{
|
||||||
foreach ($res as $quiz)
|
// Fetch all quizzes using the gateway's findAll method.
|
||||||
{
|
$q = $this->gateway->findAll();
|
||||||
$quizs[] = new QuizEntity(
|
|
||||||
$quiz['id_quiz'],
|
// Initialize an empty array to store the quiz objects.
|
||||||
$quiz['nb_quest'],
|
$quizzes = [];
|
||||||
$quiz['imgpath'],
|
|
||||||
$quiz['title']
|
// Loop through each quiz in the result and create a quizEntity object for each.
|
||||||
|
foreach ($q as $quiz) {
|
||||||
|
$quizzes[] = new quizEntity(
|
||||||
|
$quiz['id_quiz'], // Quiz ID
|
||||||
|
$quiz['nb_questions'] // The number of questions in the quiz
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $quizs;
|
// Return the array of quizEntity objects.
|
||||||
|
return $quizzes;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -1,55 +1,164 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Model;
|
namespace Model;
|
||||||
use Entity\Quote;
|
use Entity\Quote;
|
||||||
use Gateway\QuoteGateway;
|
use Gateway\QuoteGateway;
|
||||||
use Gateway\Gateway;
|
use Gateway\Gateway;
|
||||||
use Enum\TypeSourceEnum;
|
|
||||||
|
|
||||||
class QuoteModel extends Model
|
class QuoteModel extends Model
|
||||||
{
|
{
|
||||||
|
|
||||||
public function searchId(int $id): Quote{
|
/**
|
||||||
|
* Searches for a quote by its unique identifier.
|
||||||
|
*
|
||||||
|
* @param int $id The unique identifier of the quote to search for.
|
||||||
|
*
|
||||||
|
* @return Quote Returns a Quote object. If no quote is found, returns a default Quote with an ID of -1 and default values.
|
||||||
|
*/
|
||||||
|
public function searchId(int $id): Quote {
|
||||||
|
// Fetch the quote data by ID using the gateway's searchId method.
|
||||||
$res = $this->gateway->searchId($id);
|
$res = $this->gateway->searchId($id);
|
||||||
if( count($res) == 0)
|
|
||||||
return new Quote(-1,"NULL","NULL","NULL","NULL","NULL",0,"Default");
|
// If no result is found, return a default Quote with an ID of -1 and placeholder values.
|
||||||
else
|
if (count($res) == 0) {
|
||||||
return new Quote($res[0]["id_quote"],$res[0]["content"],$res[0]["caracter"],$res[0]["imgpath"],$res[0]["title"],$res[0]["dates"],$res[0]["likes"],$res[0]["langue"],TypeSourceEnum::Movie);
|
return new Quote(-1, "NULL", "NULL", "NULL", "NULL", "NULL", 0, "Default");
|
||||||
|
} else {
|
||||||
|
// Otherwise, return the Quote object populated with data from the search result.
|
||||||
|
return new Quote(
|
||||||
|
$res[0]["id_quote"], // Quote ID
|
||||||
|
$res[0]["content"], // Quote content
|
||||||
|
$res[0]["caracter"], // Character associated with the quote
|
||||||
|
$res[0]["imgpath"], // Image path (associated with the quote or character)
|
||||||
|
$res[0]["title"], // Title of the quote
|
||||||
|
$res[0]["dates"], // Date the quote was created
|
||||||
|
$res[0]["likes"], // Number of likes for the quote
|
||||||
|
$res[0]["langue"] // Language of the quote
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSuggest(int $numpage, string $language):array{
|
/**
|
||||||
$res = $this->gateway->getSuggestions($numpage,$language);
|
* Retrieves suggestions for quotes based on the specified page number and language.
|
||||||
$tabQ=[];
|
*
|
||||||
|
* @param int $numpage The page number for pagination.
|
||||||
|
* @param string $language The language to filter the suggestions by.
|
||||||
|
*
|
||||||
|
* @return Quote[] Returns an array of Quote objects representing the suggested quotes.
|
||||||
|
*/
|
||||||
|
public function getSuggest(int $numpage, string $language): array {
|
||||||
|
// Fetch suggestions from the gateway's getSuggestions method.
|
||||||
|
$res = $this->gateway->getSuggestions($numpage, $language);
|
||||||
|
|
||||||
|
// Initialize an empty array to store the resulting Quote objects.
|
||||||
|
$tabQ = [];
|
||||||
|
|
||||||
foreach($res as $q ){
|
// Loop through the result set and create Quote objects.
|
||||||
$q["content"] = (strlen($q["content"]) > 153) ? substr($q["content"],0,150).'...' : $q["content"];
|
foreach ($res as $q) {
|
||||||
$tabQ[]= new Quote($q["id_quote"],$q["content"],$q["caracter"],$q["imgpath"],$q["title"],$q["dates"],$q["likes"],$q["langue"],TypeSourceEnum::Movie) ;
|
// Truncate the content if it's longer than 153 characters, appending '...' if necessary.
|
||||||
|
$q["content"] = (strlen($q["content"]) > 153) ? substr($q["content"], 0, 150) . '...' : $q["content"];
|
||||||
|
|
||||||
|
// Create a new Quote object and add it to the tabQ array.
|
||||||
|
$tabQ[] = new Quote(
|
||||||
|
$q["id_quote"], // Quote ID
|
||||||
|
$q["content"], // Truncated content of the quote
|
||||||
|
$q["caracter"], // Character associated with the quote
|
||||||
|
$q["imgpath"], // Image path related to the quote
|
||||||
|
$q["title"], // Title of the quote
|
||||||
|
$q["dates"], // Date the quote was created
|
||||||
|
$q["likes"], // Number of likes the quote has received
|
||||||
|
$q["langue"] // Language of the quote
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the array of Quote objects.
|
||||||
return $tabQ;
|
return $tabQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQuoteOfTheDay(string $language):Quote{
|
/**
|
||||||
|
* Retrieves the quote of the day for a specified language.
|
||||||
|
*
|
||||||
|
* @param string $language The language to filter the quote of the day by.
|
||||||
|
*
|
||||||
|
* @return Quote Returns the Quote of the Day. If no quote is found, returns a default Quote with an ID of -1 and default values.
|
||||||
|
*/
|
||||||
|
public function getQuoteOfTheDay(string $language): Quote {
|
||||||
|
// Fetch the quote of the day from the gateway's getQuoteOfTheDay method.
|
||||||
$res = $this->gateway->getQuoteOfTheDay($language);
|
$res = $this->gateway->getQuoteOfTheDay($language);
|
||||||
if( count($res) == 0)
|
|
||||||
return new Quote(-1,"NULL","NULL","NULL","NULL","NULL",0,"Default",TypeSourceEnum::Movie);
|
// If no result is found, return a default Quote with an ID of -1 and placeholder values.
|
||||||
else
|
if (count($res) == 0) {
|
||||||
$res["content"] = (strlen($res["content"]) > 153) ? substr($res["content"],0,150).'...' : $res["content"];
|
return new Quote(-1, "NULL", "NULL", "NULL", "NULL", "NULL", 0, "Default");
|
||||||
return new Quote($res["id_quote"],$res["content"],$res["caracter"],$res["imgpath"],$res["title"],$res["dates"],$res["likes"],$res["langue"],TypeSourceEnum::Movie) ;
|
} else {
|
||||||
|
// Truncate the content if it's longer than 153 characters, appending '...' if necessary.
|
||||||
|
$res["content"] = (strlen($res["content"]) > 153) ? substr($res["content"], 0, 150) . '...' : $res["content"];
|
||||||
|
|
||||||
|
// Return the Quote object populated with data from the quote of the day.
|
||||||
|
return new Quote(
|
||||||
|
$res["id_quote"], // Quote ID
|
||||||
|
$res["content"], // Truncated content of the quote
|
||||||
|
$res["caracter"], // Character associated with the quote
|
||||||
|
$res["imgpath"], // Image path associated with the quote
|
||||||
|
$res["title"], // Title of the quote
|
||||||
|
$res["dates"], // Date the quote was created
|
||||||
|
$res["likes"], // Number of likes the quote has received
|
||||||
|
$res["langue"] // Language of the quote
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all favorite quotes for a specified user.
|
||||||
|
*
|
||||||
|
* @param string $userId The unique identifier of the user.
|
||||||
|
*
|
||||||
|
* @return Quote[] Returns an array of Quote objects representing the user's favorite quotes.
|
||||||
|
*/
|
||||||
public function getFavorites(string $userId): array {
|
public function getFavorites(string $userId): array {
|
||||||
|
// Fetch the user's favorite quotes from the gateway's getFavorites method.
|
||||||
$res = $this->gateway->getFavorites($userId);
|
$res = $this->gateway->getFavorites($userId);
|
||||||
$tabQ=[];
|
|
||||||
|
|
||||||
foreach($res as $q ){
|
// Initialize an empty array to store the resulting Quote objects.
|
||||||
$q["content"] = (strlen($q["content"]) > 153) ? substr($q["content"],0,150).'...' : $q["content"];
|
$tabQ = [];
|
||||||
$tabQ[]= new Quote($q["id_quote"],$q["content"],$q["caracter"],$q["imgpath"],$q["title"],$q["dates"],$q["likes"],$q["langue"],TypeSourceEnum::Movie) ;
|
|
||||||
|
// Loop through the result set and create Quote objects.
|
||||||
|
foreach ($res as $q) {
|
||||||
|
// Truncate the content if it's longer than 153 characters, appending '...' if necessary.
|
||||||
|
$q["content"] = (strlen($q["content"]) > 153) ? substr($q["content"], 0, 150) . '...' : $q["content"];
|
||||||
|
|
||||||
|
// Create a new Quote object and add it to the tabQ array.
|
||||||
|
$tabQ[] = new Quote(
|
||||||
|
$q["id_quote"], // Quote ID
|
||||||
|
$q["content"], // Truncated content of the quote
|
||||||
|
$q["caracter"], // Character associated with the quote
|
||||||
|
$q["imgpath"], // Image path related to the quote
|
||||||
|
$q["title"], // Title of the quote
|
||||||
|
$q["dates"], // Date the quote was created
|
||||||
|
$q["likes"], // Number of likes the quote has received
|
||||||
|
$q["langue"] // Language of the quote
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the array of favorite Quote objects.
|
||||||
return $tabQ;
|
return $tabQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addQuote(string $content, string $lang, int $idChar, int $idSrc, int $idUsr){
|
/**
|
||||||
$this -> gateway -> addQuote($content,$lang,$idChar,$idSrc,$idUsr);
|
* Inserts a new quote for a specific user.
|
||||||
|
*
|
||||||
|
* @param string $content The content of the quote.
|
||||||
|
* @param string $img_path The image path associated with the quote.
|
||||||
|
* @param string $langage The language of the quote.
|
||||||
|
* @param int $user The ID of the user associated with the quote.
|
||||||
|
* @param int $source The source of the quote (e.g., the origin of the quote or where it was sourced from).
|
||||||
|
* @param int $character The character associated with the quote.
|
||||||
|
*
|
||||||
|
* @return bool Returns true if the quote was successfully inserted, otherwise false.
|
||||||
|
*/
|
||||||
|
public function insert4User(string $content, string $img_path, string $langage, int $user, int $source, int $character): bool {
|
||||||
|
// Call the gateway's insert4User method to insert the new quote into the database.
|
||||||
|
return $this->gateway->insert4User($content, $img_path, $langage, $user, $source, $character);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -1,91 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Model;
|
|
||||||
|
|
||||||
use Entity\ResultsEntity;
|
|
||||||
use Gateway\ResultsGateway;
|
|
||||||
use Gateway\Gateway;
|
|
||||||
|
|
||||||
class ResultsModel extends Model
|
|
||||||
{
|
|
||||||
|
|
||||||
public function createResultsModel(int $idQuiz, int $idUser, int $score, int $time) : bool
|
|
||||||
{
|
|
||||||
return $this -> gateway -> createResultsGateway($idQuiz, $idUser, $score, $time);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResultsByQuiz(int $idQuiz) : array
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findResultsByQuiz($idQuiz);
|
|
||||||
|
|
||||||
$results = [];
|
|
||||||
|
|
||||||
foreach ($res as $result)
|
|
||||||
{
|
|
||||||
$results[] = new ResultsEntity (
|
|
||||||
$result['user_r'],
|
|
||||||
$result['quiz_r'],
|
|
||||||
$result['score'],
|
|
||||||
$result['time']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResultsByUser(int $idUser) : array
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findResultsByUser($idUser);
|
|
||||||
|
|
||||||
$results = [];
|
|
||||||
|
|
||||||
foreach ($res as $result)
|
|
||||||
{
|
|
||||||
$results[] = new ResultsEntity (
|
|
||||||
$result['user_r'],
|
|
||||||
$result['quiz_r'],
|
|
||||||
$result['score'],
|
|
||||||
$result['time']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResultsById(int $idQuiz, int $idUser) : ?ResultsEntity
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findResultsById($idQuiz, $idUser);
|
|
||||||
|
|
||||||
if ($res)
|
|
||||||
{
|
|
||||||
return new ResultsEntity (
|
|
||||||
$res['user_r'],
|
|
||||||
$res['quiz_r'],
|
|
||||||
$res['score'],
|
|
||||||
$res['time']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAllResults() : array
|
|
||||||
{
|
|
||||||
$res = $this -> gateway -> findAllResults();
|
|
||||||
|
|
||||||
$results = [];
|
|
||||||
|
|
||||||
foreach ($res as $result)
|
|
||||||
{
|
|
||||||
$results[] = new ResultsEntity (
|
|
||||||
$result['user_r'],
|
|
||||||
$result['quiz_r'],
|
|
||||||
$result['score'],
|
|
||||||
$result['time']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateResultsModel(int $idQuiz, int $idUser, ?int $score, ?int $time) : bool
|
|
||||||
{
|
|
||||||
return $this -> gateway -> updateResults($idQuiz, $idUser, $score, $time);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,112 +1,126 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Model;
|
namespace Model;
|
||||||
use Entity\SourceEntity;
|
use Entity\SourceEntity;
|
||||||
use Enum\TypeSourceEnum;
|
use Enum\TypeSourceEnum;
|
||||||
|
|
||||||
|
|
||||||
class SourceModel extends Model
|
class SourceModel extends Model
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new source with the provided title, date, and type.
|
||||||
|
*
|
||||||
|
* @param string $title The title of the source.
|
||||||
|
* @param string $date The date associated with the source.
|
||||||
|
* @param TypeSourceEnum $type The type of the source (e.g., Movie, Book, etc.).
|
||||||
|
*
|
||||||
|
* @return bool Returns true if the source was successfully created, false otherwise.
|
||||||
|
*/
|
||||||
public function createSource(string $title, string $date, TypeSourceEnum $type) : bool
|
public function createSource(string $title, string $date, TypeSourceEnum $type) : bool
|
||||||
{
|
{
|
||||||
$id = $this -> gateway -> getLastId();
|
// Create a new SourceEntity with the given title, date, and type.
|
||||||
$q = new SourceEntity($id,$title, $date, $type);
|
// Note: The type is hardcoded as "Movie" in this implementation.
|
||||||
return $this -> gateway -> create($q);
|
$q = new SourceEntity(-1, $title, $date, TypeSourceEnum::Movie);
|
||||||
|
|
||||||
|
// Use the gateway to insert the new source and return the result.
|
||||||
|
return $this->gateway->create($q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a source by its unique identifier.
|
||||||
|
*
|
||||||
|
* @param int $id_source The unique identifier of the source.
|
||||||
|
*
|
||||||
|
* @return SourceEntity|null Returns a SourceEntity object if found, or null if no source is found with the given ID.
|
||||||
|
*/
|
||||||
public function getSourceById(int $id_source) : ?SourceEntity
|
public function getSourceById(int $id_source) : ?SourceEntity
|
||||||
{
|
{
|
||||||
$res = $this -> gateway -> findById($id_source);
|
// Fetch the source by ID using the gateway's findById method.
|
||||||
|
$res = $this->gateway->findById($id_source);
|
||||||
if ($res)
|
|
||||||
return new sourceEntity(
|
// If a source is found, return a SourceEntity object.
|
||||||
$res[0]["id_source"],
|
if ($res) {
|
||||||
$res[0]["title"],
|
return new SourceEntity(
|
||||||
$res[0]["dates"],
|
$res[0]["id_source"], // Source ID
|
||||||
TypeSourceEnum::Movie//from($res[0]["type"])
|
$res[0]["title"], // Title of the source
|
||||||
|
$res[0]["dates"], // Date associated with the source
|
||||||
|
TypeSourceEnum::Movie // Hardcoded to "Movie" type; you may consider dynamically mapping this
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
// Return null if no source is found.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a source by its title.
|
||||||
|
*
|
||||||
|
* @param string $title The title of the source to search for.
|
||||||
|
*
|
||||||
|
* @return SourceEntity|null Returns a SourceEntity object if found, or null if no source is found with the given title.
|
||||||
|
*/
|
||||||
public function getSourceByTitle(string $title) : ?SourceEntity
|
public function getSourceByTitle(string $title) : ?SourceEntity
|
||||||
{
|
{
|
||||||
|
// Fetch the source by title using the gateway's findByTitle method.
|
||||||
$res = $this->gateway->findByTitle($title);
|
$res = $this->gateway->findByTitle($title);
|
||||||
if ($res)
|
|
||||||
return new sourceEntity(
|
|
||||||
$res[0]["id_source"],
|
|
||||||
$res[0]["title"],
|
|
||||||
$res[0]["dates"],
|
|
||||||
TypeSourceEnum::Movie//from($res[0]["type"])
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSourceByDate(string $date) : array
|
// If a source is found, return a SourceEntity object.
|
||||||
{
|
if ($res) {
|
||||||
$res = $this->gateway->findByDate($date);
|
return new SourceEntity(
|
||||||
$src = [];
|
$res[0]["id_source"], // Source ID
|
||||||
foreach ($res as $sources) {
|
$res[0]["title"], // Title of the source
|
||||||
$src[] = new sourceEntity(
|
$res[0]["dates"], // Date associated with the source
|
||||||
$sources["id_source"],
|
TypeSourceEnum::Movie // Hardcoded to "Movie" type; dynamic mapping could be considered
|
||||||
$sources["title"],
|
|
||||||
$sources["dates"],
|
|
||||||
TypeSourceEnum::from($sources["type"])
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $src;
|
// Return null if no source is found.
|
||||||
}
|
return null;
|
||||||
|
|
||||||
public function getSourceByType(TypeSourceEnum $type) : array
|
|
||||||
{
|
|
||||||
$res = $this->gateway->findByType($type);
|
|
||||||
$src = [];
|
|
||||||
foreach ($res as $sources) {
|
|
||||||
$src[] = new sourceEntity(
|
|
||||||
$sources["id_source"],
|
|
||||||
$sources["title"],
|
|
||||||
$sources["dates"],
|
|
||||||
TypeSourceEnum::from($sources["type"])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $src;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all sources from the database.
|
||||||
|
*
|
||||||
|
* @return SourceEntity[] Returns an array of SourceEntity objects representing all the sources.
|
||||||
|
*/
|
||||||
public function getAllSources() : array
|
public function getAllSources() : array
|
||||||
{
|
{
|
||||||
$res = $this -> gateway -> findAll();
|
// Fetch all sources from the gateway's findAll method.
|
||||||
|
$res = $this->gateway->findAll();
|
||||||
|
|
||||||
|
// Initialize an empty array to store the SourceEntity objects.
|
||||||
$src = [];
|
$src = [];
|
||||||
|
|
||||||
|
// Loop through the result and create a SourceEntity object for each source.
|
||||||
foreach ($res as $sources) {
|
foreach ($res as $sources) {
|
||||||
$src[] = new SourceEntity(
|
$src[] = new SourceEntity(
|
||||||
$sources["id_source"],
|
$sources["id_source"], // Source ID
|
||||||
$sources["title"],
|
$sources["title"], // Title of the source
|
||||||
$sources["dates"],
|
$sources["dates"], // Date associated with the source
|
||||||
TypeSourceEnum::Movie
|
TypeSourceEnum::Movie // Hardcoded to "Movie" type; you may consider dynamically mapping this
|
||||||
//TypeSourceEnum::from($sources["type"])
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $src;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteSource(int $id_source) : bool
|
// Return the array of SourceEntity objects.
|
||||||
{
|
return $src;
|
||||||
return $this -> gateway -> delete($id_source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateSource(int $id_source, string $title, string $date) : bool
|
/**
|
||||||
|
* Checks if a source with the given name and type exists.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the source to check.
|
||||||
|
* @param string $type The type of the source to check (e.g., Movie, Book, etc.).
|
||||||
|
*
|
||||||
|
* @return bool Returns true if the source exists, false otherwise.
|
||||||
|
*/
|
||||||
|
public function existSource(string $name, string $type) : bool
|
||||||
{
|
{
|
||||||
$q = $this -> getSourceById($id_source);
|
// Retrieve the source by title using the getSourceByTitle method.
|
||||||
|
$q = $this->getSourceByTitle($name);
|
||||||
|
|
||||||
if ($q){
|
// Check if the source exists and return the result.
|
||||||
$q -> setTitle($title);
|
return isset($q[0]);
|
||||||
$q -> setDate($date);
|
|
||||||
return $this -> gateway -> update($q);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function existSource(string $name, string $type) : bool{
|
|
||||||
$q = $this -> getSourceByTitle($name);
|
|
||||||
return isset($q);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
?>
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
global $twig;
|
|
||||||
|
|
||||||
|
|
||||||
echo $twig->render('head.html.twig', [
|
|
||||||
'title' => "Quiz",
|
|
||||||
'style' => "public/styles/styleAccueilQuiz.css",
|
|
||||||
'scripts' => array("public/script/theme-toggle.js")
|
|
||||||
]);
|
|
||||||
|
|
||||||
echo $twig->render('bandeau.html.twig');
|
|
||||||
|
|
||||||
echo $twig->render('accueilQuiz.html.twig', [
|
|
||||||
'quizs' => $quizs
|
|
||||||
]);
|
|
||||||
?>
|
|
@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
global $twig;
|
|
||||||
|
|
||||||
|
|
||||||
echo $twig->render('head.html.twig', [
|
|
||||||
'title' => "Quiz",
|
|
||||||
'style' => "public/styles/styleEndQuiz.css",
|
|
||||||
'scripts' => array("public/script/theme-toggle.js")
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Rendu du bandeau
|
|
||||||
echo $twig->render('bandeau.html.twig');
|
|
||||||
|
|
||||||
echo $twig->render('endQuizRandom.html.twig',
|
|
||||||
['score' => $score
|
|
||||||
]);
|
|
||||||
?>
|
|
@ -1,25 +1,5 @@
|
|||||||
|
<h1>
|
||||||
<?php
|
<?php
|
||||||
global $twig;
|
echo "ERREUR";
|
||||||
|
?>
|
||||||
if(!isset($erreur[2])){
|
</h1>
|
||||||
echo $twig->render('head.html.twig', [
|
|
||||||
'title' => "Accueil",
|
|
||||||
'style' => "public/styles/style.css",
|
|
||||||
'scripts' => array("public/script/theme-toggle.js")
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
echo $twig->render('head.html.twig', array(
|
|
||||||
'title' => "Quote",
|
|
||||||
'style' => "../public/styles/styleQuote.css",
|
|
||||||
'scripts' => array("../public/script/theme-toggle-double-param.js", "../public/script/copy.js")
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rendu du bandeau
|
|
||||||
echo $twig->render('bandeau.html.twig');
|
|
||||||
|
|
||||||
echo $twig->render('erreur.html.twig',[
|
|
||||||
'numero' => $erreur[0],
|
|
||||||
'context' => $erreur[1],
|
|
||||||
]);
|
|
@ -1,18 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
global $twig;
|
global $twig;
|
||||||
|
|
||||||
|
|
||||||
echo $twig->render('head.html.twig', [
|
echo $twig->render('head.html.twig', [
|
||||||
'title' => "Quiz",
|
'title' => "Quiz",
|
||||||
'style' => "../public/styles/styleQuiz.css",
|
'style' => "../public/styles/styleQuiz.css",
|
||||||
'scripts' => array("../public/script/theme-toggle-double-param.js")
|
'scripts' => array("../public/script/theme-toggle-double-param.js")
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
// Rendu du bandeau
|
// Rendu du bandeau
|
||||||
echo $twig->render('bandeau.html.twig');
|
echo $twig->render('bandeau.html.twig');
|
||||||
|
|
||||||
echo $twig->render('quiz.html.twig', [
|
echo $twig->render('quiz.html.twig', ['idQuiz'=>$id , 'question' => $question,'id'=>$idquestion]);
|
||||||
'question' => $question,
|
?>
|
||||||
'id'=>$idquestion,
|
|
||||||
'nb' => $num + 1,
|
|
||||||
'nbFinal' => $nbQuestion
|
|
||||||
]);
|
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
global $twig;
|
|
||||||
|
|
||||||
echo $twig->render('head.html.twig', [
|
|
||||||
'title' => "Random Quiz",
|
|
||||||
'style' => "public/styles/styleQuiz.css",
|
|
||||||
'scripts' => array("public/script/theme-toggle.js")
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Rendu du bandeau
|
|
||||||
echo $twig->render('bandeau.html.twig');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo $twig->render('quizRandom.html.twig', [
|
|
||||||
'vie' => $vie,
|
|
||||||
'question' => $question,
|
|
||||||
'nb' => $no_question + 1
|
|
||||||
]);
|
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
global $twig;
|
|
||||||
|
|
||||||
echo $twig->render('head.html.twig', array(
|
|
||||||
'title' => "Recap Quote",
|
|
||||||
'style' => "public/styles/styleSubmitQuote.css",
|
|
||||||
'scripts' => array("public/script/theme-toggle.js")
|
|
||||||
));
|
|
||||||
echo $twig->render('bandeau.html.twig');
|
|
||||||
echo $twig -> render("recapSubmitQuote.html.twig", [
|
|
||||||
'content' => $recap["content"],
|
|
||||||
'character' => $recap["character"],
|
|
||||||
'source' => $recap["src"]
|
|
||||||
]);
|
|
||||||
?>
|
|
@ -1,26 +0,0 @@
|
|||||||
<h2>Liste des Quiz</h2>
|
|
||||||
<div class="quiz-container">
|
|
||||||
|
|
||||||
<div class="quizCard">
|
|
||||||
<a href="{{ racine }}/randomQuiz" class="linkQuiz">
|
|
||||||
<img src="{{ racine }}/images/quizz.svg" alt="Image du quiz random">
|
|
||||||
<h3>Quiz random </h3>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% for quiz in quizs %}
|
|
||||||
<div class="quizCard">
|
|
||||||
<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>
|
|
||||||
{% else %}
|
|
||||||
<h3>Aucun quiz disponible pour le moment.</h3>
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,13 +1,10 @@
|
|||||||
<h1>Résultat</h1>
|
<h1>Résultat</h1>
|
||||||
<div class="resultat">
|
<div class="resultat">
|
||||||
<p> nombre de réponse juste : {{ score }}</p>
|
<p> nombre de réponse juste : {{ score }}</p>
|
||||||
<p> nombre de réponse fausse : {{ nb - score }}</p>
|
<p> nombre de réponse fausse : {{ 10 - score }}</p>
|
||||||
<p> pourcentage de réusite : {{ (100 * score) / nb }}%<p>
|
<a class="suiv" href="{{racine}}/quiz/{{ nextquiz }}" alt="quiz suivant">
|
||||||
|
|
||||||
<a class="suiv" href="{{racine}}/accueilQuiz" alt="Retour selection quiz">
|
|
||||||
<img src="../images/suivant.png" />
|
<img src="../images/suivant.png" />
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
<h1>Résultat</h1>
|
|
||||||
<div class="resultat">
|
|
||||||
|
|
||||||
<p> nombre de réponse juste : {{ score }}</p>
|
|
||||||
|
|
||||||
<a class="suiv" href="{{racine}}/accueilQuiz" alt="Retour selection quiz">
|
|
||||||
<img src="images/suivant.png" />
|
|
||||||
</a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,4 +0,0 @@
|
|||||||
<h1 class='error'>Erreur</h1>
|
|
||||||
<p class="explanation">Erreur {{numero}} : {{context}}</p>
|
|
||||||
<body>
|
|
||||||
<html>
|
|
@ -0,0 +1,9 @@
|
|||||||
|
<div class="citation-container suggestion">
|
||||||
|
<img src="{{ imagePath }}" alt="{{ movie }}" class="citation-image">
|
||||||
|
<div class="text-content">
|
||||||
|
<p class="quote">"{{ quote }}"</p>
|
||||||
|
<p class="movie">- {{ movie }}</p>
|
||||||
|
<p class="character">Personnage : {{ character }}</p>
|
||||||
|
<p class="year">Année : {{ year }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -1,25 +1,25 @@
|
|||||||
<h1>Quiz</h1>
|
<h1>Quiz</h1>
|
||||||
<div class="quiz">
|
<div class="quiz">
|
||||||
<h2> {{ question.question }} </h2>
|
<h2> {{ question.question }} </h2>
|
||||||
|
{#<a id="timer"> 10 seconds left .. </a>#}
|
||||||
|
|
||||||
<form id="quizForm" method="POST" >
|
<form id="quizForm" method="POST" >
|
||||||
<div class="answers">
|
<div class="answers">
|
||||||
<button class="answer" name="answera" value="{{ question.answera }}-{{ id }}">
|
<button class="answer" name="answera" value="A-{{ id }}">
|
||||||
{{ question.answera }}
|
{{ question.answera }}
|
||||||
</button>
|
</button>
|
||||||
<button class="answer" name="answerb" value="{{ question.answerb }}-{{ id }}">
|
<button class="answer" name="answerb" value="B-{{ id }}">
|
||||||
{{ question.answerb }}
|
{{ question.answerb }}
|
||||||
</button>
|
</button>
|
||||||
<button class="answer" name="answerc" value="{{ question.answerc }}-{{ id }}">
|
<button class="answer" name="answerc" value="C-{{ id }}">
|
||||||
{{ question.answerc }}
|
{{ question.answerc }}
|
||||||
</button>
|
</button>
|
||||||
<button class="answer" name="answerd" value="{{ question.answerd }}-{{ id }}">
|
<button class="answer" name="answerd" value="D-{{ id }}">
|
||||||
{{ question.answerd }}
|
{{ question.answerd }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="action" value="canswer">
|
<input type="hidden" name="action" value="canswer">
|
||||||
</form>
|
</form>
|
||||||
<a id="timer">{{ nb }}/{{ nbFinal }}</a>
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
<h1>Quiz Random</h1>
|
|
||||||
<div class="quiz">
|
|
||||||
<h2> {{ question.question }} </h2>
|
|
||||||
|
|
||||||
<h3>Vie restante : {{ vie }}</h3>
|
|
||||||
|
|
||||||
<form id="quizForm" method="POST" >
|
|
||||||
<div class="answers">
|
|
||||||
<button class="answer" name="answera" value="{{ question.answera }}">
|
|
||||||
{{ question.answera }}
|
|
||||||
</button>
|
|
||||||
<button class="answer" name="answerb" value="{{ question.answerb }}">
|
|
||||||
{{ question.answerb }}
|
|
||||||
</button>
|
|
||||||
<button class="answer" name="answerc" value="{{ question.answerc }}">
|
|
||||||
{{ question.answerc }}
|
|
||||||
</button>
|
|
||||||
<button class="answer" name="answerd" value="{{ question.answerd }}">
|
|
||||||
{{ question.answerd }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<input type="hidden" name="canswer" value="{{ question.canswer }}">
|
|
||||||
</form>
|
|
||||||
<a id="timer">{{ nb }}/∞</a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|