refactoring, better README (breaking commit...)
[qomet.git] / public / javascripts / components / statements.js
index 5bf6bdb..0fb5124 100644 (file)
@@ -1,7 +1,25 @@
+/*
+ * questions group by index prefix 1.2.3 1.1 ...etc --> '1'
+
+NOTE: questions can contain parameterized exercises (how ?
+--> describe variables (syntax ?)
+--> write javascript script (OK, users trusted ? ==> safe mode possible if public website)
+Imaginary example: (using math.js)
+       <params> (avant l'exo)
+       x: math.random()
+       y: math.random()
+       M: math.matrix([[7, x], [y, -3]]);
+       res: math.det(M)
+       </params>
+       <div>Calculer le déterminant de 
+       $$\begin{matrix}7 & x\\y & -3\end{matrix}$$</div>
+       * ...
+*/
+
 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)
@@ -48,6 +66,7 @@ Vue.component("statements", {
                                                                change: e => { this.answers.inputs[i][idx] = e.target.checked; },
                                                        },
                                                },
+                                               [ '' ] //to work in Firefox 45.9 ESR @ ENSTA...
                                        )
                                );
                                option.push(
@@ -88,6 +107,8 @@ Vue.component("statements", {
                                        optionList
                                )
                        );
+                       if (this.answers.displayAll && i < this.questions.length-1)
+                               questionContent.push( h("hr") );
                        return h(
                                "div",
                                {
@@ -109,6 +130,9 @@ Vue.component("statements", {
                        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.