LON-CAPA Help
Custom Response is a way to have a problem graded based on an algorithm. The use of this response type is
generally discouraged, since the responses will not be analyzable by the LON-CAPA statistics tools.
The student answer is stored in the
variable $submission, and needs to be evaluated by Perl code inside the <answer>-tag. Custom Response needs to return a standard LON-CAPA. The most common response are:
- EXACT_ANS: return if solved exactly correctly
- APPROX_ANS: return if solved approximately
- INCORRECT: return if not correct, uses up a try
- SIG_FAIL, NO_UNIT, EXTRA_ANSWER, MISSING_ANSWER, BAD_FORMULA,
WANTED_NUMERIC: return if not correct for different reasons, does not use up a try
The answer display is shown instead of the student response in 'show answer' mode.
The following example illustrates this:
<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'; }
# Need a numerical answer here
if ($submission!~/^[\d\.\-\e]+$/i) { return 'WANTED_NUMERIC'; }
$difference=abs(90-abs($submission));
if ($difference==0) { return 'EXACT_ANS'; }
if ($difference < 0.1) { return 'APPROX_ANS'; }
return 'INCORRECT';</answer>
<textline readonly="no" />
</customresponse>
</problem>
Full list of possible return codes:
- EXACT_ANS: student is exactly correct
- APPROX_ANS: student is approximately correct
- NO_RESPONSE: student submitted no response
- MISSING_ANSWER: student submitted some but not all parts of a response
- EXTRA_ANSWER: student submitted a vector of values when a scalar was expected
- WANTED_NUMERIC: expected a numeric answer and didn't get one
- SIG_FAIL: incorrect number of Significant Figures
- UNIT_FAIL: incorrect unit
- UNIT_NOTNEEDED: Submitted a unit when one shouldn't
- UNIT_INVALID_INSTRUCTOR: the unit provided by the author of the problem is unparsable
- UNIT_INVALID_STUDENT: the unit provided by the student is unparasable
- UNIT_IRRECONCIBLE: the unit from the student and the instructor are of different types
- NO_UNIT: needed a unit but none was submitted
- BAD_FORMULA: syntax error in submitted formula
- INCORRECT: answer was wrong
- SUBMITTED: submission wasn't graded
- DRAFT: submission only stored
- MISORDERED_RANK: student submitted a poorly order rank response
- ERROR: unable to get a grade
- ASSIGNED_SCORE: there is a resource.partid.responseid.awarded the real awarded should be set to the average of the individual awards
- TOO_LONG: answer submission to CAPA engine longer than 500 characters
- INVALID_FILETYPE: student tried to upload a file that was of an extension that was not specifically allowed
- COMMA_FAIL: answer requires the use of comma grouping and it wasn't provided or was incorrect