git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
map: generic page to show data tables
[sheet.git]
/
word
/
multichoice.js
diff --git
a/word/multichoice.js
b/word/multichoice.js
index b98842f18a074e0cc6643b4afe38f8ba6975e1a7..7402507aa90e33c1fb481c3840918ec93c455da8 100644
(file)
--- a/
word/multichoice.js
+++ b/
word/multichoice.js
@@
-1,16
+1,19
@@
-class Quiz {
+class
WordMultichoice extends Word
Quiz {
next() {
next() {
+ if (this.words.length < 4) return;
let word = this.words.shift();
let form = put(this.form,
let word = this.words.shift();
let form = put(this.form,
- '+img[src=$]+ul', `/data/word/
en/${word[0
]}.jpg`,
+ '+img[src=$]+ul', `/data/word/
32/${word[2
]}.jpg`,
);
);
- let answers = [word[2], this.words[1][2], this.words[2][2], this.words[3][2]]
- .sort(() => {return .5 - Math.random()}) // shuffle
+ let answers = [word[0], this.words[0][0], this.words[1][0], this.words[2][0]]
+ .shuffle()
+ this.log('ask', word[2], answers);
answers.forEach(suggest => {
let label = suggest.replace(/\/.*/, '');
let option = put(form, 'li', label, {onclick: () => {
answers.forEach(suggest => {
let label = suggest.replace(/\/.*/, '');
let option = put(form, 'li', label, {onclick: () => {
- if (suggest != word[2]) {
+ this.log('pick', suggest, null, word[0]);
+ if (suggest != word[0]) {
// incorrect
put(option, '.wrong');
return;
// incorrect
put(option, '.wrong');
return;
@@
-21,12
+24,8
@@
class Quiz {
});
}
});
}
- constructor(dataurl) {
- fetch(dataurl).then(res => res.json()).then(json => {
- this.form = document.getElementById('quiz');
- this.words = Object.values(json)
- .sort(() => {return .5 - Math.random()}) // shuffle
- this.next();
- });
+ setup() {
+ super.setup();
+ this.next();
}
};
}
};