Annotation of loncom/html/adm/help/tex/Creating_Math_Response_Problems.tex, revision 1.6

1.6     ! damieng     1: \label{Creating_Math_Response_Problems}\index{Math Response}
1.1       lira        2: 
1.2       lira        3: Math response problems use a cas system to evaluate the student response. Which computer algebra system is to 
                      4: be used is specified in the cas argument of the mathresponse tag; both Maxima and R are supported. Maxima and R 
1.3       raeburn     5: are also powerful stand-alone programs that can be installed on most operating systems. If you are interested 
1.2       lira        6: in writing Maxima or R problems, it is a good idea to install a copy on your operating system to access help, 
                      7: learn syntax, and test your expected responses outside the LON-CAPA environment. 
1.5       lira        8: See \texttt{http://maxima.sourceforge.net/} or \texttt{http://www.r-project.org/} .
1.1       lira        9: 
1.4       raeburn    10: LON-CAPA will accept two pre-named arrays inside the answerblock for the computer algebra system: RESPONSE and LONCAPALIST. RESPONSE contains the student input by comman-separated entities, for example, if ``3,42,17'' is entered by the student, RESPONSE[2] would be 42. LONCAPALIST is built from the arguments passed in an array \texttt{args} which is assigned a array value from the script.
1.2       lira       11: 
1.4       raeburn    12: The \texttt{answer} tag contains the Maxima command (and syntax) that are passed to Maxima after the RESPONSE and LONCAPALIST values are substituted. (See example below). The \texttt{answerdisplay} variable contains what is displayed when the problem is in ``Show Answer'' mode. You will want to include this field so that the students can see the correct answer after the ``Show Answer Date'' configured when the problem is assigned in the course space. Also note the description in the \texttt{postanswerdate}\index{postanswerdate} tag that is displayed after the answer date.
1.1       lira       13: 
                     14: The following example illustrates this.
                     15: \begin{verbatim}
                     16: <problem>
                     17:   <script type="loncapa/perl">
                     18: $a1 = random(-6,6,4);
                     19: $a2 = random(-6,6,4);
                     20: $n1 = random(3,11,2);
                     21: $n2 = random(2,10,2);
                     22: $function = "$a1*cos($n1*x)+$a2*sin($n2*x)";
1.2       lira       23: # reformat next two lines as single line if you copy/paste into a script
                     24: $example=&xmlparse('An example would be 
                     25: <m eval="on">$(sin($n1\cdot x)+cos($n2\cdot x))/\sqrt{2}$</m>');
1.1       lira       26:   </script>
                     27: 
                     28: <startouttext />
                     29:   Give an example of a function
                     30:   <ol>
                     31:     <li>
                     32:         which is orthogonal to <algebra>$function</algebra> with respect to the
                     33:         scalar product
                     34:         <m>
                     35:            \[<g \mid h> =
                     36:                \frac{1}{\pi} \int_{-\pi}^{\pi}dx g(x) \cdot h(x)\]
                     37:         </m>
                     38:     </li>
                     39:     <li>
                     40:         whose norm is 1.
                     41:     </li>
                     42:   </ol>
                     43: <endouttext />
                     44: 
                     45: <mathresponse answerdisplay="$example" cas="maxima" args="$function">
                     46:     <answer>
                     47: overlap:integrate((RESPONSE[1])*(LONCAPALIST[1]),x,-%pi,%pi)/%pi;
                     48: norm:integrate((RESPONSE[1])*(RESPONSE[1]),x,-%pi,%pi)/%pi;
                     49: is(overlap=0 and norm=1);
                     50:     </answer>
                     51:     <textline readonly="no" size="50" />
                     52:     <hintgroup showoncorrect="no">
                     53:         <mathhint name="ortho" args="$function" cas="maxima">
                     54:             <answer>
                     55: overlap: integrate((LONCAPALIST[1])*(RESPONSE[1]),x,-%pi,%pi)/%pi;
                     56: is(not overlap = 0);
                     57:             </answer>
                     58:         </mathhint>
                     59:         <mathhint name="norm" args="$function" cas="maxima">
                     60:             <answer>
                     61: norm: integrate((RESPONSE[1])*(RESPONSE[1]),x,-%pi,%pi)/%pi;
                     62: is(not norm = 1);
                     63:             </answer>
                     64:         </mathhint>
                     65:         <hintpart on="norm">
                     66:            <startouttext />
                     67: The function you have provided does not have a norm of one.
                     68:            <endouttext />
                     69:         </hintpart>
                     70:         <hintpart on="ortho">
                     71:             <startouttext />
                     72: The function you have provided is not orthogonal.
                     73:             <endouttext />
                     74:         </hintpart>
                     75:     </hintgroup>
                     76: </mathresponse>
                     77: 
                     78: 
                     79: <postanswerdate>
                     80:     <startouttext />
                     81:         <p>
                     82: Note that with respect to the above norm, <m>$\cos(nx)$</m> is perpendicular
                     83: to <m>$\sin(nx)$</m> and perpendicular to <m>$\cos(mx)$</m> for
                     84: <m>$n\ne m$</m>.
                     85:         </p>
                     86:     <endouttext />
                     87: </postanswerdate>
                     88: </problem>
                     89: \end{verbatim}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>