[LON-CAPA-cvs] cvs: loncom /homework functionplotresponse.pm /homework/templates functionplotback.problem functionplotback.problem.meta doc/loncapafiles loncapafiles.lpml

www www@source.lon-capa.org
Sat, 13 Nov 2010 22:30:32 -0000


www		Sat Nov 13 22:30:32 2010 EDT

  Added files:                 
    /loncom/homework/templates	functionplotback.problem 
                              	functionplotback.problem.meta 

  Modified files:              
    /doc/loncapafiles	loncapafiles.lpml 
    /loncom/homework	functionplotresponse.pm 
  Log:
  More examples
  Correction for undefined upper value on boundaries
  
  
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.711 doc/loncapafiles/loncapafiles.lpml:1.712
--- doc/loncapafiles/loncapafiles.lpml:1.711	Fri Nov 12 02:16:15 2010
+++ doc/loncapafiles/loncapafiles.lpml	Sat Nov 13 22:30:24 2010
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.711 2010/11/12 02:16:15 www Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.712 2010/11/13 22:30:24 www Exp $ -->
 
 <!--
 
@@ -1315,6 +1315,8 @@
 functionplotone.problem.meta;
 functionplottwo.problem;
 functionplottwo.problem.meta;
+functionplotback.problem;
+functionplotback.problem.meta;
 HintFormula.problem;
 HintFormula.problem.meta;
 HintMathResponse.problem;
Index: loncom/homework/functionplotresponse.pm
diff -u loncom/homework/functionplotresponse.pm:1.37 loncom/homework/functionplotresponse.pm:1.38
--- loncom/homework/functionplotresponse.pm:1.37	Sat Nov 13 03:22:58 2010
+++ loncom/homework/functionplotresponse.pm	Sat Nov 13 22:30:28 2010
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: functionplotresponse.pm,v 1.37 2010/11/13 03:22:58 www Exp $
+# $Id: functionplotresponse.pm,v 1.38 2010/11/13 22:30:28 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -417,7 +417,7 @@
                                      $token,'8').
              &Apache::edit::text_arg('Optional maximum length for range:','maximumlength',
                                      $token,'8').'<br />'.
-             &Apache::edit::select_arg(&mt('Relationship:'),'relationship',
+             &Apache::edit::select_or_text_arg(&mt('Relationship:'),'relationship',
                                   [['eq','equal'],
                                    ['ne','not equal'],
                                    ['ge','greater than or equal'],
@@ -595,7 +595,11 @@
 #
 sub array_index {
    my ($xmin,$xmax,$x)=@_;
-   return int(($x-$xmin)/($xmax-$xmin)*400.+0.5);
+   if ($x ne '') {
+      return int(($x-$xmin)/($xmax-$xmin)*400.+0.5);
+   } else {
+      return undef;
+   }
 }
 
 #
@@ -886,7 +890,7 @@
 # Basic sanity checks
    if ($li<0) { $li=0; }
    if ($lh>400) { $lh=400; }
-   if ($li>$lh) {
+   if (($li>$lh) || (!defined($lh))) {
        $lh=$li;
    }
 

Index: loncom/homework/templates/functionplotback.problem
+++ loncom/homework/templates/functionplotback.problem
<problem>
<script type="loncapa/perl">$x=&random(-5,5,2);
$y=&random(-3,3,2);
$a=&random(0.5,0.9,0.1);
if (&random(0,1,1)) {
   $function="$a*(x-($x))^2+($y)";
   $relation='gt';
} else {
   $function="-$a*(x-($x))^2+($y)";
   $relation='lt';
}</script>
<startouttext />
Provide a sketch of the derivative of the indicated function<br /> <endouttext />
<functionplotresponse xaxisvisible="yes" xlabel="x" gridvisible="yes" ylabel="y(x)" id="11" xmax="10" yaxisvisible="yes" xmin="-10" ymin="-10" ymax="10">
<functionplotelements>
<spline initx="-4" inity="0" index="A" order="3" scalex="8" />
<backgroundplot function="$function" fixed="yes" />
</functionplotelements>
<functionplotruleset>
<functionplotrule relationship="eq" xinitial="$x" value="0" derivativeorder="0" percenterror="2" index="extreme" />
<functionplotrule relationship="$relation" xinitiallabel="start" xfinallabel="end" value="0" derivativeorder="1" percenterror="10" index="slope" />
<functionplotrule relationship="eq" xinitiallabel="start" xfinallabel="end" value="0" derivativeorder="2" percenterror="50" index="linear" />
</functionplotruleset>
</functionplotresponse>
</problem>

Index: loncom/homework/templates/functionplotback.problem.meta
+++ loncom/homework/templates/functionplotback.problem.meta
<title>Functionplotresponse with Background Plot</title>
<category>Free Form Problems</category>