... |
... |
@@ -66,10 +66,6 @@ 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 |
|
-<!-- # command initialAssignments |
70 |
|
- |
71 |
|
-Some templates depend on certain variables. You can change their default values by using the command `\initialAssignments{<assignments>}`. Here `<assignments>` is a list of expressions of the form `varname=value` separated by semicolons, e.g. `\initialAssignments{a=1;b=2.1}`. These assignments will be set before your commands in the init script are evaluated. |
72 |
|
---> |
73 |
69 |
|
74 |
70 |
|
75 |
71 |
# Transforming HTML-output from Cinderella to MUMIE-content |
... |
... |
@@ -189,3 +185,125 @@ Your result should read something like the following: |
189 |
185 |
|
190 |
186 |
\end{cindyJS} |
191 |
187 |
``` |
|
188 |
+ |
|
189 |
+# Combining Cindy with MUMIE problems |
|
190 |
+ |
|
191 |
+Similar to [JSX-visualizations](JSX-Visualizations.md#using-visualizations-with-problems), you can also use Cindy in combination with MUMIE problems to enhance your exercise graphically, or to create graphical exercises. |
|
192 |
+ |
|
193 |
+The syntax of the Cindy component is the same as when used in articles. |
|
194 |
+However, there are some additional commands so that the component can interact with the problem. |
|
195 |
+ |
|
196 |
+Contrary to JSX visualizations, Cindy components can not be displayed inside the problem. |
|
197 |
+ |
|
198 |
+## Getting variable values from the problem |
|
199 |
+ |
|
200 |
+In addition to the commands and environments above, there is also the environment `\begin{initialAssignments}...\end{initialAssignments}`. |
|
201 |
+ |
|
202 |
+This environment allows for assignment of Cindy variables, and you can us values of variables from the problem there. E.g. |
|
203 |
+``` |
|
204 |
+\begin{initialAssignments} |
|
205 |
+a=problem{x0}; |
|
206 |
+b=a+question{1}{t0}; |
|
207 |
+\end{initialAssignments} |
|
208 |
+``` |
|
209 |
+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 |
+_First question_ here refers to the first question environment in your tex-document, regardless whether you are using randomquestionpools or not. |
|
211 |
+ |
|
212 |
+Also assignments of the form `A.x=question{1}{t0}` (or similar) are allowed, where `A` is a point in Cindy. |
|
213 |
+ |
|
214 |
+Take into account that the assignments within that environment will be executed before the csinit-script. |
|
215 |
+ |
|
216 |
+## Passing values to the problem as answers |
|
217 |
+ |
|
218 |
+For passing a value as answer to the problem, one uses the command `\answer{expression}{questionnr,answernr}` (see example below). `expression` has to be an expression that can be evaluated by Cindy's evalcs-function. |
|
219 |
+ |
|
220 |
+In the problem, the answer-type of the specific answer has to be set to _graphics.number_ or _graphics.function_. |
|
221 |
+The correction of answers of type _graphics.number_ is done in the same way as for _input.number_, and the correction of answers of type _graphics.function_ is done in the same way as for _input.function_. The only difference is that the student's solution is not given by input, but is passed to the problem from the Cindy component. |
|
222 |
+ |
|
223 |
+As in the `\question`-command, the value of `questionnr` in `\answer{expression}{questionnr,answernr}` is the number of the question in your tex-document, regardless whether you are using randomquestionpools or not. |
|
224 |
+ |
|
225 |
+## State of the component |
|
226 |
+ |
|
227 |
+When used with problems, on pressing the _Save_ button, also the state of the Cindy components is stored, so that it can be reloaded with the same appearance as before. |
|
228 |
+For this, the last values of the geometric components are saved, and restored before initialization. |
|
229 |
+Furthermore, in your assignments listed in `\begin{initialAssignments}...\end{initialAssignments}`, the last values of the objects on the left hand side of the assignments will be restored instead of using the given assignments. |
|
230 |
+ |
|
231 |
+You should keep that logic in mind, when creating your graphical exercises. |
|
232 |
+ |
|
233 |
+## Complete example |
|
234 |
+ |
|
235 |
+We illustrate the above with a simple example ([complete tex-document](https://miau.mumie.net/web-miau/editor/content%2Fexamples%2Fvisualizations-with-cindyJS%2Fprb_first_quadrant.src.tex)): |
|
236 |
+ |
|
237 |
+```LaTeX |
|
238 |
+\begin{cindyJS}{CSCanvas} |
|
239 |
+ \cindyObject[axes: true]{{geometry: [ |
|
240 |
+ {name: "A", type: "Free", pos: [4, -2,1], color: [1.0, 0.0, 0.0], labeled: true}, |
|
241 |
+ ]}} |
|
242 |
+ \begin{initialAssignments} |
|
243 |
+ A.x=question{1}{rand}; |
|
244 |
+ \end{initialAssignments} |
|
245 |
+ |
|
246 |
+ \begin{cindyscript}{csinit} |
|
247 |
+ sign(x):= if(x>0, 1,if(x<0,-1,0)); |
|
248 |
+ \end{cindyscript}{csinit} |
|
249 |
+ |
|
250 |
+ \answer{sign(A.x)}{1,1} % value of expression will be passed to question 1, answer 1 of the problem. |
|
251 |
+ \answer{sign(A.y)}{1,2} % value of expression will be passed to question 1, answer 2 of the problem. |
|
252 |
+ |
|
253 |
+\end{cindyJS} |
|
254 |
+ |
|
255 |
+\begin{problem} |
|
256 |
+ \begin{question} |
|
257 |
+ \begin{variables} |
|
258 |
+ \randint{rand}{1}{5} |
|
259 |
+ \function{sol}{1} |
|
260 |
+ \end{variables} |
|
261 |
+ \text{Move the point $A$ to the first quadrant.} |
|
262 |
+ \field{real} |
|
263 |
+ \begin{answer} % what is the sign of the x-coordinate of A? |
|
264 |
+ \type{graphics.number} % answer will be passed from Cindy |
|
265 |
+ \solution{sol} |
|
266 |
+ \end{answer} |
|
267 |
+ \begin{answer} % what is the sign of the y-coordinate of A? |
|
268 |
+ \type{graphics.number} % answer will be passed from Cindy |
|
269 |
+ \solution{sol} |
|
270 |
+ \end{answer} |
|
271 |
+ \explanation[[ans_1 < 0] AND [ans_2 > 0]]{Your point is in the second quadrant.} |
|
272 |
+ \explanation[[ans_1 < 0] AND [ans_2 < 0]]{Your point is in the third quadrant.} |
|
273 |
+ \explanation[[ans_1 > 0] AND [ans_2 < 0]]{Your point is in the forth quadrant.} |
|
274 |
+ \end{question} |
|
275 |
+\end{problem} |
|
276 |
+``` |
|
277 |
+ |
|
278 |
+* On initial render, the first assignment in the environment _initialAssignments_ sets the x-coordinate of the point _A_ to the value of the random integer _rand_ defined in the first question environment of the problem. |
|
279 |
+* The sign of each coordinate will be passed as an answer to the problem due to the commands `\answer{sign(A.x)}{1,1}` and `\answer{sign(A.y)}{1,2}`. |
|
280 |
+* The problem accepts these answer values due to the answer types being _graphics.number_, and compares these values for equality with the value of the variable _sol_. |
|
281 |
+* As usual in problems, the given answers can be referred to by _ans_1_ and _ans_2_, and are used in the conditions for the explanations. |
|
282 |
+* When the user presses the _Save_ button, the geometric objects (i.e. all current properties of the point A) will be stored. Due to the assignment `A.x=...;` inside the environment _initialAssignments_, the current value of _A.x_ is stored in addition. |
|
283 |
+* When the page is reloaded after the user pressed the _Save_ button, first the properties of the geometric objects will be restored. Secondly, `A.x` is set to its stored value, instead of the value of `question{1}{rand}`. Thirdly, the csinit-script is executed as it is. |
|
284 |
+ |
|
285 |
+ |
|
286 |
+As a warning, assume that in the above example you change the lines |
|
287 |
+```LaTeX |
|
288 |
+ \begin{initialAssignments} |
|
289 |
+ A.x=question{1}{rand}; |
|
290 |
+ \end{initialAssignments} |
|
291 |
+ |
|
292 |
+ \begin{cindyscript}{csinit} |
|
293 |
+ sign(x):= if(x>0, 1,if(x<0,-1,0)); |
|
294 |
+ \end{cindyscript}{csinit} |
|
295 |
+``` |
|
296 |
+to |
|
297 |
+```LaTeX |
|
298 |
+ \begin{initialAssignments} |
|
299 |
+ a=question{1}{rand}; |
|
300 |
+ \end{initialAssignments} |
|
301 |
+ |
|
302 |
+ \begin{cindyscript}{csinit} |
|
303 |
+ A.x=a; |
|
304 |
+ sign(x):= if(x>0, 1,if(x<0,-1,0)); |
|
305 |
+ \end{cindyscript}{csinit} |
|
306 |
+``` |
|
307 |
+ |
|
308 |
+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 |
+So in this case, you would not obtain the geometric state that you had when the _Save_ button was pressed. |
192 |
310 |
|