[LON-CAPA-cvs] cvs: loncom / lonr /homework lonr.pm /homework/templates Rnumerical.problem Rnumerical.problem.meta SimpleMathResponse.problem.meta SimpleMathResponseR.problem SimpleMathResponseR.problem.meta doc/loncapafiles loncapafiles.lpml

www www@source.lon-capa.org
Sat, 18 Apr 2009 23:43:54 -0000


www		Sat Apr 18 23:43:54 2009 EDT

  Added files:                 
    /loncom/homework/templates	Rnumerical.problem 
                              	Rnumerical.problem.meta 
                              	SimpleMathResponseR.problem 
                              	SimpleMathResponseR.problem.meta 

  Modified files:              
    /doc/loncapafiles	loncapafiles.lpml 
    /loncom	lonr 
    /loncom/homework	lonr.pm 
    /loncom/homework/templates	SimpleMathResponse.problem.meta 
  Log:
  * Some more blacklisted stuff
  * Eliminate debugging code
  * Templates for using R
  
  
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.640 doc/loncapafiles/loncapafiles.lpml:1.641
--- doc/loncapafiles/loncapafiles.lpml:1.640	Fri Apr 17 01:00:05 2009
+++ doc/loncapafiles/loncapafiles.lpml	Sat Apr 18 23:43:43 2009
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.640 2009/04/17 01:00:05 www Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.641 2009/04/18 23:43:43 www Exp $ -->
 
 <!--
 
@@ -1262,6 +1262,8 @@
 Plot_curve.problem.meta;
 Plot_data.problem;
 Plot_data.problem.meta;
+Rnumerical.problem;
+Rnumerical.problem.meta;
 RadioResponse.problem;
 RadioResponse.problem.meta;
 RandomLabelExample.problem;
@@ -1291,6 +1293,8 @@
 SimpleMatching.problem.meta;
 SimpleMathResponse.problem;
 SimpleMathResponse.problem.meta;
+SimpleMathResponseR.problem;
+SimpleMathResponseR.problem.meta;
 SimpleRank.problem;
 SimpleRank.problem.meta;
 SimpleTrueFalse.problem;
Index: loncom/lonr
diff -u loncom/lonr:1.4 loncom/lonr:1.5
--- loncom/lonr:1.4	Sat Apr 18 16:03:14 2009
+++ loncom/lonr	Sat Apr 18 23:43:47 2009
@@ -3,7 +3,7 @@
 # The LearningOnline Network with CAPA
 # Connect to R CAS
 #
-# $Id: lonr,v 1.4 2009/04/18 16:03:14 www Exp $
+# $Id: lonr,v 1.5 2009/04/18 23:43:47 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -269,7 +269,7 @@
 	};
 
 	$command->log_stdout(0);
-	$command->log_file("$execdir/logs/lonr.session.log");
+#	$command->log_file("$execdir/logs/lonr.session.log");
 
         for (my $i=0; $i < $MAX_CLIENTS_PER_CHILD; $i++) {
             &status('Accepting connections');
Index: loncom/homework/lonr.pm
diff -u loncom/homework/lonr.pm:1.3 loncom/homework/lonr.pm:1.4
--- loncom/homework/lonr.pm:1.3	Sat Apr 18 16:03:17 2009
+++ loncom/homework/lonr.pm	Sat Apr 18 23:43:50 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Interface routines to R CAS
 #
-# $Id: lonr.pm,v 1.3 2009/04/18 16:03:17 www Exp $
+# $Id: lonr.pm,v 1.4 2009/04/18 23:43:50 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -68,6 +68,8 @@
         'dev\.list','dev\.next','dev\.prev','dev\.set',
         'dev\.off','dev\.copy','dev\.print','graphics',
         'library','package','source','sink','objects',
+        'Sys\.','unlink','file\.','on\.exit','error',
+        'q\(\)'
      ) {
 	if ($cmd=~/$forbidden/s) { return 1; }
     } 
Index: loncom/homework/templates/SimpleMathResponse.problem.meta
diff -u loncom/homework/templates/SimpleMathResponse.problem.meta:1.1 loncom/homework/templates/SimpleMathResponse.problem.meta:1.2
--- loncom/homework/templates/SimpleMathResponse.problem.meta:1.1	Mon May 19 21:19:19 2008
+++ loncom/homework/templates/SimpleMathResponse.problem.meta	Sat Apr 18 23:43:54 2009
@@ -1,3 +1,3 @@
-<title>Math Response using Computer Algebra System</title>
+<title>Math Response using Computer Algebra System MAXIMA</title>
 <category>Algebraic Response Problems</category>
 <help>Math_Response_Problems</help>

Index: loncom/homework/templates/Rnumerical.problem
+++ loncom/homework/templates/Rnumerical.problem
<problem>
<script type="loncapa/perl">
$seed=&random(1,500,1);
$n=&random(15,25,1);
$offset=&random(2,5,0.1);
$slope=&random(0.6,2.5,0.1);
# construct a data set using R
$data=&cas('R',"set.seed($seed);x<-1:$n;w<-1+sqrt(x)/2;data.frame(x=x,y=$offset+$slope*x+rnorm(x)*w);");
# separate into an x and a y vector
@datatable=split(/\s+/gs,$data);
for ($i=0;$i<2*$n;$i+=2) {
    push(@x,$datatable[$i]);
    push(@y,$datatable[$i+1]);
}
$datax=join(',',@x);
$datay=join(',',@y);
# calculate the right answer using R
($intercept,$slope)=split(/\s+/,&cas('R',"x<-c($datax);y<-c($datay);dataset<-data.frame(x=x,y=y);fm<-lm(y~x,data=dataset);array(coef(fm),dim=2);"));
$answer="$slope*x+$intercept";
</script>
<gnuplot width="400" solid="0" plotcolor="monochrome" gridlayer="off" bmargin="default" font="9" alttag="dynamically generated plot" bgcolor="xffffff" texfont="22" transparent="off" plottype="Cartesian" rmargin="default" gridtype="Cartesian" minor_ticscale="0.5" fontface="sans-serif" grid="on" align="right" texwidth="93" height="300" border="on" samples="100" fgcolor="x000000" major_ticscale="1" tmargin="default" lmargin="default" fillstyle="empty">
    <curve linestyle="points" linetype="solid" color="x000000" pointtype="3" limit="closed" pointsize="2" linewidth="1">
        <data>@x</data>
        <data>@y</data>
    </curve>
    
</gnuplot>

<startouttext />
Consider the data set
<pre>$data</pre>

Give a linear function approximating the data.<br />
<tt>y(x)=</tt>
<endouttext />
<formularesponse answer="$answer" samples="x@1:$n#20">
    <responseparam name="tol" default="2%" description="Numerical Tolerance" type="tolerance" />
    <textline size="25" readonly="no" />
    
</formularesponse>
</problem>

Index: loncom/homework/templates/Rnumerical.problem.meta
+++ loncom/homework/templates/Rnumerical.problem.meta
<title>Numerical Response using Computer Algebra System R and Data Plot</title>
<category>Numerical Problems</category>

Index: loncom/homework/templates/SimpleMathResponseR.problem
+++ loncom/homework/templates/SimpleMathResponseR.problem
<problem>
<script type="loncapa/perl">
$mean=&random(4,9,0.1);
@args=$mean;
$answer="$mean,$mean,$mean would be a simple example";
</script>

<startouttext />
Provide a list of 3 numbers (separated by commas) that has a mean value of $mean.
<endouttext />

<mathresponse answerdisplay="$answer" cas="R" args="@args">

<answer>x<-c(RESPONSE[1],RESPONSE[2],RESPONSE[3]);
abs(mean(x)-LONCAPALIST[1])<0.001
</answer>

<textline readonly="no" size="50" />
</mathresponse>
</problem>

Index: loncom/homework/templates/SimpleMathResponseR.problem.meta
+++ loncom/homework/templates/SimpleMathResponseR.problem.meta
<title>Math Response using Computer Algebra System R</title>
<category>Algebraic Response Problems</category>
<help>Math_Response_Problems</help>