| ... |
... |
@@ -66,6 +66,10 @@ The cindyscript-environments replace the cindyscripts that you usually would put |
| 66 |
66 |
The syntax is `\begin{cindyscript}{<scriptID>} ... \end{cindyscript}` where `<scriptID>` is the ID of the script, like `csinit`, `csdraw` etc. (see [CindyJS documentation](https://cindyjs.org/ref/createCindy.html#scripts)). |
| 67 |
67 |
Within the environment you write your cindyscript commands as you would do in HTML. |
| 68 |
68 |
|
|
69 |
+<div class="alert"> |
|
70 |
+To split code for the same script across multiple blocks, just use several `\begin{cindyscript}{<scriptID>}` blocks with the same ID - they run in document order. |
|
71 |
+</div> |
|
72 |
+ |
| 69 |
73 |
|
| 70 |
74 |
|
| 71 |
75 |
# Transforming HTML-output from Cinderella to MUMIE-content |
| ... |
... |
@@ -169,12 +173,12 @@ Your result should read something like the following: |
| 169 |
173 |
\begin{cindyJS}{CSCanvas} |
| 170 |
174 |
|
| 171 |
175 |
\cindyObject[width: 600, height: 560, transform: [{visibleRect: [-9.06, 9.34, 10.06, -10.02]}], |
| 172 |
|
- background: "rgb(168,176,192), axes: false]{geometry: [ |
|
176 |
+ background: "rgb(168,176,192)", axes: false]{{geometry: [ |
| 173 |
177 |
{name: "A", type: "Free", pos: [2.08, -2.72, 4.0], color: [1.0, 0.0, 0.0], labeled: true}, |
| 174 |
178 |
{name: "B", type: "Free", pos: [4.0, -3.5, 0.76], color: [1.0, 0.0, 0.0], labeled: true}, |
| 175 |
179 |
{name: "C", type: "Free", pos: [4.0, 0.7, 0.5], color: [1.0, 0.0, 0.0], labeled: true}, |
| 176 |
180 |
{name: "S", type: "Free", pos: [4.0, -1.1, 0.88], color: [1.0, 1.0, 0.0], labeled: true} |
| 177 |
|
- ]} |
|
181 |
+ ]}} |
| 178 |
182 |
\begin{cindyscript}{csinit} |
| 179 |
183 |
S.xy = (A.xy+B.xy+C.xy)/3; |
| 180 |
184 |
\end{cindyscript} |
| ... |
... |
@@ -209,7 +213,63 @@ b=a+question{1}{t0}; |
| 209 |
213 |
would assign to a variable `a` in Cindy the value of the variable `x0` that is defined in the problem environment. The variable `b` gets as value the sum of `a` and the value of the variable `t0` that is defined in the first question of the problem. |
| 210 |
214 |
_First question_ here refers to the first question environment in your tex-document, regardless whether you are using randomquestionpools or not. |
| 211 |
215 |
|
| 212 |
|
-Also assignments of the form `A.x=question{1}{t0}` (or similar) are allowed, where `A` is a point in Cindy. |
|
216 |
+Also, assignments of the form `A.x=question{1}{t0}` (or similar) are allowed, where `A` is a point in Cindy. |
|
217 |
+ |
|
218 |
+<div class="alert"> |
|
219 |
+Do not use `problem{...}`/`question{...}{...}` for matrix variables - only number and function variables work. |
|
220 |
+</div> |
|
221 |
+ |
|
222 |
+Workaround: pass each matrix entry as its own number variable, then assemble the matrix in Cindy. Tested example: a $2\times2$ matrix $M$ is visualized as the parallelogram spanned by its columns (the image of the unit square under $M$), and the student enters its area (the determinant). |
|
223 |
+ |
|
224 |
+```LaTeX |
|
225 |
+\begin{cindyJS}{CSCanvas} |
|
226 |
+ \cindyObject[axes: true]{{geometry: [ |
|
227 |
+ {name: "O", type: "Free", pos: [0, 0, 1], color: [0.0, 0.0, 0.0], labeled: true}, |
|
228 |
+ {name: "P1", type: "Free", pos: [0, 0, 1], color: [1.0, 0.0, 0.0], labeled: true}, |
|
229 |
+ {name: "P2", type: "Free", pos: [0, 0, 1], color: [0.0, 0.0, 1.0], labeled: true}, |
|
230 |
+ {name: "P3", type: "Free", pos: [0, 0, 1], color: [0.5, 0.0, 0.5], labeled: true}, |
|
231 |
+ ]}} |
|
232 |
+ |
|
233 |
+ \begin{initialAssignments} |
|
234 |
+ a=question{1}{a}; |
|
235 |
+ b=question{1}{b}; |
|
236 |
+ c=question{1}{c}; |
|
237 |
+ d=question{1}{d}; |
|
238 |
+ \end{initialAssignments} |
|
239 |
+ |
|
240 |
+ \begin{cindyscript}{csinit} |
|
241 |
+ O.xy = [0,0]; |
|
242 |
+ P1.xy = [a,c]; |
|
243 |
+ P2.xy = [b,d]; |
|
244 |
+ P3.xy = [a+b,c+d]; |
|
245 |
+ \end{cindyscript} |
|
246 |
+ |
|
247 |
+ \begin{cindyscript}{csdraw} |
|
248 |
+ draw(O,P1); |
|
249 |
+ draw(O,P2); |
|
250 |
+ draw(P1,P3); |
|
251 |
+ draw(P2,P3); |
|
252 |
+ \end{cindyscript} |
|
253 |
+\end{cindyJS} |
|
254 |
+ |
|
255 |
+\begin{problem} |
|
256 |
+ \begin{question} |
|
257 |
+ \begin{variables} |
|
258 |
+ \number{a}{2} |
|
259 |
+ \number{b}{1} |
|
260 |
+ \number{c}{1} |
|
261 |
+ \number{d}{3} |
|
262 |
+ \function{area}{a*d-b*c} |
|
263 |
+ \end{variables} |
|
264 |
+ \text{The picture shows the parallelogram spanned by the columns of $M = \begin{pmatrix}\var{a}&\var{b}\\\var{c}&\var{d}\end{pmatrix}$, i.e. the image of the unit square under $M$. Enter the area of this parallelogram.} |
|
265 |
+ \field{real} |
|
266 |
+ \begin{answer} |
|
267 |
+ \type{input.number} |
|
268 |
+ \solution{area} |
|
269 |
+ \end{answer} |
|
270 |
+ \end{question} |
|
271 |
+\end{problem} |
|
272 |
+``` |
| 213 |
273 |
|
| 214 |
274 |
Take into account that the assignments within that environment will be executed before the csinit-script. |
| 215 |
275 |
|
| ... |
... |
@@ -245,7 +305,7 @@ We illustrate the above with a simple example ([complete tex-document](https://m |
| 245 |
305 |
|
| 246 |
306 |
\begin{cindyscript}{csinit} |
| 247 |
307 |
sign(x):= if(x>0, 1,if(x<0,-1,0)); |
| 248 |
|
- \end{cindyscript}{csinit} |
|
308 |
+ \end{cindyscript} |
| 249 |
309 |
|
| 250 |
310 |
\answer{sign(A.x)}{1,1} % value of expression will be passed to question 1, answer 1 of the problem. |
| 251 |
311 |
\answer{sign(A.y)}{1,2} % value of expression will be passed to question 1, answer 2 of the problem. |
| ... |
... |
@@ -291,7 +351,7 @@ As a warning, assume that in the above example you change the lines |
| 291 |
351 |
|
| 292 |
352 |
\begin{cindyscript}{csinit} |
| 293 |
353 |
sign(x):= if(x>0, 1,if(x<0,-1,0)); |
| 294 |
|
- \end{cindyscript}{csinit} |
|
354 |
+ \end{cindyscript} |
| 295 |
355 |
``` |
| 296 |
356 |
to |
| 297 |
357 |
```LaTeX |
| ... |
... |
@@ -302,7 +362,7 @@ to |
| 302 |
362 |
\begin{cindyscript}{csinit} |
| 303 |
363 |
A.x=a; |
| 304 |
364 |
sign(x):= if(x>0, 1,if(x<0,-1,0)); |
| 305 |
|
- \end{cindyscript}{csinit} |
|
365 |
+ \end{cindyscript} |
| 306 |
366 |
``` |
| 307 |
367 |
|
| 308 |
368 |
Initially, there is no difference to the original version. However, when pressing _Save_, apart from the properties of _A_ the value of _a_ is stored. But, the value of _a_ never changes, so when the page is reloaded, first the properties of _A_ are restored, then _a_ is set to its stored value (=initial value), and finally the csinit-script is executed and sets the x-coordinate of _A_ to this value of _a_. |
| 309 |
369 |
|