--- loncom/homework/lonmaxima.pm	2006/12/15 21:10:13	1.8
+++ loncom/homework/lonmaxima.pm	2006/12/19 14:24:05	1.11
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Interface routines to MAXIMA CAS
 #
-# $Id: lonmaxima.pm,v 1.8 2006/12/15 21:10:13 www Exp $
+# $Id: lonmaxima.pm,v 1.11 2006/12/19 14:24:05 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,6 +31,7 @@ package Apache::lonmaxima;
 use strict;
 use IO::Socket;
 use Apache::lonnet;
+use Apache::response();
 use LONCAPA;
 
 sub connect {
@@ -78,18 +79,23 @@ sub runscript {
     return $reply;
 }
 
+sub maxima_cas_formula_fix {
+   my ($expression)=@_;
+   return &Apache::response::implicit_multiplication($expression);
+}
+
 sub maxima_run {
     my ($script,$submission,$argument) = @_;
     my $socket=&connect();
     my $fullscript='';
     my $submission_index=1;
     foreach my $submission_component (split(/\s*\,\s*/,$submission)) {
-	$fullscript.="RESPONSE[$submission_index]:$submission_component;\n";
+	$fullscript.="RESPONSE[$submission_index]:".&maxima_cas_formula_fix($submission_component).";\n";
 	$submission_index++;
     }
     my $argument_index=1;
     foreach my $argument_component (@{$argument}) {
-	$fullscript.="LONCAPALIST[$argument_index]:$argument_component;\n";
+	$fullscript.="LONCAPALIST[$argument_index]:".&maxima_cas_formula_fix($argument_component).";\n";
 	$argument_index++;
     }
     $fullscript.=$script;
@@ -100,6 +106,15 @@ sub maxima_run {
     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;