[LON-CAPA-cvs] cvs: loncom /homework lonmaxima.pm /homework/templates extreme.problem

www www@source.lon-capa.org
Mon, 14 Jun 2010 11:34:20 -0000


www		Mon Jun 14 11:34:20 2010 EDT

  Modified files:              
    /loncom/homework	lonmaxima.pm 
    /loncom/homework/templates	extreme.problem 
  Log:
  Deal with pi->%pi
  
  
Index: loncom/homework/lonmaxima.pm
diff -u loncom/homework/lonmaxima.pm:1.28 loncom/homework/lonmaxima.pm:1.29
--- loncom/homework/lonmaxima.pm:1.28	Wed Dec 10 23:28:04 2008
+++ loncom/homework/lonmaxima.pm	Mon Jun 14 11:34:18 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Interface routines to MAXIMA CAS
 #
-# $Id: lonmaxima.pm,v 1.28 2008/12/10 23:28:04 raeburn Exp $
+# $Id: lonmaxima.pm,v 1.29 2010/06/14 11:34:18 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -117,7 +117,9 @@
 
 sub maxima_cas_formula_fix {
    my ($expression)=@_;
-   return &Apache::response::implicit_multiplication($expression);
+   $expression=&Apache::response::implicit_multiplication($expression);
+   $expression=~s/([^\w\%])pi/$1\%pi/gs;
+   return $expression;
 }
 
 sub maxima_run {
Index: loncom/homework/templates/extreme.problem
diff -u loncom/homework/templates/extreme.problem:1.1 loncom/homework/templates/extreme.problem:1.2
--- loncom/homework/templates/extreme.problem:1.1	Sun Jun 13 22:56:55 2010
+++ loncom/homework/templates/extreme.problem	Mon Jun 14 11:34:20 2010
@@ -71,14 +71,15 @@
 isrightkind:false;
 k:0;
 s:0;
-if hasextreme then for i:2 while s=0 do (s:at(diff(y(x),x,i),x=LONCAPALIST[1]),k:i);
+if hasextreme then for i:2 while s=0 and not is(diff(y(x),x,i)=0) do (s:at(diff(y(x),x,i),x=LONCAPALIST[1]),k:i);
 if evenp(k) and is(LONCAPALIST[2]*s>0) then isrightkind:true;
 hasextreme and isrightkind;</answer>
     <textline readonly="no" size="50" />
 </mathresponse>
 </part>
 <part id="2">
-<script type="loncapa/perl">$value=&cas('maxima',"float(at($example,x=$location))");</script>
+<script type="loncapa/perl">$previous=&maxima_cas_formula_fix($example);
+$value=&cas('maxima',"float(at($previous,x=$location))");</script>
 <startouttext />
 What is the value of your function at this $text?
 <endouttext />