meilleure gestion d'erreur + affichage nom de la liste à la place de quiz

php
Anthony RICHARD 1 year ago
parent 4877d9b4ac
commit 657d7fb711

@ -97,6 +97,8 @@ class AbsController
{
global $twig;
$vocabId = Validation::filter_int($match['id'] ?? null);
$vocabList = (new VocabularyListGateway())->findById($vocabId) ?? null;
if ($vocabList == null) throw new Exception("liste inconnue");
$mdl = new TranslationGateway();
$allTranslation = $mdl->findByIdVoc($vocabId);
$shuffle = $allTranslation;
@ -127,7 +129,7 @@ class AbsController
$answers[] = $tab;
}
echo $twig->render('quizView.html', ['questions' => $questions, 'answers' => $answers, 'goodAnswers' => $goodAnswers]);
echo $twig->render('quizView.html', ['questions' => $questions, 'answers' => $answers, 'goodAnswers' => $goodAnswers, 'listName' => $vocabList->getName()]);
}
public function login(): void {

@ -73,8 +73,9 @@ class VocabularyListGateway extends AbsGateway
$query = "SELECT * FROM VocabularyList WHERE id = :id";
$args = array(':id' => array($id, PDO::PARAM_INT));
$this->con->executeQuery($query, $args);
return $this->con->getResults();
$results = $this->con->getResults();
if (empty($results)) return null;
return new VocabularyList($results[0]['id'],$results[0]['name'],$results[0]['image'],$results[0]['userID']);
}
catch (PDOException $e){
throw new Exception($e->getMessage());

@ -21,7 +21,7 @@
<body>
<section id="quiz">
<h1>Quiz</h1>
<h1>{{listName}}</h1>
<div id="questionContainer">
{% if questions is defined %}
{% for i in 0..questions|length %}

Loading…
Cancel
Save