diff --git a/learn.php b/learn.php index 5fc9932..94ff642 100644 --- a/learn.php +++ b/learn.php @@ -20,8 +20,24 @@ if (!$data) { die('Geen lijst'); } -// kies woord (simpel: random) -$word = $data['words'][array_rand($data['words'])]; +// 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]; +} ?>