Rev 6133 | Rev 17348 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6133 | Rev 15107 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | ||
1 | < |
2 | <h2 class="wimscenter">Paramètres aléatoires dans un exercice interactif</h2> |
2 | <p> |
3 | <p> |
3 |
|
4 | L'utilisation de paramètres aléatoires rendra votre exercice beaucoup |
4 |
|
5 | plus intéressant, car ce sera un exercice différent chaque fois qu'il est |
5 | </p><p> |
- | |
6 | For example, the following line defines a parameter under the name of |
- | |
7 | <font color=blue><b>x1</b></font>, whose value will be a random integer |
- | |
8 | between -10 and 10 (inclusive): |
- | |
9 | </p> |
- | |
10 |
|
6 | redemandé. |
11 | \integer{x1=random(-10..10)} |
- | |
12 | </pre> |
- | |
13 | <p>This random parameter may then be called by the word |
- | |
14 | <b><span class="tt wims_code_variable">x1</span></b>, in the statement, the replis, the hint and the solution. |
- | |
15 | That is, each word <span class="tt wims_code_variable">x1</span> in these texts will be replaced |
- | |
16 | by the random value of the parameter. This substitution will also take |
- | |
17 | place in the definitions of other parameters which follow that of x1. |
- | |
18 | </p><p> |
7 | </p><p> |
- | 8 | Par exemple, la ligne suivante définit un paramètre sous le nom de |
|
- | 9 | <span class="tt wims_code_variable">x1</span>, dont la valeur sera un entier aléatoire entre |
|
19 |
|
10 | -10 et 10 (inclusif) : |
20 | </p><pre> |
11 | </p><pre> |
- | 12 | \integer{x1=random(-10..10)} |
|
- | 13 | </pre> |
|
- | 14 | Ce paramètre aléatoire peut ensuite être invoqué par le mot |
|
- | 15 | <b><span class="tt wims_code_variable">\x1</span></b>, dans l'énoncé, les réponses, l'indication et la solution. |
|
- | 16 | C'est-à-dire, chaque mot <span class="tt wims_code_variable">\x1</span> dans ces textes |
|
- | 17 | sera remplacé par la valeur aléatoire |
|
- | 18 | du paramètre. Cette substitution prend aussi effet dans les définitions |
|
- | 19 | d'autres paramètres qui suivent celle de <span class="tt wims_code_words">x1</span>. |
|
- | 20 | <p> |
|
- | 21 | Supposons maintenant que vous avez entré |
|
- | 22 | </p> |
|
- | 23 | <pre> |
|
21 | \integer{x1=random(-10..10)} |
24 | \integer{x1=random(-10..10)} |
22 | \integer{y1=\x1+3} |
25 | \integer{y1=\x1+3} |
23 | </pre> |
26 | </pre> |
24 |
|
27 | dans le champ de la définition de paramètre, et la question |
25 | <pre> |
28 | <pre> |
26 |
|
29 | Calculez la multiplication de \x1 par \y1. |
27 | </pre> |
30 | </pre> |
28 |
|
31 | <p>dans l'énoncé de l'exercice. Supposons que sur une demande de l'exercice, |
29 |
|
32 | une valeur aléatoire <span class="tt wims_code_variable">-7</span> est attribuée à \x1. Alors |
30 |
|
33 | le paramètre suivant \y1 prendra la valeur -4, et l'énoncé de l'exercice |
- | 34 | sera présenté sous la forme |
|
31 |
|
35 | </p><p class="wimscenter">Calculez la multiplication de -7 par -4. |
32 |
|
36 | </p> |
33 |
|
37 | Vous pouvez ensuite définir une réponse numérique au nom de <span class="tt">Le |
34 |
|
38 | produit</span>, ayant pour bonne solution <span class="tt">(\x1)*(\y1)</span>. (Remarquez |
35 |
|
39 | qu'ici les parenthèses sont nécessaires car la substitution se fera de façon |
- | 40 | littérale.) |
|
36 | <a id="list"></a> |
41 | <a id="list"></a> |
37 | !if oefparm isitemof $special_parm |
42 | !if oefparm isitemof $special_parm |
38 | !changeto help/oefparm.phtml |
43 | !changeto help/oefparm.phtml |
39 | !endif |
44 | !endif |
40 | $table_header |
45 | >$table_header |
41 | <caption> |
46 | <caption>Quelques autres exemples de paramètres |
42 | !href cmd=help&special_parm=$special_parm,oefparm#list [ |
47 | !href cmd=help&special_parm=$special_parm,oefparm#list [liste complète] |
43 | </caption> |
48 | </caption> |
44 | $table_hdtr<th> |
49 | $table_hdtr<th>Définition</th><th>Effet</th></tr> |
45 | $table_tr<td class="tt wims_code_words">\real{x=random(-5..5)} |
50 | $table_tr<td class="tt wims_code_words">\real{x=random(-5..5)} |
46 | </td><td>\x |
51 | </td><td>\x sera un nombre réel aléatoire<br/>entre -5 et 5 |
47 | </td></tr> |
52 | </td></tr> |
48 | $table_tr<td class="tt wims_code_words">\real{a=random(-5,-3,0.3,4)} |
53 | $table_tr<td class="tt wims_code_words">\real{a=random(-5,-3,0.3,4)} |
49 | </td><td>\a |
54 | </td><td>\a sera un nombre réel pris aléatoirement<br/>parmi -5,-3,0.3 et 4 |
50 | </td></tr> |
55 | </td></tr> |
51 | $table_tr<td class="tt wims_code_words">\complex{z=(1+2*i)^3} |
56 | $table_tr<td class="tt wims_code_words">\complex{z=(1+2*i)^3} |
52 | </td><td>\z |
57 | </td><td>\z sera le nombre complexe z=(1+2*i)^3 |
53 | </td></tr> |
58 | </td></tr> |
54 | $table_tr<td class="tt wims_code_words">\text{sign=random(+,-)} |
59 | $table_tr<td class="tt wims_code_words">\text{sign=random(+,-)} |
55 | </td><td>\sign |
60 | </td><td>\sign sera un signe aléatoire: + ou - |
56 | </td></tr> |
61 | </td></tr> |
57 | $table_tr<td class="tt wims_code_words">\integer{n=3*exp(\a)} |
62 | $table_tr<td class="tt wims_code_words">\integer{n=3*exp(\a)} |
58 | </td><td>\n |
63 | </td><td>\n sera l'entier le plus proche de 3*e<sup>\a</sup> <br/>(il dépend de la |
59 |
|
64 | valeur de \a) |
60 |
|
65 | </td></tr> |
61 |
|
66 | $table_tr<td><tt class="wims_code_words">\function{f=random<br/>(x^2+1,sin(x),log(x))}</tt> |
62 |
|
67 | </td><td>\f sera une fonction aléatoire: soit x^2+1,<br/>soit sin(x), soit |
63 | log(x) |
68 | log(x) |
64 | </td></tr> |
69 | </td></tr> |
65 | $table_tr<td class="tt wims_code_words">\real{a=evalue(x^2+sin(y),x=3,y=4)} |
70 | $table_tr<td class="tt wims_code_words">\real{a=evalue(x^2+sin(y),x=3,y=4)} |
66 |
|
71 | </td><td>Evaluation de la fonction x^2+sin(y),<br/> |
67 |
|
72 | pour x=3, y=4 |
68 | </td></tr> |
73 | </td></tr> |
69 | $table_tr<td class="tt wims_code_words">\real{r=solve(x^3-3*x+1,x=0..1)} |
74 | $table_tr<td class="tt wims_code_words">\real{r=solve(x^3-3*x+1,x=0..1)} |
70 |
|
75 | </td><td>\r sera la racine simple de x^3-3x+1 entre 0 et 1 |
71 | </td></tr> |
76 | </td></tr> |
72 | $table_tr<td class="tt wims_code_words">\function{h=simplify(x^5*y^3*x^2/y)} |
77 | $table_tr<td class="tt wims_code_words">\function{h=simplify(x^5*y^3*x^2/y)} |
73 |
|
78 | </td><td>Expression simplifiée : x<sup>7</sup>y<sup>2</sup> |
74 | </td></tr> |
79 | </td></tr> |
75 | $table_tr<td class="tt wims_code_words">\function{g=diff(sin(x)+cos(y),x)} |
80 | $table_tr<td class="tt wims_code_words">\function{g=diff(sin(x)+cos(y),x)} |
76 |
|
81 | </td><td>\g sera la dérivée de sin(x)+cos(y) par rapport à x |
77 | </td></tr> |
82 | </td></tr> |
78 | $table_tr<td class="tt wims_code_words">\function{F=int(x^2+3*x+1,x)} |
83 | $table_tr<td class="tt wims_code_words">\function{F=int(x^2+3*x+1,x)} |
79 |
|
84 | </td><td>\F sera une primitive de x^2+3*x+1,<br/> |
80 |
|
85 | le terme constant n'étant pas garanti d'être toujours le même |
81 |
|
86 | !!$table_tr<td><tt class="wims_code_words">\function{F=int(t^2+3*t+1,t=1..x)} |
82 |
|
87 | !! <td>\F sera la primitive x^2+3*x+1 telle que g(1)=0 |
83 | </td></tr> |
88 | </td></tr> |
84 | $table_tr<td class="tt wims_code_words">\real{a=int(t^2+3*t+1,t=0..1)} |
89 | $table_tr<td class="tt wims_code_words">\real{a=int(t^2+3*t+1,t=0..1)} |
85 |
|
90 | </td><td>\a sera l'intégrale numérique de x^2+3*x+1, de 0 à 1 |
86 | </td></tr> |
91 | </td></tr> |
87 | $table_tr<td class="tt wims_code_words">\text{f=htmlmath(2*x^2+3*x)} |
92 | $table_tr<td class="tt wims_code_words">\text{f=htmlmath(2*x^2+3*x)} |
88 | </td><td>\f |
93 | </td><td>\f sera rendu en html comme: 2x<sup>2</sup>+3x |
89 | </td></tr> |
94 | </td></tr> |
90 | $table_tr<td class="tt wims_code_words">\text{f=texmath(2*x^2+3*x)} |
95 | $table_tr<td class="tt wims_code_words">\text{f=texmath(2*x^2+3*x)} |
91 | </td><td>\f |
96 | </td><td>\f sera le source TeX de l'expression. |
92 | </td></tr> |
97 | </td></tr> |
93 | $table_tr<td class="tt wims_code_words">\integer{n=items(a,b,c,d,e,f)} |
98 | $table_tr<td class="tt wims_code_words">\integer{n=items(a,b,c,d,e,f)} |
94 |
|
99 | </td><td>\n sera le nombre d'articles (ici c'est 6) dans la liste |
95 | {a,b,c,d,e,f} |
100 | {a,b,c,d,e,f} |
96 |
|
101 | </td></tr> |
97 | $table_tr<td class="tt wims_code_words">\text{i=item(3,a,b,c,d,e,f)} |
102 | $table_tr<td class="tt wims_code_words">\text{i=item(3,a,b,c,d,e,f)} |
98 |
|
103 | </td><td>\i sera l'article numéro 3 de la liste |
99 | {a,b,c,d,e,f} ( |
104 | {a,b,c,d,e,f} (donc c). |
100 | </td></tr> |
105 | </td></tr> |
101 | $table_tr<td class="tt wims_code_words">\text{s=shuffle(6)} |
106 | $table_tr<td class="tt wims_code_words">\text{s=shuffle(6)} |
102 | </td><td>\s |
107 | </td><td>\s sera la liste des 6 entiers 1,2,...,6, dans un ordre aléatoire. |
103 | </td></tr> |
108 | </td></tr> |
104 | $table_tr<td class="tt wims_code_words">\text{s=shuffle(a,b,c,d,e)} |
109 | $table_tr<td class="tt wims_code_words">\text{s=shuffle(a,b,c,d,e)} |
105 | </td><td>\s |
110 | </td><td>\s sera les lettres {a,b,c,d,e} dans un ordre aléatoire. |
106 | </td></tr> |
- | |
107 | $table_tr<td class="tt wims_code_words">\matrix{m=1,2,3<br/>4,5,6<br/>7,8,9} |
- | |
108 | </td><td>\m will be the matrix of 3 rows and 3 columns. |
- | |
109 | </td></tr> |
111 | </td></tr> |
110 | $table_tr<td class |
112 | $table_tr<td><tt class="wims_code_words">\matrix{m=1,2,3<br/>4,5,6<br/>7,8,9}</tt> |
111 | </td><td> |
113 | </td><td>\m sera la matrice de 3 lignes et 3 colonnes. |
112 | </td></tr> |
114 | </td></tr> |
- | 115 | $table_tr<td class="tt wims_code_words">\text{t=asis(Comment ça va ? matrix(1,2,3))} |
|
- | 116 | </td><td>\t est la chaîne comme elle est écrite, <br/>sans transformation ni conditionalité.</td> |
|
- | 117 | </tr> |
|
113 | $table_end |
118 | $table_end |
114 | 119 | ||
115 |
|
120 | Paramètres conditionnels : vous pouvez écrire |
116 | <pre> |
121 | <pre> |
117 | \text{ttt=_condition?_def1} |
122 | \text{ttt=_condition?_def1} |
118 | \text{ttt=_condition?_def1:_def2} |
123 | \text{ttt=_condition?_def1:_def2} |
119 | </pre> |
124 | </pre> |
120 | <p> |
125 | <p> |
121 |
|
126 | Dans ce cas, <span class="tt wims_code_words">ttt</span> aura la valeur <span class="tt wims_code_words">_def1</span> si |
122 | <span class="tt |
127 | <span class="tt wims_code_words">_condition</span> s'avère vraie, ou <span class="tt wims_code_words">_def2</span> sinon (dans la seconde |
123 |
|
128 | syntaxe). |
124 |
|
129 | !href target=wims_mhelp cmd=help&special_parm=if Liste de conditions |
125 | </p><p> |
130 | </p><p> |
126 |
|
131 | La position relative d'une définition par rapport à l'énoncé est |
- | 132 | importante : si une variable est définie APRÈS l'énoncé, l'évaluation |
|
127 |
|
133 | de la variable aura lieu uniquement APRÈS que l'utilisateur ait répondu à |
128 |
|
134 | la question. Dans ce cas, la définition peut utiliser les réponses données |
129 |
|
135 | par l'utilisateur, via <span class="tt wims_code_variable">\reply1</span>, <span class="tt wims_code_variable">\reply2</span>, etc. Et la |
130 |
|
136 | variable ainsi définie peut être utilisée dans les conditions |
131 |
|
137 | de test ou les feedbacks. |
132 | </p> |
138 | </p> |