2 * questions group by index prefix 1.2.3 1.1 ...etc --> '1'
4 NOTE: questions can contain parameterized exercises (how ?
5 --> describe variables (syntax ?)
6 --> write javascript script (OK, users trusted ? ==> safe mode possible if public website)
7 Imaginary example: (using math.js)
11 M: math.matrix([[7, x], [y, -3]]);
14 <div>Calculer le déterminant de
15 $$\begin{matrix}7 & x\\y & -3\end{matrix}$$</div>
19 Vue
.component("statements", {
20 // 'inputs': array of index (as in questions) + input (text or array of ints)
21 // display: 'all', 'one', 'solution'
22 // iidx: current level-0 integer index (can match a group of questions / inputs)
23 props: ['questions','inputs','display','iidx'],
26 displayStyle: "compact", //or "all": all on same page
29 // Full questions tree is rendered, but some parts hidden depending on display settings
31 let domTree
= (this.questions
|| [ ]).map( (q
,i
) => {
32 let questionContent
= [ ];
38 "questionIndex": true,
61 let optionsOrder
= _
.range(q
.options
.length
);
63 optionsOrder
= _
.shuffle(optionsOrder
);
65 optionsOrder
.forEach( idx
=> {
72 checked: this.answers
.inputs
.length
> 0 && this.answers
.inputs
[i
][idx
],
76 id: this.inputId(i
,idx
),
80 change: e
=> { this.answers
.inputs
[i
][idx
] = e
.target
.checked
; },
83 [ '' ] //to work in Firefox 45.9 ESR @ ENSTA...
91 innerHTML: q
.options
[idx
],
94 "for": this.inputId(i
,idx
),
105 choiceCorrect: this.answers
.showSolution
&& this.questions
[i
].answer
.includes(idx
),
106 choiceWrong: this.answers
.showSolution
&& this.answers
.inputs
[i
][idx
] && !q
.answer
.includes(idx
),
113 questionContent
.push(
125 if (this.display
== "all" && !this.navigator
&& i
< this.questions
.length
-1)
126 questionContent
.push( h("hr") );
127 const depth
= (q
.index
.match(/\./g) || []).length
;
133 "hide": this.display
== "one" && this.iidx
!= i
,
134 "depth" + depth: true,
144 "hide": this.displayStyle
== "all"
156 this.index
= Math
.max(0, this.index
- 1);
160 [ h("span", { "class": { "material-icon": true } }, "fast_rewind") ]
161 ), //onclick: index = max(0,index-1)
162 h("span",{ },(this.iidx
+1).toString()),
171 this.index
= Math
.min(this.index
+1, this.questions
.length
-1)
175 [ h("span", { "class": { "material-icon": true } }, "fast_forward") ]
179 domTree
.push(navigator
);
186 this.displayStyle
= displayStyle
== "compact" ? "all" : "compact";
190 this.displayStyle
== "compact" ? "Show all" : "Navigator"
203 mounted: function() {
204 statementsLibsRefresh();
206 updated: function() {
207 statementsLibsRefresh();
210 inputId: function(i
,j
) {
211 return "q" + i
+ "_" + "input" + j
;