[LON-CAPA-users] Simple math advice

Lucas, Mark lucasm at ohio.edu
Wed Jun 27 15:50:45 EDT 2012


Thanks!
On Jun 27, 2012, at 3:26 PM, Gerd Kortemeyer wrote:

Hi,

On Jun 27, 2012, at 3:24 PM, Lucas, Mark wrote:

I've got a colleague who wants to write a formularesponse problem such as the
following:

Simplify -18(v+44)

The problem is that the student should not be able to just type the question in and
have it come right. He wants it reduced.

Is there a simple way to require this using maxima?

Simple: unfortunately no
MAXIMA: yes

See attached. It uses customresponse to first check for unwanted stuff like parenthesis, and then compares the terms using MAXIMA.

-Gerd.

<problem>

<script type="loncapa/perl">
($t1,$t2,$t3,$t4)=&random_permutation(&random(0,1000,1),(
'a+b^2',
'a+2*b',
'a-4*b',
'3*a^2+b',
'a^2+2*c',
'a^2+3*c^2',
'2*c-a'));
$res1=&cas('maxima',"expand(($t1)*($t2))");
$res2=&cas('maxima',"expand(($t3)*($t4))");
</script>

<startouttext />
<h1>Multiplying Terms</h1>
<endouttext />
<part id="11">
<startouttext />
<p>What is
<algebra>($t1)*($t2)</algebra>
</p>
<endouttext />
<customresponse id="12">
<textline readonly="no" size="70" />


   <answer type="loncapa/perl">if ($submission=~/\,/) { return 'EXTRA_ANSWER'; }
if ($submission=~/\)/) { return 'WRONG_FORMAT'; }
if ($submission=~/\(/) { return 'WRONG_FORMAT'; }
$diff=&cas('maxima',"trigsimp(trigreduce(($t1)*($t2)-($submission)))");
if ($diff=~/^Error/) { return 'BAD_FORMULA'; }
if ($diff eq '0') { return 'EXACT_ANS'; }
return 'INCORRECT';</answer>

</customresponse>
<preduedate><solved><startouttext /><algebra>$res1</algebra><endouttext /></solved></preduedate>
<postanswerdate><startouttext /><algebra>$res1</algebra><endouttext /></postanswerdate>
</part>
<part id="13">
<startouttext />
<p>What is
<algebra>($t3)*($t4)</algebra>
</p>
<endouttext />
<customresponse id="14">
<textline readonly="no" size="70" />


   <answer type="loncapa/perl">if ($submission=~/\,/) { return 'EXTRA_ANSWER'; }
if ($submission=~/\)/) { return 'WRONG_FORMAT'; }
if ($submission=~/\(/) { return 'WRONG_FORMAT'; }
$diff=&cas('maxima',"trigsimp(trigreduce(($t3)*($t4)-($submission)))");
if ($diff=~/^Error/) { return 'BAD_FORMULA'; }
if ($diff eq '0') { return 'EXACT_ANS'; }
return 'INCORRECT';</answer>

</customresponse>
<preduedate><solved><startouttext /><algebra>$res2</algebra><endouttext /></solved></preduedate>
<postanswerdate><startouttext /><algebra>$res2</algebra><endouttext /></postanswerdate>
</part>
</problem>




_______________________________________________
LON-CAPA-users mailing list
LON-CAPA-users at mail.lon-capa.org<mailto:LON-CAPA-users at mail.lon-capa.org>
http://mail.lon-capa.org/mailman/listinfo/lon-capa-users

--
Mark Lucas  email: lucasm at ohiou.edu<mailto:lucasm at ohiou.edu>
252D Clippinger Lab phone: (740)597-2984
Department of Physics and Astronomy fax: (740)593-0433
Ohio University
Athens, OH 45701

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.lon-capa.org/pipermail/lon-capa-users/attachments/20120627/39718158/attachment.html>


More information about the LON-CAPA-users mailing list