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

www lon-capa-cvs@mail.lon-capa.org
Tue, 19 Dec 2006 17:44:17 -0000


www		Tue Dec 19 12:44:17 2006 EDT

  Modified files:              
    /loncom	lonmaxima 
    /loncom/homework	lonmaxima.pm 
  Log:
  The reset()-command in MAXIMA is broken
  Need to actually do string replacement
  
  
Index: loncom/lonmaxima
diff -u loncom/lonmaxima:1.21 loncom/lonmaxima:1.22
--- loncom/lonmaxima:1.21	Tue May  9 22:21:19 2006
+++ loncom/lonmaxima	Tue Dec 19 12:44:16 2006
@@ -3,7 +3,7 @@
 # The LearningOnline Network with CAPA
 # Connect to MAXIMA CAS
 #
-# $Id: lonmaxima,v 1.21 2006/05/10 02:21:19 www Exp $
+# $Id: lonmaxima,v 1.22 2006/12/19 17:44:16 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -253,7 +253,7 @@
         for (my $i=0; $i < $MAX_CLIENTS_PER_CHILD; $i++) {
            &status('Accepting connections');
            my $client = $server->accept()     or last;
-           print $command "kill(all);reset();\n";
+           print $command "kill(all);\n";
 	   &getmaximaoutput($command);
            &sync($command);
            while (my $cmd=<$client>) {
Index: loncom/homework/lonmaxima.pm
diff -u loncom/homework/lonmaxima.pm:1.11 loncom/homework/lonmaxima.pm:1.12
--- loncom/homework/lonmaxima.pm:1.11	Tue Dec 19 09:24:05 2006
+++ loncom/homework/lonmaxima.pm	Tue Dec 19 12:44:16 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Interface routines to MAXIMA CAS
 #
-# $Id: lonmaxima.pm,v 1.11 2006/12/19 14:24:05 www Exp $
+# $Id: lonmaxima.pm,v 1.12 2006/12/19 17:44:16 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -87,19 +87,19 @@
 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]:".&maxima_cas_formula_fix($submission_component).";\n";
-	$submission_index++;
+    my @submissionarray=split(/\s*\,\s*/,$submission);
+    for (my $i=0;$i<=$#submissionarray;$i++) {
+        my $n=$i+1;
+        my $fixedsubmission=&maxima_cas_formula_fix($submissionarray[$i]);
+        $script=~s/RESPONSE\[$n\]/$fixedsubmission/gs;
     }
-    my $argument_index=1;
-    foreach my $argument_component (@{$argument}) {
-	$fullscript.="LONCAPALIST[$argument_index]:".&maxima_cas_formula_fix($argument_component).";\n";
-	$argument_index++;
+    my @argumentarray=@{$argument};
+    for (my $i=0;$i<=$#argumentarray;$i++) {
+        my $n=$i+1;
+        my $fixedargument=&maxima_cas_formula_fix($argumentarray[$i]);
+        $script=~s/LONCAPALIST\[$n\]/$fixedargument/gs;
     }
-    $fullscript.=$script;
-    my $reply=&runscript($socket,$fullscript);
+    my $reply=&runscript($socket,$script);
     &disconnect($socket);
     if ($reply=~/^\s*true\s*$/) { return 'EXACT_ANS'; }
     if ($reply=~/^\s*false\s*/) { return 'INCORRECT'; }