From a8e02f8948b961a27b47965e0eab1fcc1c207915 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 30 Dec 2021 01:40:43 +0100 Subject: [PATCH] word/quiz: preset configuration filters level Manual option preset.cat to test difficulty selection. --- word/quiz.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/word/quiz.js b/word/quiz.js index 361d075..146aff7 100644 --- a/word/quiz.js +++ b/word/quiz.js @@ -8,11 +8,16 @@ Array.prototype.shuffle = function () { class WordQuiz { dataselect(json) { + // find viable rows from json data let rows = Object.values(json); + if (this.preset.level !== undefined) { + rows = rows.filter(row => row[1] <= this.preset.level); + } return rows.shuffle(); } load(dataurl) { + this.preset = {}; fetch(dataurl).then(res => res.json()).then(json => { this.words = this.dataselect(json) this.setup(); -- 2.30.0