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 (14 years, 6 months ago) by www
Branches: MAIN
CVS tags: version_2_12_X, version_2_11_X, version_2_11_5_msu, version_2_11_5, 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

<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>


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