File: parameters.phtml

package info (click to toggle)
wims 2%3A4.29a%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 185,704 kB
  • sloc: xml: 366,687; javascript: 120,570; ansic: 62,341; java: 62,170; sh: 7,744; perl: 3,937; yacc: 3,217; cpp: 1,915; lex: 1,805; makefile: 1,084; lisp: 914; pascal: 601; python: 520; php: 318; asm: 7
file content (132 lines) | stat: -rw-r--r-- 6,079 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<h3>Random parameters in an interactive exercise</h3>
<p>
The use of random parameters makes your exercise much more interesting, 
because it will be a different exercise each time it is requested.
</p><p>
For example, the following line defines a parameter under the name of
<span class="tt wims_code_variable">x1</span>, whose value will be a random integer
between -10 and 10 (inclusive):
</p><pre>
\integer{x1=random(-10..10)}
</pre>
This random parameter may then be called by the word
<b><span class="tt wims_code_variable">x1</span></b>, in the statement, the replies, the hint and the solution.
That is, each word <span class="tt wims_code_variable">x1</span> in these texts will be replaced
by the random value of the parameter. This substitution will also take
place in the definitions of other parameters which follow that of x1.
<p>
Suppose now that you have entered
<pre>
\integer{x1=random(-10..10)}
\integer{y1=\x1+3}
</pre>
in the field of the definition of parameters, and the question
<pre>
Compute the multiplication of \x1 by \y1.
</pre>
in the statement of the exercise. Suppose that for a certain request of 
the exercise, a random value <font color="red">-7</font> 
is attributed to \x1. Then the following parameter \y1 will take the value
-4, and the statement of the exercise will be presented under the form <div class="wimscenter">Compute the multiplication of -7 by -4.
</div>
You may then define a numerical reply in the name of <span class="tt">The product</span>,
having for the good solution <span class="tt wims_code_words">(\x1)*(\y1)</span>. (Remark that here
the parentheses are necessary, because the substitution is done literarily.)
<a id="list"></a>
!if oefparm isitemof $special_parm
 !changeto help/oefparm.phtml
!endif
$table_header
<caption>Some other examples of parameters
!href cmd=help&special_parm=$special_parm,oefparm#list [complete list]
</caption>
$table_hdtr<th>Definition</th><th>Effect</th></tr>
$table_tr<td class="tt wims_code_words">\real{x=random(-5..5)}
    </td><td>\x will be a random real number<br>between -5 and 5
</td></tr>
$table_tr<td class="tt wims_code_words">\real{a=randitem(-5,-3,0.3,4)}
    </td><td>\a will be a real number taken randomly<br>among -5,-3,0.3 and 4
</td></tr>
$table_tr<td class="tt wims_code_words">\complex{z=(1+2*i)^3}
    </td><td>\z will be the complex number (1+2*i)^3
</td></tr>
$table_tr<td class="tt wims_code_words">\text{sign=randitem(+,-)}
    </td><td>\sign will be a random sign: + ou -
</td></tr>
$table_tr<td class="tt wims_code_words">\integer{n=3*exp(\a)}
    </td><td>\n will be the closest integer to 3*e<sup>\a</sup> <br>(it depends on
    the value of \a)
</td></tr>
$table_tr<td class="tt wims_code_words">\function{f=randitem<br> (x^2+1,sin(x),log(x))}
    </td><td>\f will be a random function: either x^2+1,<br>or sin(x), or
    log(x)
</td></tr>
$table_tr<td class="tt wims_code_words">\real{a=evalue(x^2+sin(y),x=3,y=4)}
    </td><td>Evaluation of the function x^2+sin(y),<br>
    for x=3, y=4
</td></tr>
$table_tr<td class="tt wims_code_words">\real{r=solve(x^3-3*x+1,x=0..1)}
    </td><td>\r will the the simple root of x^3-3x+1 between 0 and 1
</td></tr>
$table_tr<td class="tt wims_code_words">\function{h=simplify(x^5*y^3*x^2/y)}
    </td><td>Simplified expression: x<sup>7</sup>y<sup>2</sup>
</td></tr>
$table_tr<td class="tt wims_code_words">\function{g=diff(sin(x)+cos(y),x)}
    </td><td>\g will the the derivative of sin(x)+cos(y) with respect to x
</td></tr>
$table_tr<td class="tt wims_code_words">\function{F=int(x^2+3*x+1,x)}
    </td><td>\F will an antiderivative of x^2+3*x+1,<br>
     the constant term being not garanteed to be always the same
!!$table_tr<td class="tt wims_code_words">\function{F=int(t^2+3*t+1,t=1..x)}
!!    </td><td>\F will the antiderivative of x^2+3*x+1 with g(1)=0
</td></tr>
$table_tr<td class="tt wims_code_words">\real{a=int(t^2+3*t+1,t=0..1)}
    </td><td>\a will the numerical integral of x^2+3*x+1 from 0 to 1
</td></tr>
$table_tr<td class="tt wims_code_words">\text{f=htmlmath(2*x^2+3*x)}
    </td><td>\f will be rendered in html as: 2x<sup>2</sup>+3x
</td></tr>
$table_tr<td class="tt wims_code_words">\text{f=texmath(2*x^2+3*x)}
    </td><td>\f will be the TeX source for the expression.
</td></tr>
$table_tr<td class="tt wims_code_words">\integer{n=items(a,b,c,d,e,f)}
    </td><td>\n will be the number of items (here it is 6) in the list
     {a,b,c,d,e,f}
</td></tr>
$table_tr<td class="tt wims_code_words">\text{i=item(3,a,b,c,d,e,f)}
    </td><td>\i will be the item number 3 of the list
     {a,b,c,d,e,f} (hence c).
</td></tr>
$table_tr<td class="tt wims_code_words">\text{s=shuffle(6)}
    </td><td>\s will be the list of 6 integers 1,2,...,6, in random order.
</td></tr>
$table_tr<td class="tt wims_code_words">\text{s=shuffle(a,b,c,d,e)}
    </td><td>\s will be the letters {a,b,c,d,e} in random order.
</td></tr>
$table_tr<td class="tt wims_code_words">\matrix{m=1,2,3<br>4,5,6<br>7,8,9}
    </td><td>\m will be the matrix of 3 rows and 3 columns.
</td></tr>
$table_tr<td class="tt wims_code_words">\text{t=asis(How do you do? item(1,2,3))}
    </td><td>The string as it is, with no transformation nor conditionality.
</td></tr>
$table_end

Conditional parameters: You may write
<pre>
\text{ttt=_condition?_def1}
\text{ttt=_condition?_def1:_def2}
</pre>
<p>
In this case, <span class="tt">ttt</span> will be set to <span class="tt">_def1</span> if 
<span class="tt">_condition</span> is true, or to <span class="tt">_def2</span> otherwise (in the second
syntax).
!href target=wims_mhelp cmd=help&special_parm=if List of conditions
</p><p>
The relative positionning of the definition and the statement is important:
if a variable is defined AFTER the statement, the evaluation of the variable
will take place only AFTER the user has replied to the question. In this
case, the definition may involve user replies, via <span class="tt wims_code_variable">\reply1</span>, 
<span class="tt wims_code_variable">\reply2</span>, etc. And the variable can be used in testing
conditions or feedbacks.
</p>