[LON-CAPA-cvs] cvs: loncom /homework/templates answerdependent.problem.meta dynamicgraph.problem dynamicgraph.problem.meta extreme.problem extreme.problem.meta doc/loncapafiles loncapafiles.lpml

www www@source.lon-capa.org
Sun, 13 Jun 2010 22:56:55 -0000


www		Sun Jun 13 22:56:55 2010 EDT

  Added files:                 
    /loncom/homework/templates	dynamicgraph.problem 
                              	dynamicgraph.problem.meta 
                              	extreme.problem extreme.problem.meta 

  Modified files:              
    /doc/loncapafiles	loncapafiles.lpml 
    /loncom/homework/templates	answerdependent.problem.meta 
  Log:
  More sample problems
  
  
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.689 doc/loncapafiles/loncapafiles.lpml:1.690
--- doc/loncapafiles/loncapafiles.lpml:1.689	Fri Jun 11 19:50:08 2010
+++ doc/loncapafiles/loncapafiles.lpml	Sun Jun 13 22:56:52 2010
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.689 2010/06/11 19:50:08 www Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.690 2010/06/13 22:56:52 www Exp $ -->
 
 <!--
 
@@ -1286,6 +1286,10 @@
 blank.problem.meta;
 blank.task;
 blank.task.meta;
+dynamicgraph.problem;
+dynamicgraph.problem.meta;
+extreme.problem;
+extreme.problem.meta;
 simple.task;
 simple.task.meta;
 multiple_instance.task;
Index: loncom/homework/templates/answerdependent.problem.meta
diff -u loncom/homework/templates/answerdependent.problem.meta:1.1 loncom/homework/templates/answerdependent.problem.meta:1.2
--- loncom/homework/templates/answerdependent.problem.meta:1.1	Fri Jun 11 19:50:12 2010
+++ loncom/homework/templates/answerdependent.problem.meta	Sun Jun 13 22:56:55 2010
@@ -1,3 +1,3 @@
-<title>Using Learner Answer in Numerical Problem</title>
-<category>Input-Dependent Multipart Problems</category>
+<title>Using Learner Answer in Multipart Numerical Problem</title>
+<category>Input-Dependent Problems</category>
 <help></help>

Index: loncom/homework/templates/dynamicgraph.problem
+++ loncom/homework/templates/dynamicgraph.problem
<problem>
    <parameter name="maxtries" id="12" type="int_pos" default="99" description="Maximum Number of Tries" />

<script type="loncapa/perl">
$amplitude=&random(2.5,3.8,0.1);
$omega=&random(1,3,0.1);
$k=&random(0.2,0.4,0.1);
$phi=&random(0.3,3,0.1);
# Correct function from computer
$function="$amplitude*exp(-$k*x)*sin($omega*x+$phi)";
# Get user function with &submission(partID,responseID),
# use implicit multiplication to insert "*" where obvious
$userfunction=&implicit_multiplication(&submission(0,11));
if ($userfunction) {
    if (&cas('maxima',$userfunction)=~/^(error|incorrect)/i) {
# Don't plot formulas with syntax errors, they would
# result in a broken plot.
        $userfunction='0';
    }
    $remark="The function you entered is indicated in red.";
} else {
   $userfunction='0';
   $remark='';
}
# The user function will be evaluated fuzzy (with tolerance),
# since the user is unlikely to hit exactly the right function.
</script>

<gnuplot width="600" grid="on" align="left" font="9" height="400" border="on" samples="100" bgcolor="xffffff" fgcolor="x000000" transparent="off" plottype="Cartesian">
    <axis xmin="0" ymax="4" color="x000000" ymin="-4" xmax="10" />
    <xlabel>x</xlabel>
    <ylabel>f(x)</ylabel>
    <curve linestyle="linespoints" name="ProblemPlot" color="x000000" pointtype="0">
        <function>$function</function>
        
    </curve>
    <curve linestyle="lines" name="UserPlot" color="xFF0000" pointtype="0">
        <function>$userfunction</function>
        
    </curve>
</gnuplot>

<startouttext /><br clear="all" />Match the function indicated in black. $remark<br />
f(x)=<endouttext />

<formularesponse answer="$function" samples="x@0;1;2;3;4;5;6;7;8;9" id="11">
    
    <textline size="60" readonly="no" />
    <responseparam name="tol" default="0.4" description="Numerical Tolerance" type="tolerance" />
    
</formularesponse>
</problem>


Index: loncom/homework/templates/dynamicgraph.problem.meta
+++ loncom/homework/templates/dynamicgraph.problem.meta
<title>Using Learner Formula in Graph with Formula Response</title>
<category>Input-Dependent Problems</category>
<help></help>

Index: loncom/homework/templates/extreme.problem
+++ loncom/homework/templates/extreme.problem
<problem>
    <parameter name="ordered" type="string_yesno" description="Show Parts One-at-a-Time" default="yes" />

<script type="loncapa/perl">
$location=&random(4,10,1);
$example="(x-$location)^2";
if (&random(0,1,1)) {
   $text='minimum';
   $factor=1;
} else {
   $text='maximum';
   $factor=-1;
   $example='-'.$example;
}

# Get user input, run through function that adds "*" to 3x, etc
$userfunction=&implicit_multiplication(&submission(1,11));
if ($userfunction) {
# Determine value at extreme point
   $extremevalue=&cas('maxima',"float(at($userfunction,x=$location))");
   if ($extremevalue=~/^(error|incorrect)/i) {
# cas could not evaluate the function
      $userfunction='0';
      $extremevalue=0;
      $remark='Your function could not be evaluated.';
   } else {
      $remark='Your function is plotted.';
      $example=$userfunction;
   }
} else {
   $userfunction='0';
   $extremevalue=0;
   $remark='';
}
# Plot boundaries
$minx=$location-5;
$maxx=$location+5;
$miny=$extremevalue-5;
$maxy=$extremevalue+5;
@args=($location,$factor);
</script>

<part id="1">
<gnuplot width="400" solid="0" plotcolor="monochrome" gridlayer="off" bmargin="default" font="9" alttag="Plot" bgcolor="xffffff" texfont="22" transparent="off" plottype="Cartesian" rmargin="default" gridtype="Cartesian" minor_ticscale="0.5" fontface="sans-serif" grid="on" align="middle" texwidth="93" height="300" border="on" samples="100" fgcolor="x000000" major_ticscale="1" tmargin="default" lmargin="default" fillstyle="empty">
    <curve 
         linestyle="lines"
         color="x000000"
         pointtype="1"
         linetype="solid"
         linewidth="1"
         name=""
         limit="closed"
         pointsize="1" >
        <function>$userfunction</function>
        
        
    </curve>
    <axis yzero="off" xformat="on" xmin="$minx" yformat="on" color="x000000" xmax="$maxx" xzero="off" ymax="$maxy" ymin="$miny" />
    
</gnuplot>

<startouttext />
<p>$remark</p>
Give a differentiable real function <m>$f(x)$</m> that has a $text at <m eval="on">$x=$location$</m>.<br />
<m>$f(x)=$</m>
<endouttext />

<mathresponse answerdisplay="$example" cas="maxima" args="@args" id="11">
    <answer>y(x):=RESPONSE[1];
hasextreme:is(at(diff(y(x),x,1),x=LONCAPALIST[1])=0);
isrightkind:false;
k:0;
s:0;
if hasextreme then for i:2 while s=0 do (s:at(diff(y(x),x,i),x=LONCAPALIST[1]),k:i);
if evenp(k) and is(LONCAPALIST[2]*s>0) then isrightkind:true;
hasextreme and isrightkind;</answer>
    <textline readonly="no" size="50" />
</mathresponse>
</part>
<part id="2">
<script type="loncapa/perl">$value=&cas('maxima',"float(at($example,x=$location))");</script>
<startouttext />
What is the value of your function at this $text?
<endouttext />
<numericalresponse answer="$value">
<responseparam type="tolerance" default="5%" name="tol" description="Numerical Tolerance" />

    <textline readonly="no" />
    
</numericalresponse>
</part>
</problem>

Index: loncom/homework/templates/extreme.problem.meta
+++ loncom/homework/templates/extreme.problem.meta
<title>Using Learner Formula in Graph with Math Response</title>
<category>Input-Dependent Problems</category>
<help></help>