Answers are typically not displayed to the student when they submit an answer to a problem, unless their answer is correct. When the problem is assigned in a course, a parameter for the `answer date' must be set such that students will see answers displayed when they revisit the problem after that date. The answer date is distinct from the due date which can also be set when a problem is assigned.
Suppose you want the answer displayed as soon as the student finishes the problem rather than waiting until the answer date. For example, this may occur in a multipoint problem where you want the students to see the correct answer for one part before proceding to the next part. If you would like the computer answer to be displayed after the student answer is correct, or the maximum number of tries has been reached, this can be achieved by setting the parameter problemstatus = answer. Using the colorful editor, the parameter can be inserted WITHIN the problem part, but BEFORE the response tag (e.g. numericalresponse). For example:
<part id="01"> <parameter name="problemstatus" id="11" type="string_problemstatus" default="answer" description="Show Problem Status" /> <numericalresponse answer="$c" id="01a"> <!-- using no tolerance since exact integer is expected for answer --> <textline readonly="no" spellcheck="none" /> </numericalresponse> </part>
The options for the problemstatus are: "yes" - shows correct or incorrect only; "answer" - shows computer answer as described above; "no" - don't show correct/incorrect feedback; "no_feedback_ever"- supresses all feedback.
If you want to provide additional explanation in addition to the answer as soon as the maximum tries allowed for the part have been reached, include a conditional block in the problem part, and set the condition for the part to evaluate to true when the problem is either correct, no tries remain, or it is post-answer date.
To achieve this behavior, add a call to the LON-CAPA function &check_status(`partid') for each part to the script block, and set a scalar to the value returned for each part, then use that scalar in the conditional block, e.g.,
<script type="loncapa/perl"> # for part: a $status_a = &check_status('a'); # other computations </script> <part id="a"> <block condition="$status_a"> <startouttext /> <br /> Some explanation text about the answer, $answer <endouttext /> </block> </part>