remove extra step in end assessment process
[qomet.git] / public / javascripts / components / statements.js
index 6ebea85..819d723 100644 (file)
@@ -1,7 +1,7 @@
 Vue.component("statements", {
        // 'answers' is an object containing
        //   'inputs'(array),
-       //   'displayAll'(bool),
+       //   'displayAll'(bool), //TODO: should be in questions!
        //   'showSolution'(bool),
        //   'indices': order of appearance
        //   'index': current integer index (focused question)
@@ -11,7 +11,7 @@ Vue.component("statements", {
        // Full questions tree is rendered, but some parts hidden depending on display settings
        render(h) {
                // TODO: render nothing if answers is empty
-               let domTree = this.questions.map( (q,i) => {
+               let domTree = (this.questions || [ ]).map( (q,i) => {
                        let questionContent = [ ];
                        questionContent.push(
                                h(
@@ -48,6 +48,7 @@ Vue.component("statements", {
                                                                change: e => { this.answers.inputs[i][idx] = e.target.checked; },
                                                        },
                                                },
+                                               [ '' ] //to work in Firefox 45.9 ESR @ ENSTA...
                                        )
                                );
                                option.push(
@@ -70,7 +71,7 @@ Vue.component("statements", {
                                                        "class": {
                                                                option: true,
                                                                choiceCorrect: this.answers.showSolution && this.questions[i].answer.includes(idx),
-                                                               choiceWrong: this.answers.showSolution && this.inputs[i][idx] && !q.answer.includes(idx),
+                                                               choiceWrong: this.answers.showSolution && this.answers.inputs[i][idx] && !q.answer.includes(idx),
                                                        },
                                                },
                                                option
@@ -88,12 +89,14 @@ Vue.component("statements", {
                                        optionList
                                )
                        );
+                       if (this.answers.displayAll && i < this.questions.length-1)
+                               questionContent.push( h("hr") );
                        return h(
                                "div",
                                {
                                        "class": {
                                                "question": true,
-                                               "hide": !this.answers.displayAll && this.answers.index != i,
+                                               "hide": !this.answers.displayAll && this.answers.indices[this.answers.index] != i,
                                        },
                                },
                                questionContent
@@ -106,9 +109,12 @@ Vue.component("statements", {
                                        id: "statements",
                                },
                        },
-                       questions
+                       domTree
                );
        },
+       mounted: function() {
+               statementsLibsRefresh();
+       },
        updated: function() {
                // TODO: next line shouldn't be required: questions wordings + answer + options
                // are processed earlier; their content should be updated at this time.