Rev 6133 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
23 | reyssat | 1 | |
6133 | bpr | 2 | <h3>Examples of interactive exercises under OEF format</h3> |
23 | reyssat | 3 | |
4 | Here are some exampls of interactive exercises one can create by Createxo. |
||
5 | <ol> |
||
5900 | bpr | 6 | |
7 | <li> |
||
8 | <b>Length of vector 2D</b>, a simple computation of the length of |
||
23 | reyssat | 9 | a vector in the plane. Here is the complete source of this exercise. |
10 | |||
6133 | bpr | 11 | <pre> |
23 | reyssat | 12 | \title{Norm of vector 2D} |
13 | \language{en} |
||
14 | \computeanswer{no} |
||
15 | \format{html} |
||
16 | |||
17 | \integer{x=random(-10..10)} |
||
18 | \integer{y=random(-10..10)} |
||
19 | \real{norm=sqrt((\x)^2+(\y)^2)} |
||
20 | \statement{What is the length of the vector (\x,\y) in R<sup>2</sup>?} |
||
21 | |||
11003 | bpr | 22 | \hint{The length of a vector (x,y) is equal to |
23 | reyssat | 23 | sqrt(x^2+y^2).} |
24 | \answer{The length}{\norm} |
||
5900 | bpr | 25 | </pre> |
23 | reyssat | 26 | |
27 | In this exercise, one has defined 2 random integers, x et y, who are the |
||
28 | coordinates of the vector. Then a third parameter, this time real, is defined |
||
29 | by the formula of the length. The exercise takes a freestyle reply under the |
||
30 | name of ``the length'', and the good reply should be the value of the third |
||
31 | parameter``norm''. A hint is prepared in the exercise, which recalls the |
||
32 | formula of the length. <p> |
||
33 | You can |
||
34 | !set parm=oef_answercnt=1&oef_choicecnt=0&oef_title=Norm of vector 2D&oef_format=html&oef_computeanswer=no&level=2&oef_parms=%5Cinteger%7Bx%3Drandom%28-10..10%29%7D%0D%0A%5Cinteger%7By%3Drandom%28-10..10%29%7D%0D%0A%5Creal%7Bnorm%3Dsqrt%28%28%5Cx%29%5E2%2B%28%5Cy%29%5E2%29%7D&oef_statement=What is the length of the vector %28%5Cx%2C%5Cy%29 in R%3Csup%3E2%3C%2Fsup%3E%3F&ansprompt1=The length&ansgood1=%5Cnorm&oef_hint=The length f a vector %28x%2Cy%29 is equal to %0D%0Asqrt%28x%5E2%2By%5E2%29.&oef_solution= $ |
||
35 | !href cmd=reply&mode=guided&$parm load this example into the menu |
||
36 | to test it. (You can also copy the source into the menu under raw mode.) |
||
5900 | bpr | 37 | </p> |
38 | </li> |
||
11003 | bpr | 39 | <li> |
5900 | bpr | 40 | <b>Trace of matrix 2x2</b>, computes the trace of a matrix. The question |
11003 | bpr | 41 | is formatted by TeX, for a better presentation of the matrix. Here is |
23 | reyssat | 42 | the complete source of the exercise. |
5900 | bpr | 43 | <pre> |
23 | reyssat | 44 | \title{Trace of matrix 2x2} |
45 | \language{en} |
||
46 | \computeanswer{yes} |
||
11003 | bpr | 47 | \format{html} |
23 | reyssat | 48 | |
49 | \integer{range=20} |
||
50 | \integer{a=random(-\range..\range)} |
||
51 | \integer{b=random(-\range..\range)} |
||
52 | \integer{c=random(-\range..\range)} |
||
53 | \integer{d=random(-\range..\range)} |
||
54 | \integer{trace=(\a)+(\d)} |
||
55 | \statement{Compute the trace of the matrix |
||
11003 | bpr | 56 | \([\a,\b;\c,\d]\).} |
23 | reyssat | 57 | |
58 | \answer{The trace}{\trace} |
||
5900 | bpr | 59 | </pre> |
23 | reyssat | 60 | We have first defined an integer ``range'', to be used to bound the |
61 | random values a,b,c,d which are the elements of the matrix. And the trace is |
||
62 | of course defined by the sum of the elements on the diagonal. Please take |
||
5903 | bpr | 63 | care to the definition <span class="tt">trace=(\a)+(\d)</span>: the pairs of parentheses |
23 | reyssat | 64 | are necessary, for the substitution is literary. If you define |
11003 | bpr | 65 | <span class="tt">trace=\a+\d</span> and if a and d take the values of 3 and -15 respectively, |
5903 | bpr | 66 | you woule have <span class="tt">trace=3+-15</span>, a bad mathematical expression. <p> |
23 | reyssat | 67 | Remark that in this exercise, the non-computed replies are admitted |
68 | (such as 2+15 or 3*105). <p> |
||
69 | You can |
||
11003 | bpr | 70 | !set parm=oef_answercnt=1&oef_choicecnt=0&oef_title=Trace of matrix 2x2&oef_format=html&oef_computeanswer=yes&level=2&oef_parms=%5Cinteger%7Brange%3D20%7D%0D%0A%5Cinteger%7Ba%3Drandom%28-%5Crange..%5Crange%29%7D%0D%0A%5Cinteger%7Bb%3Drandom%28-%5Crange..%5Crange%29%7D%0D%0A%5Cinteger%7Bc%3Drandom%28-%5Crange..%5Crange%29%7D%0D%0A%5Cinteger%7Bd%3Drandom%28-%5Crange..%5Crange%29%7D%0D%0A%5Cinteger%7Btrace%3D%28%5Ca%29%2B%28%5Cd%29%7D&oef_statement=Compute the trace of the matrix \\([\a,\b;\c,\d]\\).&ansprompt1=The trace&ansgood1=%5Ctrace&oef_hint= &oef_solution= $ |
23 | reyssat | 71 | !href cmd=reply&mode=guided&$parm load this example into the menu |
72 | to test it. (You can also copy the source into the menu under raw mode.) |
||
73 | |||
5900 | bpr | 74 | </li> |
23 | reyssat | 75 | </ol> |
76 |