avancement du quiz

php
Patrick BRUGIERE 1 year ago
parent d1cedcce77
commit 54bbd3e5a9

@ -100,6 +100,6 @@ abstract class AbsController
$allTranslation = $mdl->findByIdVoc($vocabId);
$shuffle = $allTranslation;
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();
break;
case 'quiz':
$this->quiz();
AbsController::quiz();
break;
default :
@ -128,10 +128,5 @@ class FrontController
$mdl->deconnection();
$this->home();
}
public function quiz(){
$ctrl = new StudentController();
$ctrl->quiz();
}
}

@ -36,16 +36,7 @@ class StudentController
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) {
$idVoc = $v->getId();

@ -8,19 +8,28 @@
<section>
<h1>Quiz</h1>
{% if translations is defined %}
{% for translation in translations %}
{% if translations is defined %}
{% for translation in translations %}
<h2>{{ translation.word1 }}</h2>
{% set correctAnswer = translation.word2 %}
{% set otherTranslations = [translation.word2, translations[0].word2, translations[1].word2, translations[2].word2] %}
<input type="radio" name="answer" value="{{ correctAnswer }}"> {{ correctAnswer }}<br>
{% for otherTranslation in otherTranslations %}
{% if otherTranslation != correctAnswer %}
<input type="radio" name="answer" value="{{ otherAnswer }}"> {{ otherAnswer }}<br>
{% set correctAnswer = translation.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>
{% for otherTranslation in otherTranslations %}
<input type="radio" name="answer" value="{{ otherTranslation }}"> {{ otherTranslation }}<br>
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
<input type="submit" value="Submit" name="submitForm">
</form>
{% if submitted %}

Loading…
Cancel
Save