X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/50442220cc52bad55c1003de34f8dada958650d5..44e16a2ff933556dd5db83bdbf2315d61ce0640f:/word/multichoice.js diff --git a/word/multichoice.js b/word/multichoice.js index 761b966..300a32f 100644 --- a/word/multichoice.js +++ b/word/multichoice.js @@ -1,16 +1,18 @@ -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[2]}.jpg`, + '+img[src=$]+ul', word.thumb() ); - let answers = [word[0], this.words[0][0], this.words[1][0], this.words[2][0]] + 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[0]) { + 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; @@ -22,7 +24,7 @@ class WordMultiChoice extends WordQuiz { } setup() { - this.form = document.getElementById('quiz'); + super.setup(); this.next(); } };