[LON-CAPA-users] Code to accept multiple answers

Peter Dencker dencker at math.uni-luebeck.de
Wed Jun 17 14:05:04 EDT 2015



Hi David,

define 'ln(x):=log(x)'. (See my example below.)

The maxima function  'radcan' simplifies expressions in maxima, which 
can contain logs, exponentials, and radicals, so it may helpful. (It is 
not needed in your specific example but can help to compare more subtle 
examples.

- Peter

<problem>

<script type="loncapa/perl">
   our $result = "4*ln(1/2)";
</script>

<part id="p0">
<customresponse id="p0r0">
   <textline />
   <answer type="loncapa/perl">
       my $given      = implicit_multiplication($submission);
       my $maxima_in  = "ln(x):=log(x);is(rat(radcan($result-($given)))=0)";
       my $evaluation = cas( 'maxima', $maxima_in );
       return 'EXACT_ANS' if $evaluation eq 'true';
       return 'INCORRECT' if $evaluation eq 'false';
       return 'BAD_FORMULA';
   </answer>
</customresponse>
</part>

</problem>





Am 06/17/2015 um 05:45 PM schrieb Huckleberry, David W:
> 4*(ln(1) - ln(2))


-- 
Dr. Peter Dencker
     wissenschaftl. Mitarbeiter

UNIVERSITÄT ZU LÜBECK
     INSTITUT FÜR MATHEMATIK

     Ratzeburger Allee 160
     23562 Lübeck

     Tel +49 451 500 4254
     Fax +49 451 500 3373
     dencker at math.uni-luebeck.de

     www.math.uni-luebeck.de


More information about the LON-CAPA-users mailing list