|
|
|
@ -12,6 +12,7 @@ class VisitorController
|
|
|
|
|
{
|
|
|
|
|
public function memory($match): void{
|
|
|
|
|
global $twig;
|
|
|
|
|
global $user;
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
$idVoc = Validation::filter_int($_POST['idVoc'] ?? 4);
|
|
|
|
@ -19,6 +20,7 @@ class VisitorController
|
|
|
|
|
$name = ((new \gateway\VocabularyListGateway())->findById($idVoc))->getName();
|
|
|
|
|
$wordShuffle = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shuffle($wordList);
|
|
|
|
|
$pairs = [];
|
|
|
|
|
$maxWords = 28;
|
|
|
|
@ -33,11 +35,22 @@ class VisitorController
|
|
|
|
|
|
|
|
|
|
shuffle($wordShuffle);
|
|
|
|
|
|
|
|
|
|
if(isset($user)) {
|
|
|
|
|
echo $twig->render('memory.html', [
|
|
|
|
|
'wordShuffle' => $wordShuffle,
|
|
|
|
|
'pairs' => json_encode($pairs),
|
|
|
|
|
'name' => $name,
|
|
|
|
|
'userID' => $user->getID(),
|
|
|
|
|
'userRole' => $user->getRoles()
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
echo $twig->render('memory.html', [
|
|
|
|
|
'wordShuffle' => $wordShuffle,
|
|
|
|
|
'pairs' => json_encode($pairs),
|
|
|
|
|
'name' => $name
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception $e){
|
|
|
|
@ -47,6 +60,8 @@ class VisitorController
|
|
|
|
|
public function quiz($match): void
|
|
|
|
|
{
|
|
|
|
|
global $twig;
|
|
|
|
|
global $user;
|
|
|
|
|
try {
|
|
|
|
|
$vocabId = Validation::filter_int($_POST['idVoc'] ?? 4);
|
|
|
|
|
$vocabList = (new VocabularyListGateway())->findById($vocabId) ?? null;
|
|
|
|
|
if ($vocabList == null) throw new Exception("liste inconnue");
|
|
|
|
@ -80,7 +95,25 @@ class VisitorController
|
|
|
|
|
$answers[] = $tab;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo $twig->render('quizView.html', ['questions' => $questions, 'answers' => $answers, 'goodAnswers' => $goodAnswers, 'listName' => $vocabList->getName()]);
|
|
|
|
|
if (isset($user)) {
|
|
|
|
|
echo $twig->render('quizView.html', [
|
|
|
|
|
'questions' => $questions,
|
|
|
|
|
'answers' => $answers,
|
|
|
|
|
'goodAnswers' => $goodAnswers,
|
|
|
|
|
'listName' => $vocabList->getName(),
|
|
|
|
|
'userID' => $user->getID(),
|
|
|
|
|
'userRole' => $user->getRoles()]);
|
|
|
|
|
} else {
|
|
|
|
|
echo $twig->render('quizView.html', [
|
|
|
|
|
'questions' => $questions,
|
|
|
|
|
'answers' => $answers,
|
|
|
|
|
'goodAnswers' => $goodAnswers,
|
|
|
|
|
'listName' => $vocabList->getName()]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception $e){
|
|
|
|
|
throw new Exception("Erreur");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function login(): void {
|
|
|
|
|