avancement du quiz

php
Patrick BRUGIERE 1 year ago
parent d1cedcce77
commit 54bbd3e5a9

@ -100,6 +100,6 @@ abstract class AbsController
$allTranslation = $mdl->findByIdVoc($vocabId); $allTranslation = $mdl->findByIdVoc($vocabId);
$shuffle = $allTranslation; $shuffle = $allTranslation;
shuffle($shuffle); shuffle($shuffle);
echo $twig->render('quizzView.html', ['translations' => $allTranslation, 'randomtranslations']); echo $twig->render('quizzView.html', ['translations' => $allTranslation, 'randomtranslations' => $shuffle]);
} }
} }

@ -56,7 +56,7 @@ class FrontController
$this->disconnect(); $this->disconnect();
break; break;
case 'quiz': case 'quiz':
$this->quiz(); AbsController::quiz();
break; break;
default : default :
@ -128,10 +128,5 @@ class FrontController
$mdl->deconnection(); $mdl->deconnection();
$this->home(); $this->home();
} }
public function quiz(){
$ctrl = new StudentController();
$ctrl->quiz();
}
} }

@ -36,16 +36,7 @@ class StudentController
echo $twig->render('manageVocabView.html', ['vocabularies' => $vocab]); echo $twig->render('manageVocabView.html', ['vocabularies' => $vocab]);
} }
public function quiz(): void
{
global $twig;
$vocabId = $_GET['vocabID'];
$mdl = new TranslationGateway();
$allTranslation = $mdl->findByIdVoc($vocabId);
$shuffle = $allTranslation;
shuffle($shuffle);
echo $twig->render('quizzView.html', ['translations' => $allTranslation, 'randomtranslations']);
}
/* /*
public function flashcard(VocabularyList $v) { public function flashcard(VocabularyList $v) {
$idVoc = $v->getId(); $idVoc = $v->getId();

@ -12,13 +12,22 @@
{% for translation in translations %} {% for translation in translations %}
<h2>{{ translation.word1 }}</h2> <h2>{{ translation.word1 }}</h2>
{% set correctAnswer = translation.word2 %} {% set correctAnswer = translation.word2 %}
{% set otherTranslations = [translation.word2, translations[0].word2, translations[1].word2, translations[2].word2] %} {% if randomtranslations is defined %}
{% set otherTranslations = [correctAnswer] %}
{% for randomtranslation in randomtranslations %}
{% if randomtranslation.word2 != correctAnswer and otherTranslations|length <= 3 %}
{% set otherTranslations = otherTranslations|merge([randomtranslation.word2]) %}
{% endif %}
{% endfor %}
{# Affichage des réponses sous forme de radio buttons #}
<input type="radio" name="answer" value="{{ correctAnswer }}"> {{ correctAnswer }}<br> <input type="radio" name="answer" value="{{ correctAnswer }}"> {{ correctAnswer }}<br>
{% for otherTranslation in otherTranslations %} {% for otherTranslation in otherTranslations %}
{% if otherTranslation != correctAnswer %} <input type="radio" name="answer" value="{{ otherTranslation }}"> {{ otherTranslation }}<br>
<input type="radio" name="answer" value="{{ otherAnswer }}"> {{ otherAnswer }}<br>
{% endif %}
{% endfor %} {% endfor %}
{% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
<input type="submit" value="Submit" name="submitForm"> <input type="submit" value="Submit" name="submitForm">

Loading…
Cancel
Save