[LON-CAPA-dev] How does formularesponse work
Peter Riegler
lon-capa-dev@mail.lon-capa.org
Tue, 22 May 2007 11:20:25 +0200
Hi,
we have a problem using formula response here, which brings up the
question how it works internally. Unfortunately, I am not really capable
of understanding what is going on in caparesponse.pm.
So far, my idea of formularesponse has been that it runs nested
for-loops w.r.t. the sampling variables. For instance,
<formularesponse samples="x,y@-3,-3,;2,2#4" answer="$answer" id="11">
should result in something like
for each x value
for each y value
check whether $answer evaluated at x and y equals
response evaluated at x an y
if not break out of the for loops and return false
end
end
However, we experience that
answer = sin(x)
response = sin(y)
evaluates to true in formularesponse IF you use the same sampling points
for x and y.
I will attach a loncapa problem below. The text is German. The task is
simply to give the integral including integration constant.
Peter
<problem>
<script type="loncapa/perl">
#
# Stammfunktion einer trigonometrischen Funktion mit kostantem
Vorfaktor vor der Funktion und im Argument
#
# Setzen der möglichen Vorfaktoren, Variablen und trigonometrischen
Funktionen
# $fakt - Vorfaktor vor Funktion
# $argfalt - Vorfaktor im Argument
# $funktion - Art der trigonometrischen Funktion
# $var - Variable
$fakt=&random(2,8,1);
$argfakt=&random(1,5,1);
$funktion=&choose(&random(1,2,1),"sin","cos");
$var=&choose(&random(1,3,1),"x","z","t");
# zu intrgrierende Formel
#$formula="$fakt*$funktion($argfakt*$var)";
# Bestimmen der Art der trigonometrischen Stammfunktion und ihres
Vorzeichens
if( $funktion eq "sin") {
$intfakt=-1;
$intfunkt="cos"; }
elsif( $funktion eq "cos") {
$intfakt=1;
$intfunkt="sin"; }
# Endgültiger Vorfaktor der Stammfunktion
$intfakt=$intfakt*$fakt/$argfakt;
# Richtiges Ergebnis
$integral="$intfakt*$intfunkt($argfakt*$var)+ C";</script>
<startouttext />Bestimmen Sie folgende Stammfunktion. Bezeichnen Sie die
Integrationskonstante mit C.
<br> </br>
<m eval="on"> \int ( \, $fakt \, $funktion ( $argfakt*$var) ) \,
d$var </m>
<br> </br><endouttext />
<formularesponse samples="x,z,t,C@-3,-3,-3,-3;2,2,2,2#4"
answer="$integral" id="11">
<responseparam name="tol" type="tolerance" default="0.00001"
description="Numerical Tolerance" />
<textline readonly="no" size="25" />
</formularesponse>
</problem>
--
Peter Riegler
Fachhochschule Braunschweig/Wolfenbüttel
Salzdahlumer Str. 46/48, 38302 Wolfenbüttel
Tel. +49 5331 939 6314, Fax. +49 5331 939 6002
email: p.riegler@fh-wolfenbuettel.de
http://public.rz.fh-wolfenbuettel.de/~riegler