File:  [LON-CAPA] / loncom / homework / templates / CustomResponse.problem
Revision 1.4: download - view: text, annotated - select for diffs
Thu Jun 10 22:37:12 2010 UTC (13 years, 10 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
Recognize negative and floating point numbers

<problem>

<startouttext />
Accept an answer of around 90 or -90
<endouttext />

<customresponse answerdisplay="something near 90 or -90">
    <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'; }
$difference=abs(90-abs($submission));
if ($difference==0) { return 'EXACT_ANS'; }
if ($difference < 0.001) { return 'APPROX_ANS'; }
return 'INCORRECT';
    </answer>
    <textline />
</customresponse>

</problem>

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