Annotation of loncom/html/adm/help/tex/Custom_Response_Problems.tex, revision 1.2

1.1       www         1: \label{Custom_Response_Problems}
                      2: Custom Response is a way to have a problem graded based on an algorithm. The use of this response type is
                      3: generally discouraged, since the responses will not be analyzable by the LON-CAPA statistics tools.
                      4: 
                      5: The student answer is stored in the
                      6: variable \$submission, and needs to be evaluated by Perl code inside the <answer>-tag. Custom Response needs to return a standard LON-CAPA grading code:
                      7: \begin{itemize}
                      8: \item EXACT\_ANS: return if solved exactly correctly
                      9: \item APPROX\_ANS: return if solved approximately
1.2     ! albertel   10: \item INCORRECT: return if not correct, uses up a try
1.1       www        11: \item SIG\_FAIL, NO\_UNIT, ANS\_CNT\_NOT\_MATCH, BAD\_FORMULA, 
1.2     ! albertel   12: WANTED\_NUMERIC: return if not correct for different reasons, does not use up a try
1.1       www        13: \end{itemize}
                     14: The answer display is shown instead of the student response in 'show answer' mode.
                     15: The following example illustrates this:
                     16: \begin{verbatim}
                     17: <problem>
                     18: <startouttext />Accept an answer of around 90 or -90<endouttext />
                     19:   <customresponse answerdisplay="something near 90 or -90">
                     20:     <answer type="loncapa/perl">
                     21: # We do not want a vector
                     22: if ($submission=~/\,/) { return 'ANS_CNT_NOT_MATCH'; }
                     23: # Need a numerical answer here
                     24: if ($submission!~/^[\d\.\-\e]+$/i) { return 'WANTED_NUMERIC'; }
                     25: $difference=abs(90-abs($submission));
                     26: if ($difference==0) { return 'EXACT_ANS'; }
                     27: if ($difference < 0.1) { return 'APPROX_ANS'; }
                     28: return 'INCORRECT';</answer>
                     29:     <textline readonly="no" />
                     30:   </customresponse>
                     31: </problem>
                     32: \end{verbatim}

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