Leni BEAULATON 6 months ago
commit c0196869f2

BIN
.DS_Store vendored

Binary file not shown.

@ -0,0 +1,19 @@
<?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>

@ -0,0 +1,12 @@
<?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

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="userId" value="5c5a39c9:192fb929d1e:-7ffa" />
</MTProjectMetadataState>
</option>
</component>
</project>

@ -0,0 +1,33 @@
<?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>

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

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<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$/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/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>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ComposerSettings" synchronizationState="SYNCHRONIZE">
<pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
<execution />
</component>
<component name="Git.Settings">
<excluded-from-favorite>
<branch-storage>
<map>
<entry type="LOCAL">
<value>
<list>
<branch-info repo="$PROJECT_DIR$" source="master" />
</list>
</value>
</entry>
</map>
</branch-storage>
</excluded-from-favorite>
<favorite-branches>
<branch-storage>
<map>
<entry type="LOCAL">
<value>
<list>
<branch-info repo="$PROJECT_DIR$" source="reorganisation" />
</list>
</value>
</entry>
</map>
</branch-storage>
</favorite-branches>
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="master" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="PhpWorkspaceProjectConfiguration" interpreter_name="/opt/homebrew/Cellar/php/8.3.8/bin/php">
<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="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: 4
}</component>
<component name="ProjectId" id="2oQGGlghI0ydDNgxjOeok3kwC7m" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "master",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"vue.rearranger.settings.migration": "true"
},
"keyToStringList": {
"DatabaseDriversLRU": [
"postgresql"
]
}
}]]></component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/vue/templates" />
</key>
</component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-js-predefined-1d06a55b98c1-0b3e54e931b4-JavaScript-PS-241.18034.69" />
<option value="bundled-php-predefined-ba97393d7c68-48a1a656d44e-com.jetbrains.php.sharedIndexes-PS-241.18034.69" />
</set>
</attachedChunks>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="afa12d51-331f-4dbc-a297-7289ad4e396d" name="Changes" comment="" />
<created>1730794293135</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1730794293135</updated>
<workItem from="1730794294713" duration="2741000" />
<workItem from="1730797544484" duration="27887000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
</project>

@ -0,0 +1,167 @@
<?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;
/* quiz.html.twig */
class __TwigTemplate_eb15b3c7b3e1c48f1a2ebec5d9eb6685 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>
<script>
// Timer pour 5 minutes
var timeLeft = 300;
function countdown() {
var timerDisplay = document.getElementById(\"timer\");
if (timeLeft <= 0) {
document.getElementById(\"quizForm\").submit();
} else {
timerDisplay.innerHTML = timeLeft + \" seconds left\";
timeLeft -= 1;
setTimeout(countdown, 1000);
}
}
window.onload = countdown;
</script>
</head>
<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>
<h1>▶ Quiz ◀</h1>
<div class=\"quiz\">
<h2> ";
// line 44
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, ($context["question"] ?? null), "question", [], "any", false, false, false, 44), "html", null, true);
yield " </h2>
<a id=\"timer\"> 300 seconds left .. </a>
<form id=\"quizForm\" method=\"POST\">
<div class=\"answers\">
<button class=\"answer\" name=\"answera\" value=\"A-";
// line 49
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["id"] ?? null), "html", null, true);
yield "\">
";
// line 50
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, ($context["question"] ?? null), "answera", [], "any", false, false, false, 50), "html", null, true);
yield "
</button>
<button class=\"answer\" name=\"answerb\" value=\"B-";
// line 52
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["id"] ?? null), "html", null, true);
yield "\">
";
// line 53
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, ($context["question"] ?? null), "answerb", [], "any", false, false, false, 53), "html", null, true);
yield "
</button>
<button class=\"answer\" name=\"answerc\" value=\"C-";
// line 55
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["id"] ?? null), "html", null, true);
yield "\">
";
// line 56
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, ($context["question"] ?? null), "answerc", [], "any", false, false, false, 56), "html", null, true);
yield "
</button>
<button class=\"answer\" name=\"answerd\" value=\"D-";
// line 58
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["id"] ?? null), "html", null, true);
yield "\">
";
// line 59
yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, ($context["question"] ?? null), "answerd", [], "any", false, false, false, 59), "html", null, true);
yield "
</button>
</div>
<input type=\"hidden\" name=\"action\" value=\"canswer\">
</form>
</div>
</body>
</html>
";
yield from [];
}
/**
* @codeCoverageIgnore
*/
public function getTemplateName(): string
{
return "quiz.html.twig";
}
/**
* @codeCoverageIgnore
*/
public function isTraitable(): bool
{
return false;
}
/**
* @codeCoverageIgnore
*/
public function getDebugInfo(): array
{
return array ( 126 => 59, 122 => 58, 117 => 56, 113 => 55, 108 => 53, 104 => 52, 99 => 50, 95 => 49, 87 => 44, 42 => 1,);
}
public function getSourceContext(): Source
{
return new Source("", "quiz.html.twig", "/Users/kiem/Documents/WikiFantasy/WF-Website/vue/templates/quiz.html.twig");
}
}

@ -8,6 +8,7 @@
"psr-4": {
"Controleur\\": "src/Controleur/",
"Model\\": "src/Model/",
"Gateway\\": "src/Gateway/",
"Entity\\": "src/Entity/"
}
}

@ -11,6 +11,7 @@ require_once __DIR__ . '/config/config.php';
require __DIR__ . '/vendor/autoload.php';
$co = new \Gateway\Connection('pgsql:host=localhost;dbname=dbwikifantasy;', 'kiem', '');
//twig
$loader = new \Twig\Loader\FilesystemLoader('vue/templates');
@ -19,7 +20,7 @@ $twig = new \Twig\Environment($loader, [
]);
$cont = new Controleur\FrontControler();
$cont = new Controleur\FrontControler($co);
session_unset();
session_destroy();

@ -1,9 +1,14 @@
<?php
namespace Controller;
namespace Controleur;
use Entity\QuestionEntity;
use Gateway\Connection;
use Gateway\QuestionGateway;
use Gateway\QuizGateway;
use Gateway\QuizQuestionGateway;
use Model\QuestionModel;
use Model\QuizModel;
use Model\QuizQuestionModel;
use Twig\Environment;
use Twig\Error\LoaderError;
@ -13,10 +18,15 @@ use Twig\Loader\FilesystemLoader;
class QuizController
{
private Environment $twig;
private int $no_question = 0;
private Connection $co;
private QuestionGateway $gw;
private QuestionModel $mdl;
/**
* @throws SyntaxError
* @throws RuntimeError
@ -24,34 +34,73 @@ class QuizController
*/
public function __construct(Connection $co)
{
$this -> co = $co;
$this -> gw = new QuestionGateway($this->co);
$this -> mdl = new QuestionModel($this->gw);
$loader = new FilesystemLoader('vue/templates');
$this->twig = new \Twig\Environment($loader, [
'cache' => false,
]);
$action = $_REQUEST['action'] ?? null;
$id = explode('-', $_SERVER['REQUEST_URI'])[1] ?? null;
$id = (int) explode('/', $_SERVER['REQUEST_URI'])[2] ?? null;
switch ($action) {
case 'canswer':
switch($id)
{
case null:
// page erreur
if ($this->CorrectAnswer())
echo "Bonne réponse";
else echo "Mauvaise réponse";
$this->no_question ++;
echo $this->no_question;
$this->showQuestion($id, $this->no_question);
break;
default:
$this->showQuestion($id);
break;
switch($id)
{
case null:
// page erreur
break;
default:
$this->showQuestion($id, $this->no_question);
break;
}
}
}
public function CorrectAnswer() : bool
{
$answera = $_POST['answera'] ?? null;
$answerb = $_POST['answerb'] ?? null;
$answerc = $_POST['answerc'] ?? null;
$answerd = $_POST['answerd'] ?? null;
$id= null;
$answer = null;
if ($answera) {
$answer = explode('-', $answera)[0];
$id = (int) explode('-', $answera)[1];
} elseif ($answerb) {
$answer = explode('-', $answerb)[0];
$id = (int) explode('-', $answerb)[1];
} elseif ($answerc) {
$answer = explode('-', $answerc)[0];
$id = (int) explode('-', $answerc)[1];
} elseif ($answerd) {
$answer = explode('-', $answerd)[0];
$id = (int) explode('-', $answerd)[1];
}
$res = $this->mdl->getQuestion($id);
return $answer == $res->getCanswer();
}
public function GetQuestion(int $id): array
{
$gw = new QuizQuestionGateway($this->co);
$quizModel = new QuizQuestionModel($gw);
return $quizModel->getAllQuestionByQuiz($id, $this->co);
$mdl = new QuizQuestionModel($gw);
return $mdl->getAllQuestionByQuiz($id, $this->co);
}
/**
@ -59,13 +108,37 @@ class QuizController
* @throws SyntaxError
* @throws LoaderError
*/
public function showQuestion(int $id) : void
public function showQuestion(int $id, int $no) : void
{
global $twig;
$q = $this->GetQuestion($id);
$i = 0;
// en fonction du nb de question restante et du answer submit changer le i
$q = $q[$i];
$question = $q[$no];
echo $this->twig->render('quiz.html.twig', ['question' => $q]);
$idquestion = $question->getIdQuestion();
echo $twig->render('quiz.html.twig', ['question' => $question,'id'=>$idquestion]);
}
public function getNumberOfQuestion() : int
{
$gw = new QuizGateway($this->co);
$mdl = new QuizModel($gw);
return 0;
}
}
/*
<php
foreach ($news as $new)
{
<h2 href=<?= $new->getUrl() ?>> <?= $new->getTitle() ?> </h2>
}
}
?>
*/

@ -1,7 +1,9 @@
<?php
namespace Gateway;
class Connection extends \PDO {
use PDO;
class Connection extends \PDO {
private $stmt;

@ -1,6 +1,7 @@
<?php
namespace Gateway;
use Connection;
use Gateway\Connection;
use PDO;
class QuestionGateway
{

@ -1,10 +1,9 @@
<?php
namespace Gateway;
use Connection;
use Gateway\Connection;
use PDO;
require_once("../Entity/quizEntity.php");
class QuizGateway
{

@ -24,13 +24,13 @@ class QuestionModel
$q = $this -> gateway -> findById($id_question);
if ($q)
return new QuestionEntity(
$q['id_question'],
$q['question'],
$q['answerA'],
$q['answerB'],
$q['answerC'],
$q['answerD'],
$q['cAnswer']
$q[0]['id_question'],
$q[0]['question'],
$q[0]['answera'],
$q[0]['answerb'],
$q[0]['answerc'],
$q[0]['answerd'],
$q[0]['canswer']
);
return null;
}

@ -41,7 +41,7 @@ class QuizQuestionModel
public function getAllQuestionByQuiz(int $id, Connection $co): array
{
$q = $this ->gw->findQuizQuestionByIdQuestion($id);
$q = $this->gw->findQuestionsFromQuiz($id);
$questions = [];
$gw = new QuestionGateway($co);
@ -50,6 +50,7 @@ class QuizQuestionModel
foreach ($q as $question){
$questions [] = $qmdl->getQuestion($question[1]);
}
return $questions;
}

@ -11,6 +11,7 @@ return array(
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
'Model\\' => array($baseDir . '/src/Model'),
'Gateway\\' => array($baseDir . '/src/Gateway'),
'Entity\\' => array($baseDir . '/src/Entity'),
'Controleur\\' => array($baseDir . '/src/Controleur'),
);

@ -32,6 +32,10 @@ class ComposerStaticInit68804b2111cb6b8bf6edf66cb2b4669c
array (
'Model\\' => 6,
),
'G' =>
array (
'Gateway\\' => 8,
),
'E' =>
array (
'Entity\\' => 7,
@ -63,6 +67,10 @@ class ComposerStaticInit68804b2111cb6b8bf6edf66cb2b4669c
array (
0 => __DIR__ . '/../..' . '/src/Model',
),
'Gateway\\' =>
array (
0 => __DIR__ . '/../..' . '/src/Gateway',
),
'Entity\\' =>
array (
0 => __DIR__ . '/../..' . '/src/Entity',

@ -13,11 +13,10 @@
'title' => "Accueil",
'style' => "../../public/styles/styleAccueil.css",
));
echo $twig->render('bandeau.html.twig');
?>
<?php
$file = 'citation.txt';

@ -1,82 +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 : Quiz</title>
<link id="favicon" rel="icon" href="../images/iconeSombre.ico"> <!-- Par défaut sombre -->
<link rel="stylesheet" href="../styles/styleQuiz.css">
<script defer src="../script/theme-toggle.js"></script>
<script>
// Timer pour 5 minutes
var timeLeft = 300;
function countdown() {
var timerDisplay = document.getElementById("timer");
if (timeLeft <= 0) {
document.getElementById("quizForm").submit();
} else {
timerDisplay.innerHTML = timeLeft + " seconds left";
timeLeft -= 1;
setTimeout(countdown, 1000);
}
}
window.onload = countdown;
</script>
</head>
<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>
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/src/Gateway/QuestionGateway.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/src/Model/QuestionModel.php');
use Model\QuestionModel;
$dsn = 'pgsql:host=localhost;dbname=dbwikifantasy;';
$user = 'kiem';
$co = new Connection($dsn, $user, '');
$gw = new QuestionGateway($co);
$mdl = new QuestionModel($gw);
$q = $mdl -> getRdmQuestion();
?>
<h1>▶ Quiz ◀</h1>
<div class="quiz">
<h2> <?= $q -> getQuestion() ?></h2>
<a id="timer"> 300 seconds left .. </a>
<form id="quizForm" method="POST" action="submit_quiz.php">
<div class="answers">
<button class="answer" type="submit" name="answer" value="A">
<?=$q -> getAnswerA()?>
</button>
<button class="answer" type="submit" name="answer" value="B">
<?=$q -> getAnswerB()?>
</button>
<button class="answer" type="submit" name="answer" value="C">
<?=$q -> getAnswerC()?>
</button>
<button class="answer" type="submit" name="answer" value="D">
<?=$q -> getAnswerD()?>
</button>
</div>
<div class="submit-button">
<button class="buttonSudmite" type="submit">Confirmer</button>
</div>
</form>
</div>
</body>
</html>

@ -0,0 +1,66 @@
<!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>
<script>
// Timer pour 5 minutes
var timeLeft = 300;
function countdown() {
var timerDisplay = document.getElementById("timer");
if (timeLeft <= 0) {
document.getElementById("quizForm").submit();
} else {
timerDisplay.innerHTML = timeLeft + " seconds left";
timeLeft -= 1;
setTimeout(countdown, 1000);
}
}
window.onload = countdown;
</script>
</head>
<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>
<h1>▶ Quiz ◀</h1>
<div class="quiz">
<h2> {{ question.question }} </h2>
<a id="timer"> 300 seconds left .. </a>
<form id="quizForm" method="POST">
<div class="answers">
<button class="answer" name="answera" value="A-{{ id }}">
{{ question.answera }}
</button>
<button class="answer" name="answerb" value="B-{{ id }}">
{{ question.answerb }}
</button>
<button class="answer" name="answerc" value="C-{{ id }}">
{{ question.answerc }}
</button>
<button class="answer" name="answerd" value="D-{{ id }}">
{{ question.answerd }}
</button>
</div>
<input type="hidden" name="action" value="canswer">
</form>
</div>
</body>
</html>
Loading…
Cancel
Save