Gerd Kortemeyer korte at lite.msu.edu
Wed Jun 27 15:26:48 EDT 2012

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

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'; }

</customresponse>
<preduedate><solved><startouttext /><algebra>\$res1</algebra><endouttext /></solved></preduedate>
</part>
<part id="13">
<startouttext />
<p>What is
<algebra>(\$t3)*(\$t4)</algebra>
</p>
<endouttext />
<customresponse id="14">

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'; }

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