word/quiz: common base class for all subpages
[sheet.git] / word / multichoice.js
index b98842f18a074e0cc6643b4afe38f8ba6975e1a7..aa018d015294ec5f031d58c8112542795b031178 100644 (file)
@@ -1,4 +1,4 @@
-class Quiz {
+class WordMultiChoice extends WordQuiz {
        next() {
                let word = this.words.shift();
                let form = put(this.form,
@@ -21,12 +21,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() {
+               this.form = document.getElementById('quiz');
+               this.next();
        }
 };