X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/af99f42e425d0fd4e22d92458d5dc2049429d684..a1eb869d25a24f6f0b19e3011a19474fc0102f8c:/word/multichoice.js diff --git a/word/multichoice.js b/word/multichoice.js index aa018d0..f0520f9 100644 --- a/word/multichoice.js +++ b/word/multichoice.js @@ -1,16 +1,20 @@ class WordMultiChoice extends WordQuiz { next() { + if (this.words.length < 4) return; let word = this.words.shift(); + if (!word[2]) return this.next(); 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: () => { - if (suggest != word[2]) { + this.log('pick', suggest, null, word[0]); + if (suggest != word[0]) { // incorrect put(option, '.wrong'); return;