Subversion Repositories wimsdev

Rev

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
<h3>Random parameters in an interactive exercise</h3>
2
<h2 class="wimscenter">Paramètres aléatoires dans un exercice interactif</h2>
2
<p>
3
<p>
3
The use of random parameters makes your exercise much more interesting,
4
L'utilisation de paramètres aléatoires rendra votre exercice beaucoup
4
because it will be a different exercise each time it is requested.
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
<pre>
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
Suppose now that you have entered
10
-10 et 10 (inclusif)&nbsp;:
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
in the field of the definition of parameters, and the question
27
dans le champ de la définition de paramètre, et la question
25
<pre>
28
<pre>
26
Compute the multiplication of \x1 by \y1.
29
Calculez la multiplication de \x1 par \y1.
27
</pre>
30
</pre>
28
in the statement of the exercise. Suppose that for a certain request of
31
<p>dans l'énoncé de l'exercice. Supposons que sur une demande de l'exercice,
29
the exercise, a random value <span class="wims_emph">-7</span>
32
une valeur aléatoire <span class="tt wims_code_variable">-7</span> est attribuée à \x1. Alors
30
is attributed to \x1. Then the following parameter \y1 will take the value
33
le paramètre suivant \y1 prendra la valeur -4, et l'énoncé de l'exercice
-
 
34
sera présenté sous la forme
31
-4, and the statement of the exercise will be presented under the form <div class="wimscenter">Compute the multiplication of -7 by -4.
35
</p><p class="wimscenter">Calculez la multiplication de -7 par -4.
32
</div>
36
</p>
33
You may then define a numerical reply in the name of <span class="tt">The product</span>,
37
Vous pouvez ensuite définir une réponse numérique au nom de <span class="tt">Le
34
having for the good solution <span class="tt wims_code_words">(\x1)*(\y1)</span>. (Remark that here
38
produit</span>, ayant pour bonne solution <span class="tt">(\x1)*(\y1)</span>. (Remarquez
35
the parentheses are necessary, because the substitution is done literarily.)
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>Some other examples of parameters
46
<caption>Quelques autres exemples de paramètres
42
!href cmd=help&special_parm=$special_parm,oefparm#list [complete list]
47
!href cmd=help&special_parm=$special_parm,oefparm#list [liste complète]
43
</caption>
48
</caption>
44
$table_hdtr<th>Definition</th><th>Effect</th></tr>
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 will be a random real number<br/>between -5 and 5
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 will be a real number taken randomly<br/>among -5,-3,0.3 and 4
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 will be the complex number (1+2*i)^3
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 will be a random sign: + ou -
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 will be the closest integer to 3*e<sup>\a</sup> <br/>(it depends on
63
    </td><td>\n sera l'entier le plus proche de 3*e<sup>\a</sup> <br/>(il dépend de la
59
    the value of \a)
64
    valeur de \a)
60
</td></tr>
65
</td></tr>
61
$table_tr<td class="tt wims_code_words">\function{f=random<br/> (x^2+1,sin(x),log(x))}
66
$table_tr<td><tt class="wims_code_words">\function{f=random<br/>(x^2+1,sin(x),log(x))}</tt>
62
    </td><td>\f will be a random function: either x^2+1,<br/>or sin(x), or
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
    </td><td>Evaluation of the function x^2+sin(y),<br/>
71
    </td><td>Evaluation de la fonction x^2+sin(y),<br/>
67
    for x=3, y=4
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
    </td><td>\r will the the simple root of x^3-3x+1 between 0 and 1
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
    </td><td>Simplified expression: x<sup>7</sup>y<sup>2</sup>
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
    </td><td>\g will the the derivative of sin(x)+cos(y) with respect to x
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
    </td><td>\F will an antiderivative of x^2+3*x+1,<br/>
84
    </td><td>\F sera une primitive de x^2+3*x+1,<br/>
80
     the constant term being not garanteed to be always the same
85
     le terme constant n'étant pas garanti d'être toujours le même
81
!!$table_tr<td class="tt wims_code_words">\function{F=int(t^2+3*t+1,t=1..x)}
86
!!$table_tr<td><tt class="wims_code_words">\function{F=int(t^2+3*t+1,t=1..x)}
82
!!    </td><td>\F will the antiderivative of x^2+3*x+1 with g(1)=0
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
    </td><td>\a will the numerical integral of x^2+3*x+1 from 0 to 1
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 will be rendered in html as: 2x<sup>2</sup>+3x
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 will be the TeX source for the expression.
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
    </td><td>\n will be the number of items (here it is 6) in the list
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
</td></tr>
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
    </td><td>\i will be the item number 3 of the list
103
    </td><td>\i sera l'article numéro 3 de la liste
99
     {a,b,c,d,e,f} (hence c).
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 will be the list of 6 integers 1,2,...,6, in random order.
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 will be the letters {a,b,c,d,e} in random order.
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="tt wims_code_words">\text{t=asis(How do you do? item(1,2,3))}
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>The string as it is, with no transformation nor conditionality.
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
Conditional parameters: You may write
120
Paramètres conditionnels&nbsp;: 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
In this case, <span class="tt">ttt</span> will be set to <span class="tt">_def1</span> if
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">_condition</span> is true, or to <span class="tt">_def2</span> otherwise (in the second
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
syntax).
128
syntaxe).
124
!href target=wims_mhelp cmd=help&special_parm=if List of conditions
129
!href target=wims_mhelp cmd=help&special_parm=if Liste de conditions
125
</p><p>
130
</p><p>
126
The relative positionning of the definition and the statement is important:
131
La position relative d'une définition par rapport à l'énoncé est
-
 
132
importante&nbsp;: si une variable est définie APRÈS l'énoncé, l'évaluation
127
if a variable is defined AFTER the statement, the evaluation of the variable
133
de la variable aura lieu uniquement APRÈS que l'utilisateur ait répondu à
128
will take place only AFTER the user has replied to the question. In this
134
la question. Dans ce cas, la définition peut utiliser les réponses données
129
case, the definition may involve user replies, via <span class="tt wims_code_variable">\reply1</span>,
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
<span class="tt wims_code_variable">\reply2</span>, etc. And the variable can be used in testing
136
variable ainsi définie peut être utilisée dans les conditions
131
conditions or feedbacks.
137
de test ou les feedbacks.
132
</p>
138
</p>