-class WordMultiChoice extends WordQuiz {
+class WordMultichoice extends WordQuiz {
next() {
+ if (this.words.length < 4) return;
let word = this.words.shift();
let form = put(this.form,
- '+img[src=$]+ul', `/data/word/en/${word[0]}.jpg`,
+ '+img[src=$]+ul', word.thumb()
);
- let answers = [word[2], this.words[0][2], this.words[1][2], this.words[2][2]]
+ let answers = [word, this.words[0], this.words[1], this.words[2]]
.shuffle()
+ this.log('ask', word.id, answers.map(w => w.id));
answers.forEach(suggest => {
- let label = suggest.replace(/\/.*/, '');
- let option = put(form, 'li', label, {onclick: () => {
- if (suggest != word[2]) {
+ let option = put(form, 'li', suggest.label, {onclick: () => {
+ this.log('pick', suggest.id, null, word.id);
+ if (suggest.label != word.label) {
// incorrect
put(option, '.wrong');
return;
}
setup() {
- this.form = document.getElementById('quiz');
+ super.setup();
this.next();
}
};