[LON-CAPA-cvs] cvs: loncom / lonr /homework default_homework.lcpm hint.pm response.pm /xml lonxml.pm doc/loncapafiles loncapafiles.lpml

www www@source.lon-capa.org
Fri, 17 Apr 2009 01:00:21 -0000


www		Fri Apr 17 01:00:21 2009 EDT

  Modified files:              
    /doc/loncapafiles	loncapafiles.lpml 
    /loncom	lonr 
    /loncom/homework	default_homework.lcpm hint.pm response.pm 
    /loncom/xml	lonxml.pm 
  Log:
  Support for R CAS
  - needs testing
  - better error handling
  - correct blacklist
  - correct list of allowed libraries
  
  
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.639 doc/loncapafiles/loncapafiles.lpml:1.640
--- doc/loncapafiles/loncapafiles.lpml:1.639	Mon Apr  6 03:58:39 2009
+++ doc/loncapafiles/loncapafiles.lpml	Fri Apr 17 01:00:05 2009
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.639 2009/04/06 03:58:39 raeburn Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.640 2009/04/17 01:00:05 www Exp $ -->
 
 <!--
 
@@ -4810,6 +4810,15 @@
   <status>works/unverified</status>
 </file>
 <file>
+  <source>loncom/homework/lonr.pm</source>
+  <target dist='default'>home/httpd/lib/perl/Apache/lonr.pm</target>
+  <categoryname>handler</categoryname>
+  <description>
+    routines to simplify talking to the R client
+  </description>
+  <status>works/unverified</status>
+</file>
+<file>
 <source>loncom/xml/Safe.pm</source>
 <target dist='default'>home/httpd/lib/perl/Safe.pm</target>
 <categoryname>handler</categoryname>
Index: loncom/lonr
diff -u loncom/lonr:1.2 loncom/lonr:1.3
--- loncom/lonr:1.2	Fri Apr 17 00:34:46 2009
+++ loncom/lonr	Fri Apr 17 01:00:10 2009
@@ -1,9 +1,9 @@
 #!/usr/bin/perl
 #
 # The LearningOnline Network with CAPA
-# Connect to MAXIMA CAS
+# Connect to R CAS
 #
-# $Id: lonr,v 1.2 2009/04/17 00:34:46 www Exp $
+# $Id: lonr,v 1.3 2009/04/17 01:00:10 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.143 loncom/homework/default_homework.lcpm:1.144
--- loncom/homework/default_homework.lcpm:1.143	Fri Feb  6 10:43:48 2009
+++ loncom/homework/default_homework.lcpm	Fri Apr 17 01:00:15 2009
@@ -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.143 2009/02/06 10:43:48 riegler Exp $
+# $Id: default_homework.lcpm,v 1.144 2009/04/17 01:00:15 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -436,6 +436,8 @@
     my $output;
     if ($system eq 'maxima') {
        $output=&maxima_eval($input,$library);
+    } elsif ($system eq 'R') {
+       $output=&r_eval($input,$library);
     } else {
        $output='Error: unrecognized CAS';
     }
Index: loncom/homework/hint.pm
diff -u loncom/homework/hint.pm:1.74 loncom/homework/hint.pm:1.75
--- loncom/homework/hint.pm:1.74	Thu Nov 20 15:19:15 2008
+++ loncom/homework/hint.pm	Fri Apr 17 01:00:15 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # implements the tags that control the hints
 #
-# $Id: hint.pm,v 1.74 2008/11/20 15:19:15 jms Exp $
+# $Id: hint.pm,v 1.75 2009/04/17 01:00:15 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -35,6 +35,7 @@
 use capa;
 use Apache::caparesponse();
 use Apache::lonmaxima();
+use Apache::lonr();
 use Apache::response();
 use Apache::lonlocal;
 use Storable qw(dclone);
@@ -244,7 +245,7 @@
         $result.=&Apache::edit::text_arg('Name:','name',$token);
         $result.=&Apache::edit::select_arg('Algebra System:',
                                            'cas',
-                                           ['maxima'],
+                                           ['maxima','R'],
                                            $token);
         $result.=&Apache::edit::text_arg('Argument Array:',
                                          'args',$token);
@@ -282,6 +283,10 @@
 	    my $args = [&Apache::lonxml::get_param_var('args',$parstack,$safeeval)];
 	    $award=&Apache::lonmaxima::maxima_run($Apache::response::custom_answer[-1],$response,$args);
 	}
+        if ($cas eq 'R') {
+            my $args = [&Apache::lonxml::get_param_var('args',$parstack,$safeeval)];
+            $award=&Apache::lonr::r_run($Apache::response::custom_answer[-1],$response,$args);
+        }
         if ($award eq 'EXACT_ANS' || $award eq 'APPROX_ANS') {
             push (@Apache::hint::which,$name);
         }
@@ -706,4 +711,4 @@
 
 =back
 
-=cut
\ No newline at end of file
+=cut
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.213 loncom/homework/response.pm:1.214
--- loncom/homework/response.pm:1.213	Mon Mar 16 18:20:22 2009
+++ loncom/homework/response.pm	Fri Apr 17 01:00:15 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.213 2009/03/16 18:20:22 bisitz Exp $
+# $Id: response.pm,v 1.214 2009/04/17 01:00:15 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -54,6 +54,7 @@
 use Apache::lonlocal;
 use Apache::lonnet;
 use Apache::lonmaxima();
+use Apache::lonr();
 
 BEGIN {
     &Apache::lonxml::register('Apache::response',('responseparam','parameter','dataresponse','customresponse','mathresponse'));
@@ -508,7 +509,7 @@
 					 'answerdisplay',$token);
 	$result.=&Apache::edit::select_arg('Algebra System:',
 					   'cas',
-					   ['maxima'],
+					   ['maxima','R'],
 					   $token);
 	$result.=&Apache::edit::text_arg('Argument Array:',
 					 'args',$token).
@@ -572,6 +573,12 @@
                 $award=&Apache::lonmaxima::maxima_run($Apache::response::custom_answer[-1],$response,$args,
                                                       &Apache::lonxml::get_param('libraries',$parstack,$safeeval));
             }
+            if ($cas eq 'R') {
+                my $args = [&Apache::lonxml::get_param_var('args',$parstack,$safeeval)];
+                $award=&Apache::lonr::r_run($Apache::response::custom_answer[-1],$response,$args,
+                                            &Apache::lonxml::get_param('libraries',$parstack,$safeeval));
+            }
+
 	    if (!&Apache::inputtags::valid_award($award)) {
 		$error = $award;
 		$award = 'ERROR';
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.493 loncom/xml/lonxml.pm:1.494
--- loncom/xml/lonxml.pm:1.493	Mon Apr 13 20:42:32 2009
+++ loncom/xml/lonxml.pm	Fri Apr 17 01:00:20 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.493 2009/04/13 20:42:32 raeburn Exp $
+# $Id: lonxml.pm,v 1.494 2009/04/17 01:00:20 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -109,6 +109,7 @@
 use Apache::lonmsg();
 use Apache::loncacc();
 use Apache::lonmaxima();
+use Apache::lonr();
 use Apache::lonlocal;
 
 #====================================   Main subroutine: xmlparse  
@@ -755,6 +756,11 @@
   $safehole->wrap(\&Apache::lonmaxima::maxima_cas_formula_fix,$safeeval,
 		  '&maxima_cas_formula_fix');
 
+  $safehole->wrap(\&Apache::lonr::r_eval,$safeeval,'&r_eval');
+  $safehole->wrap(\&Apache::lonr::r_check,$safeeval,'&r_check');
+  $safehole->wrap(\&Apache::lonr::r_cas_formula_fix,$safeeval,
+                  '&r_cas_formula_fix');
+ 
   $safehole->wrap(\&Apache::caparesponse::capa_formula_fix,$safeeval,
 		  '&capa_formula_fix');