[LON-CAPA-cvs] cvs: loncom /homework default_homework.lcpm lonmaxima.pm /xml lonxml.pm

www lon-capa-cvs@mail.lon-capa.org
Tue, 19 Dec 2006 14:24:08 -0000


www		Tue Dec 19 09:24:08 2006 EDT

  Modified files:              
    /loncom/homework	default_homework.lcpm lonmaxima.pm 
    /loncom/xml	lonxml.pm 
  Log:
  &cas()
  
  
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.123 loncom/homework/default_homework.lcpm:1.124
--- loncom/homework/default_homework.lcpm:1.123	Fri Dec 15 17:11:43 2006
+++ loncom/homework/default_homework.lcpm	Tue Dec 19 09:24:05 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
 #
-# $Id: default_homework.lcpm,v 1.123 2006/12/15 22:11:43 www Exp $
+# $Id: default_homework.lcpm,v 1.124 2006/12/19 14:24:05 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -417,6 +417,15 @@
     return ($final_award,$final_msg);
 }
 
+sub cas {
+    my ($system,$input)=@_;
+    my $output;
+    if ($system eq 'maxima') {
+       $output=&maxima_eval($input);
+    }
+    return $output;
+}
+
 sub tex {
     if ( $external::target eq "tex" ) {
 	return $_[0];
Index: loncom/homework/lonmaxima.pm
diff -u loncom/homework/lonmaxima.pm:1.10 loncom/homework/lonmaxima.pm:1.11
--- loncom/homework/lonmaxima.pm:1.10	Mon Dec 18 16:12:51 2006
+++ loncom/homework/lonmaxima.pm	Tue Dec 19 09:24:05 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Interface routines to MAXIMA CAS
 #
-# $Id: lonmaxima.pm,v 1.10 2006/12/18 21:12:51 www Exp $
+# $Id: lonmaxima.pm,v 1.11 2006/12/19 14:24:05 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -106,6 +106,15 @@
     return 'BAD_FORMULA';
 }
 
+sub maxima_eval {
+    my ($script) = @_;
+    my $socket=&connect();
+    my $reply=&runscript($socket,$script);
+    &disconnect($socket);
+    return $reply;
+}
+
+
 sub compareterms {
     my ($socket,$terma,$termb)=@_;
     my $difference=$terma.'-'.$termb;
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.430 loncom/xml/lonxml.pm:1.431
--- loncom/xml/lonxml.pm:1.430	Sun Dec 10 19:42:47 2006
+++ loncom/xml/lonxml.pm	Tue Dec 19 09:24:07 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.430 2006/12/11 00:42:47 albertel Exp $
+# $Id: lonxml.pm,v 1.431 2006/12/19 14:24:07 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -88,6 +88,7 @@
 use Apache::lonfeedback();
 use Apache::lonmsg();
 use Apache::loncacc();
+use Apache::lonmaxima();
 use Apache::lonlocal;
 
 #==================================================   Main subroutine: xmlparse  
@@ -674,6 +675,8 @@
 		  '&chem_standard_order');
   $safehole->wrap(\&Apache::response::check_status,$safeeval,'&check_status');
 
+  $safehole->wrap(\&Apache::lonmaxima::maxima_eval,$safeeval,'&maxima_eval');
+
   $safehole->wrap(\&Math::Cephes::asin,$safeeval,'&asin');
   $safehole->wrap(\&Math::Cephes::acos,$safeeval,'&acos');
   $safehole->wrap(\&Math::Cephes::atan,$safeeval,'&atan');