File:  [LON-CAPA] / loncom / homework / templates / dynamicgraph.problem
Revision 1.1: download - view: text, annotated - select for diffs
Sun Jun 13 22:56:55 2010 UTC (13 years, 11 months ago) by www
Branches: MAIN
CVS tags: version_2_12_X, version_2_11_X, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, version_2_10_X, version_2_10_1, version_2_10_0_RC2, version_2_10_0_RC1, version_2_10_0, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, HEAD, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse, BZ4492-Support_horizontal_radioresponse
More sample problems

    1: <problem>
    2:     <parameter name="maxtries" id="12" type="int_pos" default="99" description="Maximum Number of Tries" />
    3: 
    4: <script type="loncapa/perl">
    5: $amplitude=&random(2.5,3.8,0.1);
    6: $omega=&random(1,3,0.1);
    7: $k=&random(0.2,0.4,0.1);
    8: $phi=&random(0.3,3,0.1);
    9: # Correct function from computer
   10: $function="$amplitude*exp(-$k*x)*sin($omega*x+$phi)";
   11: # Get user function with &submission(partID,responseID),
   12: # use implicit multiplication to insert "*" where obvious
   13: $userfunction=&implicit_multiplication(&submission(0,11));
   14: if ($userfunction) {
   15:     if (&cas('maxima',$userfunction)=~/^(error|incorrect)/i) {
   16: # Don't plot formulas with syntax errors, they would
   17: # result in a broken plot.
   18:         $userfunction='0';
   19:     }
   20:     $remark="The function you entered is indicated in red.";
   21: } else {
   22:    $userfunction='0';
   23:    $remark='';
   24: }
   25: # The user function will be evaluated fuzzy (with tolerance),
   26: # since the user is unlikely to hit exactly the right function.
   27: </script>
   28: 
   29: <gnuplot width="600" grid="on" align="left" font="9" height="400" border="on" samples="100" bgcolor="xffffff" fgcolor="x000000" transparent="off" plottype="Cartesian">
   30:     <axis xmin="0" ymax="4" color="x000000" ymin="-4" xmax="10" />
   31:     <xlabel>x</xlabel>
   32:     <ylabel>f(x)</ylabel>
   33:     <curve linestyle="linespoints" name="ProblemPlot" color="x000000" pointtype="0">
   34:         <function>$function</function>
   35:         
   36:     </curve>
   37:     <curve linestyle="lines" name="UserPlot" color="xFF0000" pointtype="0">
   38:         <function>$userfunction</function>
   39:         
   40:     </curve>
   41: </gnuplot>
   42: 
   43: <startouttext /><br clear="all" />Match the function indicated in black. $remark<br />
   44: f(x)=<endouttext />
   45: 
   46: <formularesponse answer="$function" samples="x@0;1;2;3;4;5;6;7;8;9" id="11">
   47:     
   48:     <textline size="60" readonly="no" />
   49:     <responseparam name="tol" default="0.4" description="Numerical Tolerance" type="tolerance" />
   50:     
   51: </formularesponse>
   52: </problem>
   53: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>