pull/21/head
commit f883217037

@ -3,7 +3,9 @@
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<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>
</option>
</component>

@ -5,19 +5,8 @@
</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$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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" />
@ -78,6 +67,9 @@
&quot;associatedIndex&quot;: 4
}</component>
<component name="ProjectId" id="2oQGGlghI0ydDNgxjOeok3kwC7m" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="1" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
@ -85,7 +77,7 @@
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "master",
"git-widget-placeholder": "quizPart",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
@ -121,7 +113,7 @@
<option name="presentableId" value="Default" />
<updated>1730794293135</updated>
<workItem from="1730794294713" duration="2741000" />
<workItem from="1730797544484" duration="27887000" />
<workItem from="1730797544484" duration="43165000" />
</task>
<servers />
</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");
}
}

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

@ -1,5 +1,4 @@
<?php
namespace Controleur;
use Entity\QuestionEntity;
@ -18,7 +17,6 @@ use Twig\Loader\FilesystemLoader;
class QuizControler
{
private int $no_question = 0;
private Connection $co;
@ -35,24 +33,21 @@ class QuizControler
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 -> gw = new QuestionGateway($this -> co);
$this -> mdl = new QuestionModel($this -> gw);
global $num;
global $loader;
$action = $_REQUEST['action'] ?? null;
$id = (int) explode('/', $_SERVER['REQUEST_URI'])[2] ?? null;
$nb_questions = $this->getNumberOfQuestion($id);
switch ($action) {
case 'canswer':
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);
$_SESSION['score'] = isset($_SESSION['score']) ? ($_SESSION['score'] + 1) : 1;
$this->continueQuiz($id, $nb_questions);
break;
default:
switch($id)
@ -61,13 +56,48 @@ class QuizControler
// page erreur
break;
default:
$this->showQuestion($id, $this->no_question);
$_SESSION['score'] = $_SESSION['score'] ?? 0;
$this->showQuestion($id, $_SESSION['no_question'] ?? 0);
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
{
$answera = $_POST['answera'] ?? null;
@ -108,37 +138,23 @@ class QuizControler
* @throws SyntaxError
* @throws LoaderError
*/
public function showQuestion(int $id, int $no) : void
public function showQuestion(int $id, int $num) : void
{
global $twig;
echo $num;
echo " : ", $_SESSION['score'];
$q = $this->GetQuestion($id);
$question = $q[$no];
$question = $q[$num] ?? $q[0];
$idquestion = $question->getIdQuestion();
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);
$mdl = new QuizModel($gw);
return 0;
return $mdl->getQuiz($id)->getNbQuestions();
}
}
/*
<php
foreach ($news as $new)
{
<h2 href=<?= $new->getUrl() ?>> <?= $new->getTitle() ?> </h2>
}
?>
*/
}

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

@ -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>

@ -9,7 +9,7 @@
<script defer src="../../public/script/theme-toggle.js"></script>
<script>
// Timer pour 5 minutes
var timeLeft = 300;
var timeLeft = 10;
function countdown() {
var timerDisplay = document.getElementById("timer");
if (timeLeft <= 0) {
@ -24,25 +24,12 @@
</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>
{{ include "bandeau.html.twig" }}
<h1>▶ Quiz ◀</h1>
<div class="quiz">
<h2> {{ question.question }} </h2>
<a id="timer"> 300 seconds left .. </a>
<a id="timer"> 10 seconds left .. </a>
<form id="quizForm" method="POST">
<div class="answers">
@ -59,7 +46,7 @@
{{ question.answerd }}
</button>
</div>
<input type="hidden" name="action" value="canswer">
<input type="hidden" name="action" value="">
</form>
</div>
</body>

Loading…
Cancel
Save