index: release v1.18 with only altgr index linked
[sheet.git] / word / multichoice.js
index f0520f9d428cccbcc376a89eecb7e2f2c960d884..300a32fa73e42558c886d7c7a53741eeafd81d04 100644 (file)
@@ -1,20 +1,18 @@
-class WordMultiChoice extends WordQuiz {
+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/32/${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[2], answers);
+               this.log('ask', word.id, answers.map(w => w.id));
                answers.forEach(suggest => {
-                       let label = suggest.replace(/\/.*/, '');
-                       let option = put(form, 'li', label, {onclick: () => {
-                               this.log('pick', suggest, null, word[0]);
-                               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;
@@ -26,7 +24,7 @@ class WordMultiChoice extends WordQuiz {
        }
 
        setup() {
-               this.form = document.getElementById('quiz');
+               super.setup();
                this.next();
        }
 };