reglement conflit

pull/21/head
kevin.modejar 5 months ago
commit 90cb24707a

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="dataSourceStorageLocal" created-in="PS-241.18034.69">
<data-source name="dbwikifantasy" uuid="351a7e7c-c4d1-4e89-bf03-667b32764270">
<database-info product="PostgreSQL" version="14.13 (Homebrew)" jdbc-version="4.2" driver-name="PostgreSQL JDBC Driver" driver-version="42.6.0" dbms="POSTGRES" exact-version="14.13" exact-driver-version="42.6">
<identifier-quote-string>&quot;</identifier-quote-string>
</database-info>
<case-sensitivity plain-identifiers="lower" quoted-identifiers="exact" />
<secret-storage>master_key</secret-storage>
<schema-mapping>
<introspection-scope>
<node kind="database" qname="@">
<node kind="schema" qname="@" />
</node>
</introspection-scope>
</schema-mapping>
</data-source>
</component>
</project>

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="dbwikifantasy" uuid="351a7e7c-c4d1-4e89-bf03-667b32764270">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://localhost:5432/dbwikifantasy</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

File diff suppressed because it is too large Load Diff

@ -3,7 +3,9 @@
<component name="MaterialThemeProjectNewConfig"> <component name="MaterialThemeProjectNewConfig">
<option name="metadata"> <option name="metadata">
<MTProjectMetadataState> <MTProjectMetadataState>
<option name="userId" value="5c5a39c9:192fb929d1e:-7ffa" /> <option name="migrated" value="true" />
<option name="pristineConfig" value="false" />
<option name="userId" value="-1562669c:19061473cbf:-7ffe" />
</MTProjectMetadataState> </MTProjectMetadataState>
</option> </option>
</component> </component>

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MessDetectorOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCSFixerOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCodeSnifferOptionsConfiguration">
<option name="highlightLevel" value="WARNING" />
<option name="transferred" value="true" />
</component>
<component name="PhpIncludePathManager">
<include_path>
<path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/altorouter/altorouter" />
<path value="$PROJECT_DIR$/vendor/twig/twig" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php81" />
<path value="$PROJECT_DIR$/vendor/symfony/deprecation-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.3">
<option name="suggestChangeDefaultLanguageLevel" value="false" />
</component>
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" />
</component>
</project>

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

@ -5,19 +5,8 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="afa12d51-331f-4dbc-a297-7289ad4e396d" name="Changes" comment=""> <list default="true" id="afa12d51-331f-4dbc-a297-7289ad4e396d" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/composer.json" beforeDir="false" afterPath="$PROJECT_DIR$/composer.json" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/index.php" beforeDir="false" afterPath="$PROJECT_DIR$/index.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controleur/FrontControler.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controleur/FrontControler.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controleur/QuizController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controleur/QuizController.php" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/Controleur/QuizController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controleur/QuizController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Gateway/Connection.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Gateway/Connection.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Gateway/QuestionGateway.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Gateway/QuestionGateway.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Gateway/QuizGateway.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Gateway/QuizGateway.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Model/QuestionModel.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Model/QuestionModel.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Model/QuizQuestionModel.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Model/QuizQuestionModel.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vendor/composer/autoload_psr4.php" beforeDir="false" afterPath="$PROJECT_DIR$/vendor/composer/autoload_psr4.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vendor/composer/autoload_static.php" beforeDir="false" afterPath="$PROJECT_DIR$/vendor/composer/autoload_static.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vue/accueil.php" beforeDir="false" afterPath="$PROJECT_DIR$/vue/accueil.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vue/quiz.php" beforeDir="false" afterPath="$PROJECT_DIR$/vue/templates/quiz.html.twig" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -78,6 +67,9 @@
&quot;associatedIndex&quot;: 4 &quot;associatedIndex&quot;: 4
}</component> }</component>
<component name="ProjectId" id="2oQGGlghI0ydDNgxjOeok3kwC7m" /> <component name="ProjectId" id="2oQGGlghI0ydDNgxjOeok3kwC7m" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="1" id="Add" />
</component>
<component name="ProjectViewState"> <component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
@ -85,7 +77,7 @@
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent"><![CDATA[{
"keyToString": { "keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "master", "git-widget-placeholder": "quizPart",
"node.js.detected.package.eslint": "true", "node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true", "node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)", "node.js.selected.package.eslint": "(autodetect)",
@ -121,7 +113,7 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1730794293135</updated> <updated>1730794293135</updated>
<workItem from="1730794294713" duration="2741000" /> <workItem from="1730794294713" duration="2741000" />
<workItem from="1730797544484" duration="27887000" /> <workItem from="1730797544484" duration="43165000" />
</task> </task>
<servers /> <servers />
</component> </component>

@ -0,0 +1,95 @@
<?php
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\CoreExtension;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
use Twig\TemplateWrapper;
/* endQuiz.html.twig */
class __TwigTemplate_c06a302c21f2b7c0cffcc93742935dad extends Template
{
private Source $source;
/**
* @var array<string, Template>
*/
private array $macros = [];
public function __construct(Environment $env)
{
parent::__construct($env);
$this->source = $this->getSourceContext();
$this->parent = false;
$this->blocks = [
];
}
protected function doDisplay(array $context, array $blocks = []): iterable
{
$macros = $this->macros;
// line 1
yield "<!DOCTYPE html>
<html lang=\"fr\">
<head>
<meta charset=\"UTF-8\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
<title>Wiki Fantasy : Quiz</title>
<link id=\"favicon\" rel=\"icon\" href=\"../../images/iconeSombre.ico\"> <!-- Par défaut sombre -->
<link rel=\"stylesheet\" href=\"../../public/styles/styleQuiz.css\">
<script defer src=\"../../public/script/theme-toggle.js\"></script>
</head>
<body>
<h2> ";
// line 14
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["score"] ?? null), "html", null, true);
yield " </h2>
</body>
</html>
";
yield from [];
}
/**
* @codeCoverageIgnore
*/
public function getTemplateName(): string
{
return "endQuiz.html.twig";
}
/**
* @codeCoverageIgnore
*/
public function isTraitable(): bool
{
return false;
}
/**
* @codeCoverageIgnore
*/
public function getDebugInfo(): array
{
return array ( 57 => 14, 42 => 1,);
}
public function getSourceContext(): Source
{
return new Source("", "endQuiz.html.twig", "/Users/kiem/Documents/WikiFantasy/WF-Website/vue/templates/endQuiz.html.twig");
}
}

@ -8,10 +8,9 @@ $rep = __DIR__ . '/../';
//$dConfig['includes']= array('controleur/Validation.php'); //$dConfig['includes']= array('controleur/Validation.php');
//BD //BD
$base = 'dbmarocher8';
$base = 'dbkemondejar'; $login = 'marocher8';
$login = 'kemondejar'; $mdp = 'sucepute';
$mdp = 'Ctvl-21122005';
//Vues //Vues
@ -21,6 +20,7 @@ $vues['quote'] = 'vue/quote.php';
$vues['login'] = 'vue/login.php'; $vues['login'] = 'vue/login.php';
$vues['signin'] = 'vue/signin.php'; $vues['signin'] = 'vue/signin.php';
$vues['quiz'] = 'vue/quiz.html'; $vues['quiz'] = 'vue/quiz.html';
$vues['favorite'] = 'vue/favorits.php';

@ -19,12 +19,9 @@ $twig = new \Twig\Environment($loader, [
'cache' => false, 'cache' => false,
]); ]);
$twig->addGlobal('racine','/~kemondejar/WF-Website'); $twig->addGlobal('racine','/~marocher8/WF-Website');
$cont = new Controleur\FrontControler($co); $cont = new Controleur\FrontControler($co);
session_unset();
session_destroy();
$_SESSION = array();
?> ?>

@ -54,6 +54,7 @@
overflow: hidden; overflow: hidden;
margin-bottom: 20px; margin-bottom: 20px;
height: 150px; height: 150px;
margin-left: 5%;
} }
.suggestion { .suggestion {

@ -16,15 +16,21 @@ Class FrontControler{
<<<<<<< HEAD
$this->listAction = ['visitor' => array('accueil','search','quote','login','signin'), $this->listAction = ['visitor' => array('accueil','search','quote','login','signin'),
'user' => array('quiz','commentary','favorite','logout','addComment'), 'user' => array('quiz','commentary','favorite','logout','addComment'),
'admin' => array('null')]; 'admin' => array('null')];
=======
$this->listAction = ['visitor' => array('accueil','search','quote','login','signin', 'favorite'),
'user' => array('quiz','commentary','logout'),
'admin' => array('null')];
>>>>>>> refs/remotes/origin/master
$dVueEreur = []; $dVueEreur = [];
$router = new \AltoRouter(); $router = new \AltoRouter();
$router->setBasePath('/~kemondejar/WF-Website'); $router->setBasePath('/~marocher8/WF-Website');
$router->map('GET', '/', 'VisitorControler','accueil'); $router->map('GET', '/', 'VisitorControler','accueil');
@ -41,6 +47,7 @@ Class FrontControler{
$router->map('GET|POST', '/login', 'VisitorControler','login'); $router->map('GET|POST', '/login', 'VisitorControler','login');
$router->map('GET|POST', '/signin', 'VisitorControler','signin'); $router->map('GET|POST', '/signin', 'VisitorControler','signin');
$router->map('GET|POST', '/addComment', 'UserControler','addComment'); $router->map('GET|POST', '/addComment', 'UserControler','addComment');
$router->map('GET|POST', '/favorite', 'VisitorControler','favorite');
$router->map('GET|POST', '/quiz/[i:id]?', 'QuizControler','quiz'); $router->map('GET|POST', '/quiz/[i:id]?', 'QuizControler','quiz');

@ -1,5 +1,4 @@
<?php <?php
namespace Controleur; namespace Controleur;
use Entity\QuestionEntity; use Entity\QuestionEntity;
@ -18,7 +17,6 @@ use Twig\Loader\FilesystemLoader;
class QuizControler class QuizControler
{ {
private int $no_question = 0;
private Connection $co; private Connection $co;
@ -37,22 +35,19 @@ class QuizControler
$this -> co = $co; $this -> co = $co;
$this -> gw = new QuestionGateway($this -> co); $this -> gw = new QuestionGateway($this -> co);
$this -> mdl = new QuestionModel($this -> gw); $this -> mdl = new QuestionModel($this -> gw);
global $num;
$loader = new FilesystemLoader('vue/templates'); global $loader;
$action = $_REQUEST['action'] ?? null; $action = $_REQUEST['action'] ?? null;
$id = (int) explode('/', $_SERVER['REQUEST_URI'])[2] ?? null; $id = (int) explode('/', $_SERVER['REQUEST_URI'])[2] ?? null;
$nb_questions = $this->getNumberOfQuestion($id);
switch ($action) { switch ($action) {
case 'canswer': case 'canswer':
if ($this->CorrectAnswer()) if ($this->CorrectAnswer())
echo "Bonne réponse"; $_SESSION['score'] = isset($_SESSION['score']) ? ($_SESSION['score'] + 1) : 1;
else echo "Mauvaise réponse"; $this->continueQuiz($id, $nb_questions);
$this->no_question ++;
echo $this->no_question;
$this->showQuestion($id, $this->no_question);
break; break;
default: default:
switch($id) switch($id)
@ -61,13 +56,48 @@ class QuizControler
// page erreur // page erreur
break; break;
default: default:
$this->showQuestion($id, $this->no_question); $_SESSION['score'] = $_SESSION['score'] ?? 0;
$this->showQuestion($id, $_SESSION['no_question'] ?? 0);
break; break;
} }
} }
} }
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
public function continueQuiz(int $id_quiz, int $total_questions) : void
{
$score = $_SESSION['score'];
$_SESSION['no_question'] = isset($_SESSION['no_question']) ? ($_SESSION['no_question'] + 1) : 1;
if ($_SESSION['no_question'] >= $total_questions) {
session_destroy();
$this->endQuiz($id_quiz, $score);
}
else header("Location: http://localhost:8000/quiz/$id_quiz");
}
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
public function endQuiz(int $id_quiz, int $score) : void
{
global $twig;
$gw = new QuizGateway($this->co);
$mdl = new QuizModel($gw);
if ($mdl->getQuiz($id_quiz + 1))
echo $twig->render('endQuiz.html.twig', ['score' => $score, 'nextquiz' => $id_quiz + 1]);
echo $twig->render('endQuiz.html.twig', ['score' => $score]);
}
public function CorrectAnswer() : bool public function CorrectAnswer() : bool
{ {
$answera = $_POST['answera'] ?? null; $answera = $_POST['answera'] ?? null;
@ -108,37 +138,23 @@ class QuizControler
* @throws SyntaxError * @throws SyntaxError
* @throws LoaderError * @throws LoaderError
*/ */
public function showQuestion(int $id, int $no) : void public function showQuestion(int $id, int $num) : void
{ {
global $twig; global $twig;
echo $num;
echo " : ", $_SESSION['score'];
$q = $this->GetQuestion($id); $q = $this->GetQuestion($id);
$question = $q[$no]; $question = $q[$num] ?? $q[0];
$idquestion = $question->getIdQuestion(); $idquestion = $question->getIdQuestion();
echo $twig->render('quiz.html.twig', ['question' => $question,'id'=>$idquestion]); echo $twig->render('quiz.html.twig', ['question' => $question,'id'=>$idquestion]);
} }
public function getNumberOfQuestion() : int
public function getNumberOfQuestion(int $id) : int
{ {
$gw = new QuizGateway($this->co); $gw = new QuizGateway($this->co);
$mdl = new QuizModel($gw); $mdl = new QuizModel($gw);
return 0; return $mdl->getQuiz($id)->getNbQuestions();
} }
} }
/*
<php
foreach ($news as $new)
{
<h2 href=<?= $new->getUrl() ?>> <?= $new->getTitle() ?> </h2>
}
?>
*/

@ -17,7 +17,21 @@ Class UserControler{
require_once $vues['quiz']; require_once $vues['quiz'];
} }
<<<<<<< HEAD
public function addComment(){ public function addComment(){
echo $_POST['content']; echo $_POST['content'];
=======
public function favorits() {
global $vues;
$user = $_SESSION['username'];
$idUser = $this->userGateway->getIdUser($user);
$suggestions = $this->favoritsGateway->getFavorits(0, 'fr');
require_once $vues['favorits'];
>>>>>>> refs/remotes/origin/master
} }
} }

@ -1,24 +1,35 @@
<?php <?php
namespace Controleur; namespace Controleur;
use Model\QuoteModel; use Model\QuoteModel;
use Model\CommentaryModel; use Model\CommentaryModel;
use Gateway\Connection; use Gateway\Connection;
use Gateway\QuoteGateway; use Gateway\QuoteGateway;
use Gateway\CommentaryGateway; use Gateway\CommentaryGateway;
use Gateway\AccueilGateway;
Class VisitorControler{ class VisitorControler {
private QuoteModel $qMod; private QuoteModel $qMod;
private CommentaryModel $cMod; private CommentaryModel $cMod;
private AccueilGateway $accueilGateway;
public function __construct(){ public function __construct(){
global $co; global $co;
$this->qMod = new QuoteModel(new QuoteGateway($co)); $this->qMod = new QuoteModel(new QuoteGateway($co));
$this->cMod = new CommentaryModel(new CommentaryGateway($co)); $this->cMod = new CommentaryModel(new CommentaryGateway($co));
$this->accueilGateway = new AccueilGateway($co);
} }
public function accueil() { public function accueil() {
global $vues; global $vues;
// Récupérer la citation du jour via AccueilGateway
$citationDuJour = $this->accueilGateway->getQuoteOfTheDay('fr');
$suggestions = $this->accueilGateway->getSuggestions(0, 'fr');
// Passer les données à la vue
require_once $vues['accueil']; require_once $vues['accueil'];
} }
@ -31,16 +42,17 @@ Class VisitorControler{
} }
public function login() { public function login() {
global $vues; global $vues;
require_once $vues['login']; require_once $vues['login'];
} }
public function signin() { public function signin() {
global $vues; global $vues;
require_once $vues['signin']; require_once $vues['signin'];
} }
public function favorite() {
global $vues;
require_once $vues['favorite'];
}
} }

@ -0,0 +1,49 @@
<?php
namespace Gateway;
use PDO;
class AccueilGateway {
private Connection $con;
public function __construct(Connection $con) {
$this->con = $con;
}
public function getQuoteOfTheDay(string $language): array {
$query = "SELECT q.id_quote, q.content, c.caracter, i.imgPath, s.title, s.dateS, q.likes, q.langue
FROM Quote q
JOIN Caracter c ON c.id_caracter = q.id_caracter
JOIN Source s ON s.id_source = q.id_source
JOIN Image i ON c.id_img = i.id_img
WHERE q.isValide = true AND q.isCitationDuJour = true AND q.langue = :language
ORDER BY id_quote DESC LIMIT 1;";
try {
$this->con->executeQuery($query, [':language' => [$language, PDO::PARAM_STR]]);
$result = $this->con->getResults();
return $result[0] ?? [];
} catch (PDOException $e) {
echo "Erreur dans getQuoteOfTheDay: " . $e->getMessage();
return [];
}
}
public function getSuggestions(int $numpage, string $language): array {
$query = "SELECT q.id_quote, q.content, c.caracter, i.imgPath, s.title, s.dateS, q.likes, q.langue
FROM Quote q
JOIN Caracter c ON c.id_caracter = q.id_caracter
JOIN Source s ON s.id_source = q.id_source
JOIN Image i ON c.id_img = i.id_img
WHERE q.isValide = true AND q.langue = :language
ORDER BY RANDOM()
LIMIT 20 OFFSET :offset;";
$this->con->executeQuery($query, [
':language' => [$language, PDO::PARAM_STR],
':offset' => [$numpage * 20, PDO::PARAM_INT]
]);
return $this->con->getResults();
}
}

@ -0,0 +1,31 @@
<?php
namespace Gateway;
use PDO;
class AccueilGateway {
private Connection $con;
public function __construct(Connection $con) {
$this->con = $con;
}
public function getSuggestions(int $numpage, string $language): array {
$username = $_SESSION['username'];
$userId = $this->userGateway->getIdUser($username);
$query = "SELECT q.id_quote, q.content, c.caracter, i.imgPath, s.title, s.dateS, q.likes, q.langue
FROM Quote q
JOIN Favorite f ON f.quote = q.id_quote
JOIN Caracter c ON c.id_caracter = q.id_caracter
JOIN Source s ON s.id_source = q.id_source
JOIN Image i ON c.id_img = i.id_img
WHERE q.isValide = true
AND q.langue = :language
AND f.users = :userId";
return $this->con->getResults();
}
}

@ -26,6 +26,7 @@ Class UserGateway{
return $this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_INT))); return $this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_INT)));
} }
public function getFavorite(string $id):array{ public function getFavorite(string $id):array{
//obtention favoris d'un user //obtention favoris d'un user
@ -35,7 +36,6 @@ Class UserGateway{
return $result; return $result;
} }
//obtenir les information d'un user //obtenir les information d'un user
public function findDataUser(int $id):array{ public function findDataUser(int $id):array{
$query = 'SELECT * FROM Users WHERE id_user=:idUser'; $query = 'SELECT * FROM Users WHERE id_user=:idUser';
@ -160,6 +160,13 @@ Class UserGateway{
$con->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_INT), ':newPassWd'=> array($passwordEncrypted, PDO::PARAM_STR))); $con->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_INT), ':newPassWd'=> array($passwordEncrypted, PDO::PARAM_STR)));
} }
public function getIdUser(string $username):array{
$query = 'SELECT id_user FROM Users WHERE username=:username';
$con->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR)));
$result = $con->getResults();
return $result;
}
} }

@ -24,8 +24,8 @@ class QuizModel {
$q = $this -> gateway -> findQuizById($id_quiz); $q = $this -> gateway -> findQuizById($id_quiz);
if ($q) { if ($q) {
return new quizEntity( return new quizEntity(
$q['id_quiz'], $q[0]['id_quiz'],
$q['nb_questions'], $q[0]['nb_quest']
); );
} }
return null; return null;

@ -1,89 +1,40 @@
<?php <?php
global $twig; global $twig;
echo $twig->render('head.html.twig', array(
echo $twig->render('head.html.twig', [
'title' => "Accueil", 'title' => "Accueil",
'style' => "public/styles/styleAccueil.css", 'style' => "public/styles/styleAccueil.css",
'scripts' => array("public/script/theme-toggle.js") ]);
));
echo $twig->render('bandeau.html.twig');
?>
<?php
$file = 'citation.txt';
$citations = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$citationDuJour = null;
$suggestions = [];
foreach ($citations as $citation) {
$parts = explode(';', $citation);
if (strpos(trim($parts[0]), 'µ') === 0) {
$citationDuJour = $parts;
} else {
$suggestions[] = $parts;
}
}
shuffle($suggestions);
$suggestions = array_filter($suggestions, function($suggestion) use ($citationDuJour) {
return count($suggestion) == 5 && !($suggestion[0] === trim($citationDuJour[1]));
});
$suggestions = array_slice($suggestions, 0, 10);
echo "<div class='citations-section'>";
if ($citationDuJour) { // Rendu du bandeau
$quote = htmlspecialchars(trim(substr($citationDuJour[1], 1))); // Retirer le symbole µ echo $twig->render('bandeau.html.twig');
$movie = htmlspecialchars(trim($citationDuJour[2]));
$character = htmlspecialchars(trim($citationDuJour[3]));
$year = htmlspecialchars(trim($citationDuJour[4]));
$imagePath = htmlspecialchars(trim($citationDuJour[5]));
echo "<h2>Citation du jour</h2>"; // Vérification de la présence de la "Citation du jour"
echo "<div class='citation-container citation-du-jour'>"; if (!empty($citationDuJour)) {
echo "<img src='$imagePath' alt='$movie' class='citation-image'>"; echo $twig->render('citation_du_jour.html.twig', [
echo "<div class='text-content'>"; 'quote' => $citationDuJour['content'],
echo "<p class='quote'>\"$quote\"</p>"; 'movie' => $citationDuJour['title'],
echo "<p class='movie'>- $movie</p>"; 'character' => $citationDuJour['caracter'],
echo "<p class='character'>Personnage : $character</p>"; 'year' => $citationDuJour['dates'],
echo "<p class='year'>Année : $year</p>"; 'imagePath' => $citationDuJour['imgpath']
echo "</div>"; ]);
echo "</div>";
} else { } else {
echo "<p class='error'>Aucune citation du jour n'a été trouvée.</p>"; echo "<p class='error'>Aucune citation du jour n'a été trouvée.</p>";
} }
if (!empty($suggestions)) { // Affichage des suggestions de citations
echo "<h2>Suggestions</h2>"; echo "<h2>Suggestions</h2>";
echo "<div class='suggestions-container'>"; echo "<div class='suggestions-container'>";
foreach ($suggestions as $suggestion) { foreach ($suggestions as $suggestion) {
$quote = htmlspecialchars(trim($suggestion[0])); echo $twig->render('suggestion.html.twig', [
$movie = htmlspecialchars(trim($suggestion[1])); 'quote' => $suggestion['content'],
$character = htmlspecialchars(trim($suggestion[2])); 'movie' => $suggestion['title'],
$year = htmlspecialchars(trim($suggestion[3])); 'character' => $suggestion['caracter'],
$imagePath = htmlspecialchars(trim($suggestion[4])); 'year' => $suggestion['dates'],
'imagePath' => $suggestion['imgpath']
echo "<div class='citation-container suggestion'>"; ]);
echo "<img src='$imagePath' alt='$movie' class='citation-image'>";
echo "<div class='text-content'>";
echo "<p class='quote'>\"$quote\"</p>";
echo "<p class='movie'>- $movie</p>";
echo "<p class='character'>Personnage : $character</p>";
echo "<p class='year'>Année : $year</p>";
echo "</div>";
echo "</div>";
} }
echo "</div>"; echo "</div>";
}
echo "</div>";
?> ?>
</body>
</html>

@ -1,30 +0,0 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wiki Fantasy : Favoris</title>
<link id="favicon" rel="icon" href="../images/iconeSombre.ico"> <!-- Par défaut sombre -->
<link rel="stylesheet" href="../public/styles/style.css">
<script defer src="../public/script/theme-toggle.js"></script>
<script src="../script/auth-check.js"></script>
</head>
<body>
<div class="container">
<div class="header">
<div class="nav">
<img src="../images/coeur.svg" alt="coeur" width="67px" height="67px" onmousedown="return false">
<img id="theme-icon" src="../images/light.svg" alt="toggle theme" width="72px" height="37px" onmousedown="return false" onclick="toggleTheme()">
<a href="quiz.html"><img src="../images/quizz.svg" alt="quizz" width="51px" height="82px" onmousedown="return false"></a>
</div>
<div class="logo">
<a href="accueil.html"><img src="../images/WIKIFANTASY.png" alt="Logo" width="227px" height="106px" onmousedown="return false"></a>
</div>
<div class="user">
<img src="../images/user_dark.png" alt="user" width="70px" height="70px" onmousedown="return false">
</div>
</div>
</div>
<h1>Wiki Fantasy</h1>
</body>
</html>

@ -0,0 +1,25 @@
<?php
global $twig;
// Rendu de l'en-tête
echo $twig->render('head.html.twig', [
'title' => "Accueil",
'style' => "public/styles/styleAccueil.css",
]);
// Rendu du bandeau
echo $twig->render('bandeau.html.twig');
echo "<h2>Favorits</h2>";
echo "<div class='suggestions-container'>";
foreach ($suggestions as $suggestion) {
echo $twig->render('favorits.html.twig', [
'quote' => $suggestion['content'],
'movie' => $suggestion['title'],
'character' => $suggestion['caracter'],
'year' => $suggestion['dates'],
'imagePath' => $suggestion['imgpath']
]);
}
echo "</div>";
?>

@ -1,6 +1,6 @@
<div class="header"> <div class="header">
<div class="nav"> <div class="nav">
<a href="favorite.html"><img src="images/coeur.svg" alt="coeur" width="67px" height="67px" onmousedown="return false"></a> <a href="{{ racine }}/favorite"><img src="images/coeur.svg" alt="coeur" width="67px" height="67px" onmousedown="return false"></a>
<img id="theme-icon" src="images/dark.svg" alt="toggle theme" width="72px" height="37px" onmousedown="return false" onclick="toggleTheme()"> <img id="theme-icon" src="images/dark.svg" alt="toggle theme" width="72px" height="37px" onmousedown="return false" onclick="toggleTheme()">
<a href="{{ racine }}/quiz"><img src="images/quizz.svg" alt="quizz" width="51px" height="82px" onmousedown="return false"></a> <a href="{{ racine }}/quiz"><img src="images/quizz.svg" alt="quizz" width="51px" height="82px" onmousedown="return false"></a>

@ -0,0 +1,10 @@
<h2>Citation du jour</h2>
<div class="citation-container citation-du-jour">
<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>

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wiki Fantasy : Quiz</title>
<link id="favicon" rel="icon" href="../../images/iconeSombre.ico"> <!-- Par défaut sombre -->
<link rel="stylesheet" href="../../public/styles/styleQuiz.css">
<script defer src="../../public/script/theme-toggle.js"></script>
</head>
<body>
<h1 style="color: #b7c8ff"> {{ score }} </h1>
<h1> {{ nextquiz }} </h1>
zeze
</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>

@ -9,7 +9,7 @@
<script defer src="../../public/script/theme-toggle.js"></script> <script defer src="../../public/script/theme-toggle.js"></script>
<script> <script>
// Timer pour 5 minutes // Timer pour 5 minutes
var timeLeft = 300; var timeLeft = 10;
function countdown() { function countdown() {
var timerDisplay = document.getElementById("timer"); var timerDisplay = document.getElementById("timer");
if (timeLeft <= 0) { if (timeLeft <= 0) {
@ -24,25 +24,12 @@
</script> </script>
</head> </head>
<body> <body>
<div class="header">
<div class="nav">
<a href="../favorite.html"><img src="../../images/coeur.svg" alt="coeur" width="67px" height="67px" onmousedown="return false"></a>
<img id="theme-icon" src="../../images/light.svg" alt="toggle theme" width="72px" height="37px" onmousedown="return false" onclick="toggleTheme()">
<img src="../../images/quizz.svg" alt="quizz" width="51px" height="82px" onmousedown="return false">
</div>
<div class="logo">
<img src="../../images/WIKIFANTASY.png" alt="Logo" width="227px" height="106px" onmousedown="return false">
</div>
<div class="user">
<img src="../../images/user_dark.png" alt="user" width="70px" height="70px" onmousedown="return false">
</div>
</div>
{{ include "bandeau.html.twig" }}
<h1>▶ Quiz ◀</h1> <h1>▶ Quiz ◀</h1>
<div class="quiz"> <div class="quiz">
<h2> {{ question.question }} </h2> <h2> {{ question.question }} </h2>
<a id="timer"> 300 seconds left .. </a> <a id="timer"> 10 seconds left .. </a>
<form id="quizForm" method="POST"> <form id="quizForm" method="POST">
<div class="answers"> <div class="answers">
@ -59,7 +46,7 @@
{{ question.answerd }} {{ question.answerd }}
</button> </button>
</div> </div>
<input type="hidden" name="action" value="canswer"> <input type="hidden" name="action" value="">
</form> </form>
</div> </div>
</body> </body>

@ -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>
Loading…
Cancel
Save