File:  [LON-CAPA] / loncom / homework / templates / CustomResponse.problem
Revision 1.2.8.1: download - view: text, annotated - select for diffs
Fri Aug 20 03:52:20 2010 UTC (13 years, 8 months ago) by raeburn
Branches: version_2_9_X
CVS tags: version_2_9_1
Diff to branchpoint 1.2: preferred, colored
- Backport 1.4.

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