Calculated Questions - Negative Answer with Units - Bug?

Calculated Questions - Negative Answer with Units - Bug?

by Jim Balfour -
Number of replies: 5

Hi All

I have created a calculated question quiz using units which works just great until it comes to negative answers.

Say the correct answer is -1.0000N with the 'tolerance range' -1.1000 to -0.9000.

The only correct answer recognised by the quiz engine the answer displayed after 'Save my answers'.

-1.0000N correct
-1.0000 N incorrect
-1.00N incorrect

Take the units off the question and everything works as it should. Is it just me or is this real bug, and, if so, does anyone know of a work-around?

Average of ratings: -
In reply to Jim Balfour

Re: Calculated/Numerical Questions - Negative Answer with Units - Bug?

by Henrik Kaipe -
Hi James!

It was a real bug alright and as far as I know it has been unknown until now.
Thanks for the details - they made it quite easy to find the typo that caused the bug. The fix is now in the CVS.

The bug is located in the file
<moodledir>/mod/quiz/questiontypes/numerical/questiontype.php
You can fix the bug by exchanging the old file with the new one that is attached to this post!

NOTE! - the bug is for the question type NUMERICAL
but it appears for the question type CALCULATED as well (because calculated questions reuse the logic in numerical questions when responses are graded) -
so make sure you don't exchange the wrong file as there is a file with the exact same name in the directory 'calculated'!

In reply to Henrik Kaipe

Re: Calculated/Numerical Questions - Negative Answer with Units - Bug?

by Jim Balfour -

Hi Henrik

Many thanks for your quick response. Our IT guys applyed your fix first thing this morning, and everything is working perfectly now. Thanks again.

Calculated questions are wonderful. I'm new to Moodle and I'm using it to support a couple of courses in structural mechanics. In particular I'm using Quizzes (based on calculated questions) and Workshops (for peer review of worked solutions to problems). I'm really impressed how Moodle does the 'heavy lifting', leaving me to get on with the more creative aspects of my job.

In reply to Henrik Kaipe

Re: Calculated/Numerical Questions - Negative Answer with Units - Bug?

by John Rodgers -
Did this get fixed in subsequent releases?  I still seem to be having the same problem with calulated questions with negative answers and units? 

I am operating 1.4+ upgraded in march and have a few quiz questions which don't grade properly.
In reply to John Rodgers

Re: Calculated/Numerical Questions - Negative Answer with Units - Bug?

by Gustav W Delius -
Yes, Henrik applied his fix only to Moodle 1.5, not Moodle 1.4. He will be able to reply in more detail.
In reply to Gustav W Delius

Re: Calculated/Numerical Questions - Negative Answer with Units - Bug?

by Jean-Michel Védrine -
Henrik fix is only one line (change in regular expression), it should be very easy to backport it to Moodle 1.4