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, unified
- Backport 1.4.

    1: <problem>
    2: <startouttext />Accept an answer of around 90 or -90<endouttext />
    3:   <customresponse answerdisplay="something near 90 or -90">
    4:     <answer type="loncapa/perl">
    5: # We do not want a vector
    6: if ($submission=~/\,/) { return 'EXTRA_ANSWER'; }
    7: # No units needed
    8: if ($submission=~/^\d+\s+\w+$/) { return 'UNIT_NOTNEEDED'; }
    9: # Need a numerical answer here
   10: if ($submission!~/^[\d\.\-]+$/) { return 'WANTED_NUMERIC'; }
   11: $difference=abs(90-abs($submission));
   12: if ($difference==0) { return 'EXACT_ANS'; }
   13: if ($difference < 0.001) { return 'APPROX_ANS'; }
   14: return 'INCORRECT';
   15:     </answer>
   16:     <textline />
   17:   </customresponse>
   18: </problem>
   19: 

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