Update learn.php
This commit is contained in:
@@ -21,23 +21,7 @@ if (!$data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// kies woord
|
// kies woord
|
||||||
require_once 'includes/srs_queue.php';
|
|
||||||
|
|
||||||
$words = $data['words'];
|
|
||||||
|
|
||||||
$words = sortDueWords($words);
|
|
||||||
|
|
||||||
$today = date('Y-m-d');
|
|
||||||
|
|
||||||
$due = array_filter($words, function ($w) use ($today) {
|
|
||||||
return !isset($w['nextReview']) || $w['nextReview'] <= $today;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (count($due) > 0) {
|
|
||||||
$word = array_values($due)[0];
|
|
||||||
} else {
|
|
||||||
$word = $words[0];
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -56,22 +40,17 @@ if (count($due) > 0) {
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
Vertaal:
|
Vertaal:
|
||||||
<strong><?= htmlspecialchars($word['question']) ?></strong>
|
<strong id="question"></strong>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<input id="answer" placeholder="jouw antwoord">
|
<input id="answer">
|
||||||
|
|
||||||
<button onclick="check()">
|
<button onclick="check()">Controleer</button>
|
||||||
Controleer
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<p id="result"></p>
|
<p id="result"></p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<p>
|
|
||||||
Correct: <?= $word['correct'] ?? 0 ?>
|
|
||||||
| Fout: <?= $word['wrong'] ?? 0 ?>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -112,6 +91,54 @@ async function check() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
let currentWord = null;
|
||||||
|
|
||||||
|
async function loadWord() {
|
||||||
|
|
||||||
|
const res = await fetch(
|
||||||
|
"api/next.php?lang=<?= $lang ?>&list=<?= $list ?>"
|
||||||
|
);
|
||||||
|
|
||||||
|
const data = await res.json();
|
||||||
|
|
||||||
|
currentWord = data.word;
|
||||||
|
|
||||||
|
document.getElementById('question').innerText =
|
||||||
|
currentWord.question;
|
||||||
|
|
||||||
|
document.getElementById('answer').value = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
async function check() {
|
||||||
|
|
||||||
|
const answer =
|
||||||
|
document.getElementById('answer').value;
|
||||||
|
|
||||||
|
const res = await fetch('api/answer.php', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
lang: "<?= $lang ?>",
|
||||||
|
list: "<?= $list ?>",
|
||||||
|
wordId: currentWord.id,
|
||||||
|
answer: answer
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await res.json();
|
||||||
|
|
||||||
|
document.getElementById('result').innerText =
|
||||||
|
data.correct ? "Goed" : "Fout";
|
||||||
|
|
||||||
|
setTimeout(loadWord, 600);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadWord();
|
||||||
|
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user