courses
courses copied to clipboard
Fix QuizTextHandler.makeCorrection() when the correct answer is 0
makeCorrection() should first check whether the user's answer is exactly the same as the correct answer. This fixes the issue that the user's answer would always be marked incorrect if the correct answer was 0, because the division-by-0 in the relative error calculation would produce NaN.
For example: http://bcaffo.github.io/courses/06_StatisticalInference/homework/hw4.html#6 Enter '0' for the answer to #2 and click "Submit". The red 'X' icon would appear next to the text box. Next click "Show Answer" and "OK" on the pop-up. The correct answer is 0 and the green checkmark icon is now shown next to the text box for #2.