Calculated question using first parameter as correct answer

Calculated question using first parameter as correct answer

by Melissa Bitner -
Number of replies: 3
I apologize if this has been asked and answered elsewhere - I did a fair amount of searching but didn't find anything.

We're using Moodle 1.9.5 and one of our professors reported an issue when creating calculated questions. I could reproduce the issue consistently with a simple calculated question.

I created a new calculated question with no shared wildcards. Here are the settings:

question name: random calculated question test
question text: What is {a} + {b}?
format: HTML format
image to display: none
default question grade: 1
penalty factor 0.1
general feedback: blank
correct answer formula: {a}+{b}
grade: 100%
tolerance: 0
tolerance type: relative
correct answer shows: 0
format: decimal
feedback: blank

The next page has both wildcards using the same existing private dataset as before. Under that it says possible wildcards present only in the question text.

On the final page item one has two parameters set (in this case 7 and 3) but the sample addition underneath shows the correct answer as 7 (7+3=7). It will consistently select the first parameter as the correct answer. It will also do this when you preview the question - if you put 10 in the text box it will mark it as incorrect and the fill in correct button puts in 7 instead.

Interestingly, if parentheses are added to the correct answer formula ({a}+{b}) then the correct answer will always come up as 0.

What am I doing wrong when I set up the calculated question? Thank you very much.

Average of ratings: -
In reply to Melissa Bitner

Re: Calculated question using first parameter as correct answer

by Pierre Pichet -
Cannot reproduce

Paramètre {a} 7
Paramètre {b} 3
{a}+{b} 7+3 = 10
Min: 9.9999999999999---Max: 10
Réponse correcte : 10 dans les limites de la valeur réelle 10

What are the min-max value on the third page ?

Do you really have
7 (7+3=7). and not
{a}+{b} 7+3 = 10
On the other end it is as if the + character is not recognized as the addition sign but as the end of the math expression.

Have you the same problem with other settings allowing real decimal values i.e.
tolerance > 0 i.e. 0.01
correct answer shows: 1 decimal

Pierre
In reply to Pierre Pichet

Re: Calculated question using first parameter as correct answer

by Melissa Bitner -
The min-max values on the last page look like this:

{a}+{b}
7+3 = 7
Min: 6.9999999999999---Max: 7.0000000000001
Correct answer : 7 inside limits of true value 7+3

I tried changes to the tolerance and to decimal values allowed but it didn't cause a change in behavior (other than the answer in the above would be given as 7.0 smile.

The instructor informed me that calculated questions were working two weeks ago but have stopped since then so something must have changed on our side. I didn't think we'd made any changes to the question code so I'll have to track down what's different between now and two weeks ago. Thank you very much for your time.
In reply to Melissa Bitner

Re: Calculated question using first parameter as correct answer

by Pierre Pichet -
could you look what are the real characters stored in the database answer field of question_answers table

The + between the 7 and 3 is somehow corrupted and not interpreted correctly i.e. as the addition sign but as the end of the mathematical string.
Perhaps setting temporarely your PHP debug to full display will help.

Pierre