Subject: [LON-CAPA-dev] formularesponse with maxima: Addition issues?

From: Stefan Bisitz <[email-masked]>
Date: Wed, 20 Jun 2007 13:08:45 +0200

Hi,

Before starting a new bugreport, I'd like to ask if someone knows any
issues with formularesponse with maxima using addition?!?

It seems that LON-CAPA/Maxima doesn't accept an answer which contains
additions. For example, use the "Formula Response using Computer Algebra
System" template and add "+5" or "+x" to $derivative:
--------
<problem>
    <script type="loncapa/perl">
$k=&random(3,6,1);
$formula="a*x^$k";
$m=$k-1;
$derivative="$k*a*x^$m+x"; # original: $derivative="$k*a*x^$m";
    </script>
    <startouttext />
What is the derivative of <tt>$formula</tt> with respect to x?
    <endouttext />
    <formularesponse answer="$derivative">
        <textline size="25" />    
    </formularesponse>
</problem>
--------

From now on, LON-CAPA displays "ERROR:Computer's answer is incorrect".

Using mathresponse or formularesponse WITH sampling points, no problems
could be seen.

Any idea what's wrong?

Stefan Bisitz

---

From: Gerd Kortemeyer <[email-masked]>
Date: Wed, 20 Jun 2007 08:11:43 -0400

Hi,

Yes, there was a rather stupid bug. You can change lonmaxima.pm by  
hand for now (see the diff below):

   Modified files:
     /loncom/homework	lonmaxima.pm
   Log:
   - need parentheses

Index: loncom/homework/lonmaxima.pm
diff -u loncom/homework/lonmaxima.pm:1.15 loncom/homework/ 
lonmaxima.pm:1.16
--- loncom/homework/lonmaxima.pm:1.15	Tue May 29 16:56:39 2007
+++ loncom/homework/lonmaxima.pm	Fri Jun 15 17:49:50 2007
@@ -1,7 +1,7 @@
  # The LearningOnline Network with CAPA
  # Interface routines to MAXIMA CAS
  #
-# $Id: lonmaxima.pm,v 1.15 2007/05/29 20:56:39 albertel Exp $
+# $Id: lonmaxima.pm,v 1.16 2007/06/15 21:49:50 albertel Exp $
  #
  # Copyright Michigan State University Board of Trustees
  #
@@ -121,7 +121,7 @@

  sub compareterms {
      my ($socket,$terma,$termb)=@_;
-    my $difference=$terma.'-'.$termb;
+    my $difference=$terma.'-('.$termb.')';
      if (&blacklisted($difference)) { return 'Error: blacklisted'; }
      my $reply=&maximareply($socket,'trigsimp(trigreduce('. 
$difference.'));');
      if ($reply=~/^\s*0\s*$/) { return 'true'; }

- Gerd.

On Jun 20, 2007, at 7:08 AM, Stefan Bisitz wrote:

> _______________________________________________
> LON-CAPA-dev mailing list
> [email-masked]
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-dev