'update'
[qomet.git] / public / javascripts / components / statements.js
index 64057f9..86138c0 100644 (file)
@@ -15,6 +15,8 @@ Imaginary example: (using math.js)
        $$\begin{matrix}7 & x\\y & -3\end{matrix}$$</div>
        * ...
 
++ fixed + question time (syntax ?)
+
 --> input of type text (number, or vector, or matrix e.g. in R syntax)
 --> parameter stored in question.param (TODO)
 
@@ -24,10 +26,11 @@ Vue.component("statements", {
        // 'inputs': object with key = question index and value = text or boolean array
        // display: 'all', 'one', 'solution'
        // iidx: current level-0 integer index (can match a group of questions / inputs)
-       props: ['questions','inputs','display','iidx'],
+       props: ['questions','inputs','answers','display','iidx'],
        data: function() {
                return {
                        displayStyle: "compact", //or "all": all on same page
+                       parameters: 0, //TODO: DO NOT re-draw parameters for already answered questions
                };
        }
        // Full questions tree is rendered, but some parts hidden depending on display settings
@@ -91,8 +94,8 @@ Vue.component("statements", {
                                                                "input",
                                                                {
                                                                        domProps: {
-                                                                               checked: this.inputs[q.index][idx],
-                                                                               disabled: monitoring,
+                                                                               checked: !!this.inputs && this.inputs[q.index][idx],
+                                                                               disabled: monitoring || this.display == "solution",
                                                                        },
                                                                        attrs: {
                                                                                id: this.inputId(q.index,idx),
@@ -118,14 +121,15 @@ Vue.component("statements", {
                                                                }
                                                        )
                                                );
+                                               const aIdx = (this.answers || [ ]).findIndex( item => { return item.index == q.index; });
                                                optionList.push(
                                                        h(
                                                                "div",
                                                                {
                                                                        "class": {
                                                                                option: true,
-                                                                               choiceCorrect: this.display == "solution" && q.answer.includes(idx),
-                                                                               choiceWrong: this.display == "solution" && this.inputs[q.index][idx] && !q.answer.includes(idx),
+                                                                               choiceCorrect: this.display == "solution" && this.answers[aIdx].includes(idx),
+                                                                               choiceWrong: this.display == "solution" && !!this.inputs && this.inputs[q.index][idx] && !this.answers[aIdx].includes(idx),
                                                                        },
                                                                },
                                                                option
@@ -144,6 +148,10 @@ Vue.component("statements", {
                                                )
                                        );
                                }
+                               else
+                               {
+                                       // Open question, or parameterized: TODO
+                               }
                                const depth = (q.index.match(/\./g) || []).length;
                                return h(
                                        "div",