Numerical question not showing correct answer when correct answer is zero

Numerical question not showing correct answer when correct answer is zero

by Nigel Robertson -
Number of replies: 3
This one is a bit hard to describe! The attached screen-shots might help.

If the correct answer to a numerical question is non-zero, then that correct answer can be shown when an incorrect submission is made. This is done by selecting 'Answers' in the Review options of the quiz setup. However, if the correct answer is '0' (zero) then the correct answer does not display on submission. It also appears that the number of incorrect attempts on a question where the answer is zero is not being recorded.

I can't find anything about this in the forums or the tracker - but perhaps I haven't searched hard enough! Has anyone come across this at all? If not, I'll file a bug report.

Moodle 1.9.7+

Cheers, Nigel
Attachment Answer_feedback01.png
Average of ratings: -
In reply to Nigel Robertson

Re: Numerical question not showing correct answer when correct answer is zero

by Pierre Pichet -
You are rigth,
This is related to the test done for showing or not the Correct answer
like line 306 of shortanswer/questiontype.php

if ($correctanswer) {
echo ('<div class="correctness">');
print_string('correctansweris', 'quiz', s($correctanswer, true));
echo ('</div>');
}
if $correctanswer == 0 , it will not show.
If not already done, I will fill a bug report later this day (with the solution...)

Pierre
In reply to Pierre Pichet

Re: Numerical question not showing correct answer when correct answer is zero

by Nigel Robertson -

Thanks Pierre!

Have filed it as http://tracker.moodle.org/browse/MDL-21336

Cheers, Nigel

In reply to Nigel Robertson

Re: Numerical question not showing correct answer when correct answer is zero

by Nigel Robertson -
This issue is now fixed - thanks Pierre!
Details in Tracker ref'd in previous post.

Cheers, Nigel