Quiz
{% if translations is defined %} {% for translation in translations %}
{{ translation.word1 }}
{% 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 #}
{{ correctAnswer }}
{% for otherTranslation in otherTranslations %}
{{ otherTranslation }}
{% endfor %} {% endif %} {% endfor %} {% endif %}
{% if submitted %} {% if isCorrect %}
Correct answer!
{% else %}
Wrong answer!
{% endif %} {% endif %}
Translator
{% if translations is defined %} {% for translation in translations %}
Traduire {{ translation.word1 }}
Translate
{% endfor %} {% endif %}