Subversion Repositories wimsdev

Rev

Rev 6133 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6133 Rev 17472
Line 1... Line 1...
1
<h3>Random parameters in an interactive exercise</h3>
1
<h3>Random parameters in an interactive exercise</h3>
2
 
2
<p>
3
The use of random parameters makes your exercise much more interesting,
3
The use of random parameters makes your exercise much more interesting,
4
because it will be a different exercise each time it is requested.
4
because it will be a different exercise each time it is requested.
5
<p>
5
</p><p>
6
For example, the following line defines a parameter under the name of
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
7
<span class="tt wims_code_variable">x1</span>, whose value will be a random integer
8
between -10 and 10 (inclusive):
8
between -10 and 10 (inclusive):
9
<pre>
9
</p><pre>
10
\integer{x1=random(-10..10)}
10
\integer{x1=random(-10..10)}
11
</pre>
11
</pre>
12
This random parameter may then be called by the word
12
This random parameter may then be called by the word
13
<b><span class="tt wims_code_variable">x1</span></b>, in the statement, the replis, the hint and the solution.
13
<b><span class="tt wims_code_variable">x1</span></b>, in the statement, the replies, the hint and the solution.
14
That is, each word <span class="tt wims_code_variable">x1</span> in these texts will be replaced
14
That is, each word <span class="tt wims_code_variable">x1</span> in these texts will be replaced
15
by the random value of the parameter. This substitution will also take
15
by the random value of the parameter. This substitution will also take
16
place in the definitions of other parameters which follow that of x1.
16
place in the definitions of other parameters which follow that of x1.
17
<p>
17
<p>
18
Suppose now that you have entered
18
Suppose now that you have entered
Line 40... Line 40...
40
<caption>Some other examples of parameters
40
<caption>Some other examples of parameters
41
!href cmd=help&special_parm=$special_parm,oefparm#list [complete list]
41
!href cmd=help&special_parm=$special_parm,oefparm#list [complete list]
42
</caption>
42
</caption>
43
$table_hdtr<th>Definition</th><th>Effect</th></tr>
43
$table_hdtr<th>Definition</th><th>Effect</th></tr>
44
$table_tr<td class="tt wims_code_words">\real{x=random(-5..5)}
44
$table_tr<td class="tt wims_code_words">\real{x=random(-5..5)}
45
    </td><td>\x will be a random real number<br/>between -5 and 5
45
    </td><td>\x will be a random real number<br>between -5 and 5
46
</td></tr>
46
</td></tr>
47
$table_tr<td class="tt wims_code_words">\real{a=random(-5,-3,0.3,4)}
47
$table_tr<td class="tt wims_code_words">\real{a=randitem(-5,-3,0.3,4)}
48
    </td><td>\a will be a real number taken randomly<br/>among -5,-3,0.3 and 4
48
    </td><td>\a will be a real number taken randomly<br>among -5,-3,0.3 and 4
49
</td></tr>
49
</td></tr>
50
$table_tr<td class="tt wims_code_words">\complex{z=(1+2*i)^3}
50
$table_tr<td class="tt wims_code_words">\complex{z=(1+2*i)^3}
51
    </td><td>\z will be the complex number (1+2*i)^3
51
    </td><td>\z will be the complex number (1+2*i)^3
52
</td></tr>
52
</td></tr>
53
$table_tr<td class="tt wims_code_words">\text{sign=random(+,-)}
53
$table_tr<td class="tt wims_code_words">\text{sign=randitem(+,-)}
54
    </td><td>\sign will be a random sign: + ou -
54
    </td><td>\sign will be a random sign: + ou -
55
</td></tr>
55
</td></tr>
56
$table_tr<td class="tt wims_code_words">\integer{n=3*exp(\a)}
56
$table_tr<td class="tt wims_code_words">\integer{n=3*exp(\a)}
57
    </td><td>\n will be the closest integer to 3*e<sup>\a</sup> <br/>(it depends on
57
    </td><td>\n will be the closest integer to 3*e<sup>\a</sup> <br>(it depends on
58
    the value of \a)
58
    the value of \a)
59
</td></tr>
59
</td></tr>
60
$table_tr<td class="tt wims_code_words">\function{f=random<br/> (x^2+1,sin(x),log(x))}
60
$table_tr<td class="tt wims_code_words">\function{f=randitem<br> (x^2+1,sin(x),log(x))}
61
    </td><td>\f will be a random function: either x^2+1,<br/>or sin(x), or
61
    </td><td>\f will be a random function: either x^2+1,<br>or sin(x), or
62
    log(x)
62
    log(x)
63
</td></tr>
63
</td></tr>
64
$table_tr<td class="tt wims_code_words">\real{a=evalue(x^2+sin(y),x=3,y=4)}
64
$table_tr<td class="tt wims_code_words">\real{a=evalue(x^2+sin(y),x=3,y=4)}
65
    </td><td>Evaluation of the function x^2+sin(y),<br/>
65
    </td><td>Evaluation of the function x^2+sin(y),<br>
66
    for x=3, y=4
66
    for x=3, y=4
67
</td></tr>
67
</td></tr>
68
$table_tr<td class="tt wims_code_words">\real{r=solve(x^3-3*x+1,x=0..1)}
68
$table_tr<td class="tt wims_code_words">\real{r=solve(x^3-3*x+1,x=0..1)}
69
    </td><td>\r will the the simple root of x^3-3x+1 between 0 and 1
69
    </td><td>\r will the the simple root of x^3-3x+1 between 0 and 1
70
</td></tr>
70
</td></tr>
Line 73... Line 73...
73
</td></tr>
73
</td></tr>
74
$table_tr<td class="tt wims_code_words">\function{g=diff(sin(x)+cos(y),x)}
74
$table_tr<td class="tt wims_code_words">\function{g=diff(sin(x)+cos(y),x)}
75
    </td><td>\g will the the derivative of sin(x)+cos(y) with respect to x
75
    </td><td>\g will the the derivative of sin(x)+cos(y) with respect to x
76
</td></tr>
76
</td></tr>
77
$table_tr<td class="tt wims_code_words">\function{F=int(x^2+3*x+1,x)}
77
$table_tr<td class="tt wims_code_words">\function{F=int(x^2+3*x+1,x)}
78
    </td><td>\F will an antiderivative of x^2+3*x+1,<br/>
78
    </td><td>\F will an antiderivative of x^2+3*x+1,<br>
79
     the constant term being not garanteed to be always the same
79
     the constant term being not garanteed to be always the same
80
!!$table_tr<td class="tt wims_code_words">\function{F=int(t^2+3*t+1,t=1..x)}
80
!!$table_tr<td class="tt wims_code_words">\function{F=int(t^2+3*t+1,t=1..x)}
81
!!    </td><td>\F will the antiderivative of x^2+3*x+1 with g(1)=0
81
!!    </td><td>\F will the antiderivative of x^2+3*x+1 with g(1)=0
82
</td></tr>
82
</td></tr>
83
$table_tr<td class="tt wims_code_words">\real{a=int(t^2+3*t+1,t=0..1)}
83
$table_tr<td class="tt wims_code_words">\real{a=int(t^2+3*t+1,t=0..1)}
Line 101... Line 101...
101
    </td><td>\s will be the list of 6 integers 1,2,...,6, in random order.
101
    </td><td>\s will be the list of 6 integers 1,2,...,6, in random order.
102
</td></tr>
102
</td></tr>
103
$table_tr<td class="tt wims_code_words">\text{s=shuffle(a,b,c,d,e)}
103
$table_tr<td class="tt wims_code_words">\text{s=shuffle(a,b,c,d,e)}
104
    </td><td>\s will be the letters {a,b,c,d,e} in random order.
104
    </td><td>\s will be the letters {a,b,c,d,e} in random order.
105
</td></tr>
105
</td></tr>
106
$table_tr<td class="tt wims_code_words">\matrix{m=1,2,3<br/>4,5,6<br/>7,8,9}
106
$table_tr<td class="tt wims_code_words">\matrix{m=1,2,3<br>4,5,6<br>7,8,9}
107
    </td><td>\m will be the matrix of 3 rows and 3 columns.
107
    </td><td>\m will be the matrix of 3 rows and 3 columns.
108
</td></tr>
108
</td></tr>
109
$table_tr<td class="tt wims_code_words">\text{t=asis(How do you do? item(1,2,3))}
109
$table_tr<td class="tt wims_code_words">\text{t=asis(How do you do? item(1,2,3))}
110
    </td><td>The string as it is, with no transformation nor conditionality.
110
    </td><td>The string as it is, with no transformation nor conditionality.
111
</td></tr>
111
</td></tr>