X-Git-Url: https://git.auder.net/img/rock_paper_scissors_lizard_spock.gif?a=blobdiff_plain;f=public%2Fjavascripts%2Fcomponents%2Fstatements.js;h=67aaf1212db575e3e003ce24829e694ef67fc184;hb=e49ec3e4b6e8211edb96928d225c23fd05ab548d;hp=6ebea85f1c94b55d1a7cd6f3083afe6ec16c1456;hpb=8a51dbf760226cbe6bddc44cddef2262c4945f5d;p=qomet.git diff --git a/public/javascripts/components/statements.js b/public/javascripts/components/statements.js index 6ebea85..67aaf12 100644 --- a/public/javascripts/components/statements.js +++ b/public/javascripts/components/statements.js @@ -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( @@ -70,7 +70,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 +88,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 +108,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.