File:  [LON-CAPA] / loncom / html / adm / help / tex / Creating_Math_Response_Problems.tex
Revision 1.6: download - view: text, annotated - select for diffs
Mon Jan 23 20:29:42 2017 UTC (7 years, 6 months ago) by damieng
Branches: MAIN
CVS tags: version_2_12_X, version_2_11_X, version_2_11_5_msu, version_2_11_5, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, HEAD
doc improved for editors, responses, index

    1: \label{Creating_Math_Response_Problems}\index{Math Response}
    2: 
    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 
    5: are also powerful stand-alone programs that can be installed on most operating systems. If you are interested 
    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. 
    8: See \texttt{http://maxima.sourceforge.net/} or \texttt{http://www.r-project.org/} .
    9: 
   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.
   11: 
   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.
   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)";
   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>');
   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>