[LON-CAPA-users] Having an equation or a range as a response

Gerd Kortemeyer korte at lite.msu.edu
Sat Jan 21 22:52:55 EST 2012


On Jan 20, 2012, at 1:49 PM, Seema Ali wrote:

> I'm also super new to Maxima, but can it factor out constants from an expression?  Or could you create a fraction between the left and right side, reduce it and then see if it is the simplified version? Of course being carfeul not to divide by zero. 

I think I got it, please test. If this is good, I might turn it into a template and/or a new responsetype.

Gotta love MAXIMA :-)

- Gerd.

<script type="loncapa/perl">
$sample="x=$b or y=$a*x would be correct";

sub compareequations {
    my ($var,$value,$equation)=@_;
# var is the variable given
# value is the expected value of $var, $var=$value
# equation is the equation to be tested
    if ($reply=~/^Error\:/) { return $reply; }
    if ($reply=~/true/) { return 'true'; }
    return 'false';

<startouttext />
Given an equation for an asymptote of <m eval="on">\[y=$a\cdot x+\frac{1}{x-$b}\]</m>
<endouttext />

<customresponse answerdisplay="$sample">

<answer type="loncapa/perl">
if ($first=~/^Error/) { return 'BAD_FORMULA'; }
if ($first=~/true/) { return 'EXACT_ANS'; }

if ($second=~/^Error/) { return 'BAD_FORMULA'; }
if ($second=~/true/) { return 'EXACT_ANS'; }

return 'INCORRECT';</answer>

    <textline readonly="no" />


More information about the LON-CAPA-users mailing list