git.shiar.nl
/
sheet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1d2520b
)
word/quiz: preset configuration filters level
author
Mischa POSLAWSKY
<perl@shiar.org>
Thu, 30 Dec 2021 00:40:43 +0000
(
01:40
+0100)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Fri, 31 Dec 2021 04:29:05 +0000
(
05:29
+0100)
Manual option preset.cat to test difficulty selection.
word/quiz.js
patch
|
blob
|
history
diff --git
a/word/quiz.js
b/word/quiz.js
index 361d075e66391f517b08b8f51f7a12222ef9b954..146aff73e61171c10f81779aad8be30777d7da35 100644
(file)
--- 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();