[LON-CAPA-cvs] cvs: doc /help codingmath.tex
riegler
lon-capa-cvs-allow@mail.lon-capa.org
Fri, 12 Sep 2008 02:22:26 -0000
riegler Thu Sep 11 22:22:26 2008 EDT
Modified files:
/doc/help codingmath.tex
Log:
replaced example for mathresponse with one easier to digest
Index: doc/help/codingmath.tex
diff -u doc/help/codingmath.tex:1.1 doc/help/codingmath.tex:1.2
--- doc/help/codingmath.tex:1.1 Tue Sep 9 22:12:09 2008
+++ doc/help/codingmath.tex Thu Sep 11 22:22:23 2008
@@ -21,9 +21,64 @@
\subsection{{\tt <mathresponse>}-interface}
-\input{Math_Response_Problems.tex}
+{\tt <mathresponse>} is a way to have a problem graded based on an algorithm that is executed inside of a computer algebra system.
+The documentation of \LC points out that use of this response type is
+generally discouraged, since the responses will not be analyzable by the LON-CAPA statistics tools. Yet, it can be useful.
+
+Which computer algebra system is to be used is specified in the cas argument of the mathresponse tag; currently, only Maxima is available.
+LON-CAPA sets up two arrays inside the computer algebra system: RESPONSE and LONCAPALIST. RESPONSE contains the student input by component, for example, if "3,42,17" is entered, RESPONSE[2] would be 42. LONCAPALIST contains the arguments passed in the args of mathresponse.
+
+The answerdisplay is what is displayed when the problem is in "Show Answer" mode.
+
+The following example illustrates this. It is a simplified version of \begin{verbatim} /res/msu/kashy/physicsLib02/02_Math_2_Trig/LinethroughPt2.problem\end{verbatim}.
+
+\begin{verbatim}
+<problem>
+<script type="loncapa/perl">
+$x = &random(-1,1,2) * &random(1,5,1);
+$y = &random(-1,1,2) * &random(1,4,1);
+if(&abs($x)==&abs($y)){$x=$y+1;}
+# avoids y=x and y=-x as possible solutions
+@args = ($x, $y);
+# This is passed to the CAS, where it will be
+# LONCAPALIST[1], LONCAPALIST[2]
+
+# In the <answer> block below, RESPONSE[1] is the
+# student's submission (a scalar, e.g., 3x + 2 ).
+
+# The two lines below provide a varying sample function,
+# y(x)=mx+b, to be displayed when a correct answer is entered.
+
+$m=&random(2,5)*&random(-1,1,2);
+$b = $y-$m*$x;
+if($b > 0){$b = "+ " . $b;}
+elsif ($b == 0) {$yb = "";}
+elsif ($b < 0) {$yb = "- " . $b;}
+$example = "$m x $b is an example of the many functions that
+ meet the criteria above.";
+</script>
+
+<startouttext />
+State a function y(x) which passes through the point ($x, $y)
+and which has a constant slope with absolute value > 1.<br />
+<endouttext />
+<mathresponse answerdisplay="$example" cas="maxima" args="@args">
+
+<answer>
+y(x):=RESPONSE[1];
+thrupoint:is(abs(y(LONCAPALIST[1]) - LONCAPALIST[2]) <= 0.000000001);
+islinear:is(diff(y(x),x,2) = 0);
+AbsSlopeGT1:is(abs(diff(y(x),x,1)) > 1);
+thrupoint and islinear and AbsSlopeGT1;
+</answer>
+
+<b>y(x)</b> = <textline readonly="no" size="20" />
+
+</mathresponse>
+</problem>
+
+\end{verbatim}
-{\bf a simpler example might be more appriopriate here}
\section{Interface to maxima}
\LC servers run several maxima sessions in parallel. There is a queue which distributes CAS calls to these sessions. When processing a new CAS call one has to be sure that maxima is reset to some default state. In particular functions, variables etc.\ defined in previous calls should be removed. LON-CAPA automatically takes care of that by means of the following sequence of commands which is executed every time before a maxima code snippet supplied by an author will be executed:
\begin{quote}