avancement du quiz

php
Patrick BRUGIERE 1 year ago
parent 0ad8c09673
commit 6a466b062b

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

@ -42,7 +42,9 @@ class StudentController
$vocabId = $_GET['vocabID']; $vocabId = $_GET['vocabID'];
$mdl = new TranslationGateway(); $mdl = new TranslationGateway();
$allTranslation = $mdl->findByIdVoc($vocabId); $allTranslation = $mdl->findByIdVoc($vocabId);
echo $twig->render('quizzView.html', ['translations' => $allTranslation]); $shuffle = $allTranslation;
shuffle($shuffle);
echo $twig->render('quizzView.html', ['translations' => $allTranslation, 'randomtranslations']);
} }
/* /*
public function flashcard(VocabularyList $v) { public function flashcard(VocabularyList $v) {

@ -2,41 +2,47 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Manage groups</title> <title>Manage groups</title><!-- Vos liens de styles et de scripts -->
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
<!-- Font Awesome icons (free version)-->
<script src="https://use.fontawesome.com/releases/v6.3.0/js/all.js" crossorigin="anonymous"></script>
<!-- Google fonts-->
<link href="https://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet" />
<link
href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
rel="stylesheet" />
<!-- Core theme CSS (includes Bootstrap)-->
<link href="css/styles.css" rel="stylesheet" />
</head> </head>
<body> <body>
<section> <section>
<h1>Quiz</h1> <h1>Quiz</h1>
<form action="quiz" method="post">
<h2>{{frenchWord}}</h2>
{% for i in 0..3 %} {% if translations is defined %}
{% for translation in translations %}
<input type="radio" name="answer{{i}}" value="{{valid[i]}}"> {{answers[i]}}<br> <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>
{% endif %}
{% endfor %} {% endfor %}
{% endfor %}
<input type="submit" value="Soumettre"> {% endif %}
<input type="submit" value="Submit" name="submitForm">
</form> </form>
{% if submitted %}
{% if isCorrect %}
<p>Correct answer!</p>
{% else %}
<p>Wrong answer!</p>
{% endif %}
{% endif %}
</section>
<h1>Translator</h1> <h1>Translator</h1>
<form action="quiz?vocabID={{row.id}}" method="POST"> <form action="quiz" method="POST">
<label for="wordInput">Enter a word:</label> {% if translations is defined %}
<input type="text" id="wordInput" name="wordInput"> {% for translation in translations %}
<label for="wordInput{{ translation.id }}">Traduire {{ translation.word1 }}</label>
<input type="text" id="wordInput{{ translation.id }}" name="wordInput{{ translation.id }}">
<input type="hidden" name="vocabID" value="{{ translation.listVocab }}">
<button type="submit">Translate</button> <button type="submit">Translate</button>
{% endfor %}
{% endif %}
</form> </form>
</section> </section>
</body> </body>
</html> </html>
Loading…
Cancel
Save