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
|
||||
|
||||
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/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# WikiFantasyWeb
|
||||
|
||||
|
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);
|
||||
|
||||
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;
|
||||
}
|
||||
@import url(./style.css); /* Import de style.css */
|
@ -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,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
|
||||
|
||||
namespace Model;
|
||||
use Entity\CommentaryEntity;
|
||||
use Gateway\CommentaryGateway;
|
||||
use Gateway\Gateway;
|
||||
|
||||
|
||||
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 {
|
||||
// Calls the gateway's create method to insert the new comment into the data source.
|
||||
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 {
|
||||
// Initialize an empty array to store the comment objects.
|
||||
$com = [];
|
||||
|
||||
// Fetch all comments related to the given quote ID using the gateway's findByQuote method.
|
||||
$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 {
|
||||
$res = $this->gateway->findAll();
|
||||
// Loop through each comment in the result and create a CommentaryEntity object for each.
|
||||
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 the array of CommentaryEntity objects.
|
||||
return $com;
|
||||
}
|
||||
|
||||
public function deleteComment(int $id_comment): bool {
|
||||
return $this -> gateway -> delete($id_comment);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
namespace Model;
|
||||
|
||||
use Entity\ImageEntity;
|
||||
use Gateway\ImageGateway;
|
||||
use Gateway\Gateway;
|
||||
|
||||
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
|
||||
class ImageModel extends Model
|
||||
{
|
||||
$res = $this -> gateway -> findImgById($idImg);
|
||||
|
||||
if ($res)
|
||||
{
|
||||
return new ImageEntity(
|
||||
$res[0]['id_img'],
|
||||
$res[0]['imgpath']
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAllImg() : array
|
||||
{
|
||||
/**
|
||||
* Retrieves all images from the database.
|
||||
*
|
||||
* @return ImageEntity[] Returns an array of ImageEntity objects representing all the images.
|
||||
*/
|
||||
public function getAllImg() : array {
|
||||
// Fetch all images using the gateway's findAllImg method.
|
||||
$res = $this->gateway->findAllImg();
|
||||
|
||||
// Initialize an empty array to store the ImageEntity objects.
|
||||
$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(
|
||||
$img['id_img'],
|
||||
$img['imgpath']
|
||||
$img['id_img'], // Image ID
|
||||
$img['imgpath'] // Image path (location or URL of the image)
|
||||
);
|
||||
}
|
||||
|
||||
// Return the array of ImageEntity objects.
|
||||
return $images;
|
||||
}
|
||||
|
||||
|
||||
public function deleteImgModel(int $idImg) : bool
|
||||
{
|
||||
return $this -> gateway -> deleteImgGateway($idImg);
|
||||
}
|
||||
|
||||
public function updateImgModel(int $idImg, string $imgPath) : bool
|
||||
{
|
||||
return $this -> gateway -> updateImgGateway($idImg, $imgPath);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,53 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Model;
|
||||
|
||||
use Entity\QuizEntity;
|
||||
use Entity\quizEntity;
|
||||
use Gateway\QuizGateway;
|
||||
use Gateway\Gateway;
|
||||
|
||||
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);
|
||||
}
|
||||
class QuizModel extends Model{
|
||||
|
||||
public function getQuiz(int $id_quiz): ?QuizEntity
|
||||
{
|
||||
/**
|
||||
* Retrieves a quiz by its unique identifier.
|
||||
*
|
||||
* @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) {
|
||||
return new QuizEntity(
|
||||
$q[0]['id_quiz'],
|
||||
$q[0]['nb_quest'],
|
||||
$q[0]['imgpath'],
|
||||
$q[0]['title']
|
||||
return new quizEntity(
|
||||
$q[0]['id_quiz'], // Quiz ID
|
||||
$q[0]['nb_quest'] // The number of questions in the quiz
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function deleteQuiz(int $id_quiz) : bool
|
||||
{
|
||||
return $this -> gateway -> delete($id_quiz);
|
||||
// If no quiz is found, return null.
|
||||
return null;
|
||||
}
|
||||
|
||||
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']
|
||||
/**
|
||||
* Retrieves all quizzes from the database.
|
||||
*
|
||||
* @return quizEntity[] Returns an array of quizEntity objects representing all the quizzes.
|
||||
*/
|
||||
public function getAllQuiz() : array{
|
||||
// Fetch all quizzes using the gateway's findAll method.
|
||||
$q = $this->gateway->findAll();
|
||||
|
||||
// Initialize an empty array to store the quiz objects.
|
||||
$quizzes = [];
|
||||
|
||||
// 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
|
||||
|
||||
namespace Model;
|
||||
use Entity\Quote;
|
||||
use Gateway\QuoteGateway;
|
||||
use Gateway\Gateway;
|
||||
use Enum\TypeSourceEnum;
|
||||
|
||||
class QuoteModel extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* 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);
|
||||
if( count($res) == 0)
|
||||
|
||||
// If no result is found, return a default Quote with an ID of -1 and placeholder values.
|
||||
if (count($res) == 0) {
|
||||
return new Quote(-1, "NULL", "NULL", "NULL", "NULL", "NULL", 0, "Default");
|
||||
else
|
||||
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);
|
||||
} 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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves suggestions for quotes based on the specified page number and language.
|
||||
*
|
||||
* @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 = [];
|
||||
|
||||
// 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"];
|
||||
$tabQ[]= new Quote($q["id_quote"],$q["content"],$q["caracter"],$q["imgpath"],$q["title"],$q["dates"],$q["likes"],$q["langue"],TypeSourceEnum::Movie) ;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
if( count($res) == 0)
|
||||
return new Quote(-1,"NULL","NULL","NULL","NULL","NULL",0,"Default",TypeSourceEnum::Movie);
|
||||
else
|
||||
|
||||
// If no result is found, return a default Quote with an ID of -1 and placeholder values.
|
||||
if (count($res) == 0) {
|
||||
return new Quote(-1, "NULL", "NULL", "NULL", "NULL", "NULL", 0, "Default");
|
||||
} 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 new Quote($res["id_quote"],$res["content"],$res["caracter"],$res["imgpath"],$res["title"],$res["dates"],$res["likes"],$res["langue"],TypeSourceEnum::Movie) ;
|
||||
|
||||
// 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 {
|
||||
// Fetch the user's favorite quotes from the gateway's getFavorites method.
|
||||
$res = $this->gateway->getFavorites($userId);
|
||||
|
||||
// Initialize an empty array to store the resulting Quote objects.
|
||||
$tabQ = [];
|
||||
|
||||
// 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"];
|
||||
$tabQ[]= new Quote($q["id_quote"],$q["content"],$q["caracter"],$q["imgpath"],$q["title"],$q["dates"],$q["likes"],$q["langue"],TypeSourceEnum::Movie) ;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
namespace Model;
|
||||
use Entity\SourceEntity;
|
||||
use Enum\TypeSourceEnum;
|
||||
|
||||
|
||||
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
|
||||
{
|
||||
$id = $this -> gateway -> getLastId();
|
||||
$q = new SourceEntity($id,$title, $date, $type);
|
||||
return $this -> gateway -> create($q);
|
||||
// Create a new SourceEntity with the given title, date, and type.
|
||||
// Note: The type is hardcoded as "Movie" in this implementation.
|
||||
$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
|
||||
{
|
||||
// Fetch the source by ID using the gateway's findById method.
|
||||
$res = $this->gateway->findById($id_source);
|
||||
|
||||
if ($res)
|
||||
return new sourceEntity(
|
||||
$res[0]["id_source"],
|
||||
$res[0]["title"],
|
||||
$res[0]["dates"],
|
||||
TypeSourceEnum::Movie//from($res[0]["type"])
|
||||
// If a source is found, return a SourceEntity object.
|
||||
if ($res) {
|
||||
return new SourceEntity(
|
||||
$res[0]["id_source"], // Source ID
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
// Fetch the source by title using the gateway's findByTitle method.
|
||||
$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
|
||||
{
|
||||
$res = $this->gateway->findByDate($date);
|
||||
$src = [];
|
||||
foreach ($res as $sources) {
|
||||
$src[] = new sourceEntity(
|
||||
$sources["id_source"],
|
||||
$sources["title"],
|
||||
$sources["dates"],
|
||||
TypeSourceEnum::from($sources["type"])
|
||||
// If a source is found, return a SourceEntity object.
|
||||
if ($res) {
|
||||
return new SourceEntity(
|
||||
$res[0]["id_source"], // Source ID
|
||||
$res[0]["title"], // Title of the source
|
||||
$res[0]["dates"], // Date associated with the source
|
||||
TypeSourceEnum::Movie // Hardcoded to "Movie" type; dynamic mapping could be considered
|
||||
);
|
||||
}
|
||||
return $src;
|
||||
}
|
||||
|
||||
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;
|
||||
// Return null if no source is found.
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all sources from the database.
|
||||
*
|
||||
* @return SourceEntity[] Returns an array of SourceEntity objects representing all the sources.
|
||||
*/
|
||||
public function getAllSources() : array
|
||||
{
|
||||
// Fetch all sources from the gateway's findAll method.
|
||||
$res = $this->gateway->findAll();
|
||||
|
||||
// Initialize an empty array to store the SourceEntity objects.
|
||||
$src = [];
|
||||
|
||||
// Loop through the result and create a SourceEntity object for each source.
|
||||
foreach ($res as $sources) {
|
||||
$src[] = new SourceEntity(
|
||||
$sources["id_source"],
|
||||
$sources["title"],
|
||||
$sources["dates"],
|
||||
TypeSourceEnum::Movie
|
||||
//TypeSourceEnum::from($sources["type"])
|
||||
$sources["id_source"], // Source ID
|
||||
$sources["title"], // Title of the source
|
||||
$sources["dates"], // Date associated with the source
|
||||
TypeSourceEnum::Movie // Hardcoded to "Movie" type; you may consider dynamically mapping this
|
||||
);
|
||||
}
|
||||
return $src;
|
||||
}
|
||||
|
||||
public function deleteSource(int $id_source) : bool
|
||||
{
|
||||
return $this -> gateway -> delete($id_source);
|
||||
// Return the array of SourceEntity objects.
|
||||
return $src;
|
||||
}
|
||||
|
||||
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){
|
||||
$q -> setTitle($title);
|
||||
$q -> setDate($date);
|
||||
return $this -> gateway -> update($q);
|
||||
}
|
||||
return false;
|
||||
// Check if the source exists and return the result.
|
||||
return isset($q[0]);
|
||||
}
|
||||
|
||||
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
|
||||
global $twig;
|
||||
|
||||
if(!isset($erreur[2])){
|
||||
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],
|
||||
]);
|
||||
echo "ERREUR";
|
||||
?>
|
||||
</h1>
|
@ -1,18 +1,17 @@
|
||||
<?php
|
||||
global $twig;
|
||||
|
||||
|
||||
echo $twig->render('head.html.twig', [
|
||||
'title' => "Quiz",
|
||||
'style' => "../public/styles/styleQuiz.css",
|
||||
'scripts' => array("../public/script/theme-toggle-double-param.js")
|
||||
]);
|
||||
|
||||
|
||||
// Rendu du bandeau
|
||||
echo $twig->render('bandeau.html.twig');
|
||||
|
||||
echo $twig->render('quiz.html.twig', [
|
||||
'question' => $question,
|
||||
'id'=>$idquestion,
|
||||
'nb' => $num + 1,
|
||||
'nbFinal' => $nbQuestion
|
||||
]);
|
||||
echo $twig->render('quiz.html.twig', ['idQuiz'=>$id , 'question' => $question,'id'=>$idquestion]);
|
||||
?>
|
||||
|
||||
|
@ -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>
|
||||
<div class="resultat">
|
||||
<p> nombre de réponse juste : {{ score }}</p>
|
||||
<p> nombre de réponse fausse : {{ nb - score }}</p>
|
||||
<p> pourcentage de réusite : {{ (100 * score) / nb }}%<p>
|
||||
|
||||
<a class="suiv" href="{{racine}}/accueilQuiz" alt="Retour selection quiz">
|
||||
<p> nombre de réponse fausse : {{ 10 - score }}</p>
|
||||
<a class="suiv" href="{{racine}}/quiz/{{ nextquiz }}" alt="quiz suivant">
|
||||
<img src="../images/suivant.png" />
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</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>
|
||||
<div class="quiz">
|
||||
<h2> {{ question.question }} </h2>
|
||||
{#<a id="timer"> 10 seconds left .. </a>#}
|
||||
|
||||
<form id="quizForm" method="POST" >
|
||||
<div class="answers">
|
||||
<button class="answer" name="answera" value="{{ question.answera }}-{{ id }}">
|
||||
<button class="answer" name="answera" value="A-{{ id }}">
|
||||
{{ question.answera }}
|
||||
</button>
|
||||
<button class="answer" name="answerb" value="{{ question.answerb }}-{{ id }}">
|
||||
<button class="answer" name="answerb" value="B-{{ id }}">
|
||||
{{ question.answerb }}
|
||||
</button>
|
||||
<button class="answer" name="answerc" value="{{ question.answerc }}-{{ id }}">
|
||||
<button class="answer" name="answerc" value="C-{{ id }}">
|
||||
{{ question.answerc }}
|
||||
</button>
|
||||
<button class="answer" name="answerd" value="{{ question.answerd }}-{{ id }}">
|
||||
<button class="answer" name="answerd" value="D-{{ id }}">
|
||||
{{ question.answerd }}
|
||||
</button>
|
||||
</div>
|
||||
<input type="hidden" name="action" value="canswer">
|
||||
</form>
|
||||
<a id="timer">{{ nb }}/{{ nbFinal }}</a>
|
||||
</div>
|
||||
</body>
|
||||
</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>
|