[LON-CAPA-users] Re: ERROR: Computer's answer is incorrect ("0").

Justin Gray lon-capa-users@mail.lon-capa.org
Wed, 4 May 2011 00:06:14 -0700


--20cf3054a561aaaaf304a26de589
Content-Type: text/plain; charset=ISO-8859-1

Further to this, I created a simplified version of this problem to reproduce
the error:

<problem>
    <script type="loncapa/perl">
$a=&random(1,2,1);
$b=&random(1,2,1);
$ans=$a-$b;
    </script>

    <startouttext />
Enter the answer <m eval="on">$$ans$</m>:
    <endouttext />
    <formularesponse samples="x@1:5#4" answer="$ans">
    <responseparam name="tol" type="tolerance" default="1%"
description="Numerical Tolerance" />
 <textline readonly="no">
</textline>
    </formularesponse>
</problem>

I have discovered that the error (triggered by a 0 answer) disappears when I
change the relative tolerance to an absolute tolerance.

Justin

Justin Gray | Senior Lecturer
Department of Mathematics | Simon Fraser University
8888 University Drive, Burnaby | V5A 1S6 | Canada
Tel: +1 778.782.4237







On Tue, Apr 19, 2011 at 9:09 AM, Justin Gray <jgray@math.sfu.ca> wrote:

> A local high school teacher sent me the problem below. For some reason, it
> seems to generate the following error message when the answer to either part
> is 0:
>
> *ERROR: *Computer's answer is incorrect ("0").
>
> Students that get this version of the problem receive the feedback
> Unable to understand formula
>
> The answers are calculated in Perl and evaluated using formula response
> with sampling. Can someone tell me what he needs to do to fix it? I have
> copied the XML below my signature.
>
> Many thanks,
> Justin
>
> Justin Gray | Senior Lecturer
> Department of Mathematics | Simon Fraser University
> 8888 University Drive, Burnaby | V5A 1S6 | Canada
> Tel: +1 778.782.4237
>
> <problem>
>     <script type="loncapa/perl">
> $a=&random(1,11,2)*&random(-1,1,2);
> $b=&random(2,12,2)*&random(-1,1,2);
> $c=&random(12,36,3)*&random(-1,1,2);
> $d=&random(1,20,1)*&random(-1,1,2);
> if ($b > 0) {$b = "+" . $b;}
> $xp=($c-$b*$d)/($a-$b);
> $yp=($c-$a*$d)/($b-$a);
> $xm=($c+$b*$d)/($a+$b);
> $ym=($c-$a*$d)/($b+$a);
> $i=&random(1,2,1);
> $n=&choose($i,"+","-");
> $xans=&choose($i,$xp,$xm);
> $yans=&choose($i,$yp,$ym);
>     </script>
>
>     <startouttext />
> <p> Solve the following system of linear equations. </p>
>
> <p> <m eval="on">$ $a x $b y = $c $</m> </p>
> <p> <m eval="on">$ x $n y = $d $</m> </p>
>
> <p> You can leave your answer in fractional form or convert it to a
> decimal.  You choose! </p>
> x =
>     <endouttext />
> <part id="31">
>     <formularesponse samples="x@1:5#4" answer="$xans" id="32">
>     <responseparam name="tol" type="tolerance" default="1%"
> description="Numerical Tolerance" />
>
>         <textline readonly="no" size="20" />
>     </formularesponse>
> </part>
>
> <part id="33">
>     <startouttext />
> y =
>     <endouttext />
>
>     <formularesponse samples="x@1:5#4" answer="$yans" id="34">
>     <responseparam name="tol" type="tolerance" default="1%"
> description="Numerical Tolerance" />
>
>         <textline readonly="no" size="20" />
>     </formularesponse>
> </part>
> </problem>
>
>
>
>
>

--20cf3054a561aaaaf304a26de589
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Further to this, I created a simplified version of this problem to reproduc=
e the error:<div><br></div><div><div>&lt;problem&gt;</div><div>=A0=A0 =A0&l=
t;script type=3D&quot;loncapa/perl&quot;&gt;</div><div>$a=3D&amp;random(1,2=
,1);</div>

<div>$b=3D&amp;random(1,2,1);</div><div>$ans=3D$a-$b;</div><div>=A0=A0 =A0&=
lt;/script&gt;</div><div><br></div><div>=A0=A0 =A0&lt;startouttext /&gt;</d=
iv><div>Enter the answer &lt;m eval=3D&quot;on&quot;&gt;$$ans$&lt;/m&gt;:</=
div><div>=A0=A0 =A0&lt;endouttext /&gt;</div>

<div>=A0=A0 =A0&lt;formularesponse samples=3D&quot;x@1:5#4&quot; answer=3D&=
quot;$ans&quot;&gt;</div><div>=A0=A0 =A0&lt;responseparam name=3D&quot;tol&=
quot; type=3D&quot;tolerance&quot; default=3D&quot;1%&quot; description=3D&=
quot;Numerical Tolerance&quot; /&gt;</div>

<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">		</span>&lt;=
textline readonly=3D&quot;no&quot;&gt;</div><div><span class=3D"Apple-tab-s=
pan" style=3D"white-space:pre">		</span>&lt;/textline&gt;</div><div>=A0=A0 =
=A0&lt;/formularesponse&gt;</div>

<div>&lt;/problem&gt;</div><div><br></div><div>I have discovered that the e=
rror (triggered by a 0 answer) disappears when I change the relative tolera=
nce to an absolute tolerance.</div><div><br></div><div>Justin</div><div>

<br></div><div>Justin Gray | Senior Lecturer</div>Department of Mathematics=
 | Simon Fraser University<br>8888 University Drive, Burnaby | V5A 1S6 | Ca=
nada<br>Tel: +1 778.782.4237<br><br><div><br></div><div><br><div><br></div>

</div><br>
<br><br><div class=3D"gmail_quote">On Tue, Apr 19, 2011 at 9:09 AM, Justin =
Gray <span dir=3D"ltr">&lt;<a href=3D"mailto:jgray@math.sfu.ca">jgray@math.=
sfu.ca</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"=
margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

A local high school teacher sent me the problem below. For some reason, it =
seems to generate the following error message when the answer to either par=
t is 0:<div><br></div><div><span style=3D"font-family:Verdana, Arial, Helve=
tica, sans-serif;font-size:19px;color:rgb(255, 0, 0)"><b>ERROR:=A0</b>Compu=
ter&#39;s answer is incorrect (&quot;0&quot;).</span></div>


<div><font color=3D"#FF0000" face=3D"Verdana, Arial, Helvetica, sans-serif"=
 size=3D"6"><span style=3D"font-size:19px"><br></span></font></div><div>Stu=
dents that get this version of the problem receive the feedback=A0</div>
<div><span style=3D"font-family:Times;font-size:medium">Unable to understan=
d formula</span></div><div><div><br></div>
<div>The answers are calculated in Perl and evaluated using formula respons=
e with sampling. Can someone tell me what he needs to do to fix it? I have =
copied the XML below my signature.</div><div><br></div><div>Many thanks,</d=
iv>


<div>Justin</div><div><br></div><div>Justin Gray | Senior Lecturer</div>Dep=
artment of Mathematics | Simon Fraser University<br>8888 University Drive, =
Burnaby | V5A 1S6 | Canada<br>Tel: <a href=3D"tel:%2B1%20778.782.4237" valu=
e=3D"+17787824237" target=3D"_blank">+1 778.782.4237</a><br>

<br><div><div>&lt;problem&gt;</div>
<div>=A0=A0 =A0&lt;script type=3D&quot;loncapa/perl&quot;&gt;</div><div>$a=
=3D&amp;random(1,11,2)*&amp;random(-1,1,2);</div><div>$b=3D&amp;random(2,12=
,2)*&amp;random(-1,1,2);</div><div>$c=3D&amp;random(12,36,3)*&amp;random(-1=
,1,2);</div>


<div>$d=3D&amp;random(1,20,1)*&amp;random(-1,1,2);</div><div>if ($b &gt; 0)=
 {$b =3D &quot;+&quot; . $b;}</div><div>$xp=3D($c-$b*$d)/($a-$b);</div><div=
>$yp=3D($c-$a*$d)/($b-$a);</div><div>$xm=3D($c+$b*$d)/($a+$b);</div><div>$y=
m=3D($c-$a*$d)/($b+$a);</div>


<div>$i=3D&amp;random(1,2,1);</div><div>$n=3D&amp;choose($i,&quot;+&quot;,&=
quot;-&quot;);</div><div>$xans=3D&amp;choose($i,$xp,$xm);</div><div>$yans=
=3D&amp;choose($i,$yp,$ym);</div><div>=A0=A0 =A0&lt;/script&gt;</div><div><=
br></div><div>


=A0=A0 =A0&lt;startouttext /&gt;</div><div>&lt;p&gt; Solve the following sy=
stem of linear equations. &lt;/p&gt;</div><div><br></div><div>&lt;p&gt; &lt=
;m eval=3D&quot;on&quot;&gt;$ $a x $b y =3D $c $&lt;/m&gt; &lt;/p&gt;</div>=
<div>

&lt;p&gt; &lt;m eval=3D&quot;on&quot;&gt;$ x $n y =3D $d $&lt;/m&gt; &lt;/p=
&gt;</div>
<div><br></div><div>&lt;p&gt; You can leave your answer in fractional form =
or convert it to a decimal. =A0You choose! &lt;/p&gt;</div><div>x =3D</div>=
<div>=A0=A0 =A0&lt;endouttext /&gt;</div><div>&lt;part id=3D&quot;31&quot;&=
gt;</div>


<div>=A0=A0 =A0&lt;formularesponse samples=3D&quot;x@1:5#4&quot; answer=3D&=
quot;$xans&quot; id=3D&quot;32&quot;&gt;</div><div>=A0=A0 =A0&lt;responsepa=
ram name=3D&quot;tol&quot; type=3D&quot;tolerance&quot; default=3D&quot;1%&=
quot; description=3D&quot;Numerical Tolerance&quot; /&gt;</div>


<div>=A0=A0 =A0</div><div>=A0=A0 =A0 =A0 =A0&lt;textline readonly=3D&quot;n=
o&quot; size=3D&quot;20&quot; /&gt; =A0 =A0</div><div>=A0=A0 =A0&lt;/formul=
aresponse&gt;</div><div>&lt;/part&gt;</div><div><br></div><div>&lt;part id=
=3D&quot;33&quot;&gt;</div><div>


=A0=A0 =A0&lt;startouttext /&gt;</div><div>y =3D</div><div>=A0=A0 =A0&lt;en=
douttext /&gt;</div><div><br></div><div>=A0=A0 =A0&lt;formularesponse sampl=
es=3D&quot;x@1:5#4&quot; answer=3D&quot;$yans&quot; id=3D&quot;34&quot;&gt;=
</div><div>=A0=A0 =A0&lt;responseparam name=3D&quot;tol&quot; type=3D&quot;=
tolerance&quot; default=3D&quot;1%&quot; description=3D&quot;Numerical Tole=
rance&quot; /&gt;</div>


<div>=A0=A0 =A0</div><div>=A0=A0 =A0 =A0 =A0&lt;textline readonly=3D&quot;n=
o&quot; size=3D&quot;20&quot; /&gt; =A0 =A0</div><div>=A0=A0 =A0&lt;/formul=
aresponse&gt;</div><div>&lt;/part&gt;</div><div>&lt;/problem&gt;</div></div=
><div><br></div><div><br>

<div>
<br></div></div><br>
</div>
</blockquote></div><br></div>

--20cf3054a561aaaaf304a26de589--