File:  [LON-CAPA] / loncom / homework / templates / answerdependent.problem
Revision 1.1: download - view: text, annotated - select for diffs
Fri Jun 11 19:50:12 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
New templates
Cleaner mathresponse template

<problem>

    <parameter name="ordered" type="string_yesno" description="Show Parts One-at-a-Time" default="yes" />

<script type="loncapa/perl">
$lower=&random(3,10,1);
$higher=&random(15,20,1);
$answer=&random($lower,$higher,0.1);
$example='An example would be '.$answer;
# Get the entered answer. First argument is partID, second is responseID
$given=&submission(1,11);
if ($given=~/\d/) { $answer=$given; $example='You chose '.$given; }
$add=&random(3,6,0.1);
$result=$given+$add;
</script>

<part id="1">
<startouttext />
Give a number between $lower and $higher.
<endouttext />
<customresponse answerdisplay="$example" id="11">
    <answer type="loncapa/perl"># We do not want a vector
if ($submission=~/\,/) { return 'EXTRA_ANSWER'; }
# No units needed
if ($submission=~/^\d+\s+\w+$/) { return 'UNIT_NOTNEEDED'; }
# Need a numerical answer here
if ($submission!~/^[\d\.]+$/) { return 'WANTED_NUMERIC'; }
# is it correct?
if (($submission>=$lower) && ($submission<=$higher)) { return 'EXACT_ANS'; }
return 'INCORRECT';</answer>
    <textline readonly="no" />
</customresponse>
</part>

<part id="2">
<startouttext />
What do you get if you add $add to your number?
<endouttext />
<numericalresponse answer="$result">
<responseparam type="tolerance" default="1%" name="tol" description="Numerical Tolerance" />
    <textline readonly="no" />
</numericalresponse>
</part>

</problem>


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