[LON-CAPA-users] formula response with more complex variable labels

Peter Riegler lon-capa-users@mail.lon-capa.org
Thu, 21 Jun 2007 16:49:38 +0200


Hi Jay,

both flavors of formula response seem to work on my machine (running 
2.4.1), see below. The problems by themselves are meaningless. I have 
used the templates and made T1-T2 the correct answer.

Hope that helps

Peter

<problem>
     <script type="loncapa/perl">
$k=&random(3,6,1);
$formula="a*x^$k";
$m=$k-1;
$derivative="T1-T2";
     </script>

     <startouttext />
What is the derivative of <tt>$formula</tt> with respect to x?
     <endouttext />

     <formularesponse samples="T1,T2@-3,-3:3,3#4" answer="$derivative">
         <responseparam description="Numerical Tolerance" 
type="tolerance" default="0.00001" name="tol" />
         <textline size="25" />
     </formularesponse>

</problem>

<problem>
     <script type="loncapa/perl">
$k=&random(3,6,1);
$formula="a*x^$k";
$m=$k-1;
$derivative="T1-T2";
     </script>

     <startouttext />
What is the derivative of <tt>$formula</tt> with respect to x?
     <endouttext />

     <formularesponse answer="$derivative">
         <textline size="25" />
     </formularesponse>

</problem>


Jay Sullivan wrote:

> Is is possible to do formula response with more complicated variables?
> 
> For example, let's suppose the students should enter "T1 - T2" for their 
> answer.
> It seems for now that formula response can't handle variable names that 
> contain numbers.
> 
> Jay
> 
> 

-- 
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