Moodle

Calculated questions are calculating answers irrespective of number of decimals set.

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: 1.6.1, 1.6.2
  • Fix Version/s: None
  • Component/s: Quiz
  • Labels:
    None
  • Environment:
    LAMP
  • Affected Branches:
    MOODLE_16_STABLE

Description

Debra and I had a conversation at http://moodle.org/mod/forum/discuss.php?d=55849
Debra had encountered this:
<i>I created a calculated question. The student answered 1.59, which was correct and the feedback indicated the correct answer was 1.59 but still scored the student 0/2 pts. I checked to make sure the student did not put in any extra spaces or syntax. I edited the question and sure enough 1.59 is listed as a correct answer.</i>

I was able to duplicate the problem successfully

I have discovered what is happening.

formula is 6.375/{a}
your {a} are various values fore.g. 4

Since you had mentioned: correct answer should have '2' decimal figures, the dataset has calculated the answers only upto 2 decimal figures...thus 1.59 is one of the answers in the dataset

The bug is: when you fill in the answer while attempting the question, it is not limiting itself to 2 decimals.
so try filling the follwing answers:
1.59---> incorrect
1.593---> incorrect
1.5937---> incorrect
1.59375---> Correct

Surprise!! surprise!!

Want more surprise?
Here you go===> this behaviour does not change even if you change the setting of 2 decimals to 3 significant figures.

Therefore, the bug is=> the decimal/significant figure option is affecting only the dataset for wildcard replacement but fails to be applied when answers filled in are matched with possible answers.

To take it further
if you click on 'fill with correct', it fills 1.59 only (taking it from dataset)
but if you click 'submit' then, it says 'incorrect'.

HOWEVER

once i set the settings as shown below, the preview started accepting 1.59 as correct. this was once decimal was set to 5 and tolerance to 0.01

  1. try.JPG
    47 kB
    08/Oct/06 4:01 PM
  2. try2.JPG
    57 kB
    08/Oct/06 4:01 PM
  3. try3.JPG
    23 kB
    08/Oct/06 4:01 PM

Issue Links

Activity

Hide
Dr S Bhatia added a comment -

Allow me to say that

The way i have written this bug, it's obvious that this is my first bug report. Therefore i dare say it doen't appear to be crystal clear to the reader. So I ruefully request you to please read the forum post that generated this bug. The link is in the first line of description itself. After that, you'd know the reference to the context and will comprehend the bug better.

Sorry for the hotch-potch.

Show
Dr S Bhatia added a comment - Allow me to say that The way i have written this bug, it's obvious that this is my first bug report. Therefore i dare say it doen't appear to be crystal clear to the reader. So I ruefully request you to please read the forum post that generated this bug. The link is in the first line of description itself. After that, you'd know the reference to the context and will comprehend the bug better. Sorry for the hotch-potch.
Hide
Pierre Pichet added a comment -

This is not a real bug but a quite normal misunderstaning of the Tolerance parameter and the significant figures requirement.

The tolerance that you set to 0 is correctly interpreted.

The number of significant figures is also an evaluation criteria. It is significant in my teaching of analytical chemistry so the actual code is OK.

And the resulting criterias are correctly interpreted are shown when you created data items.Look at the minimum and maximum values on your screenshot #2.

Show
Pierre Pichet added a comment - This is not a real bug but a quite normal misunderstaning of the Tolerance parameter and the significant figures requirement. The tolerance that you set to 0 is correctly interpreted. The number of significant figures is also an evaluation criteria. It is significant in my teaching of analytical chemistry so the actual code is OK. And the resulting criterias are correctly interpreted are shown when you created data items.Look at the minimum and maximum values on your screenshot #2.
Hide
Pierre Pichet added a comment -

Sorry I just report what I understand from the posting to the forum. I will test it and come back.

Show
Pierre Pichet added a comment - Sorry I just report what I understand from the posting to the forum. I will test it and come back.
Hide
Pierre Pichet added a comment -

Ok I find the problem.
You set Tolerance 0 and set it relative so you ask 0% error on the result so you want the exact number. If you were dividing 1/3, the correct response will 0.333333333333333 up to the decimal precision of the php settings.
The code calculate the MIn and Max value and apply a corecting factor for the decimal precision say delta so the Min= Min-delta and Max is Max+ delta.
The significant figures are applied after this calculation and and there are the figures that are displayed when you ask to fill or to see the grade.
Having a 0 relative tolerance setting is not surely what you want and this is why there is a 0.01 nominal value suggested when you fill the form.
I think that this is more a feature of the actual code than a bug although ideally the code should correct ALL the user errors or misunderstandings.

Show
Pierre Pichet added a comment - Ok I find the problem. You set Tolerance 0 and set it relative so you ask 0% error on the result so you want the exact number. If you were dividing 1/3, the correct response will 0.333333333333333 up to the decimal precision of the php settings. The code calculate the MIn and Max value and apply a corecting factor for the decimal precision say delta so the Min= Min-delta and Max is Max+ delta. The significant figures are applied after this calculation and and there are the figures that are displayed when you ask to fill or to see the grade. Having a 0 relative tolerance setting is not surely what you want and this is why there is a 0.01 nominal value suggested when you fill the form. I think that this is more a feature of the actual code than a bug although ideally the code should correct ALL the user errors or misunderstandings.
Hide
Dr S Bhatia added a comment -

We can live with this Pierre

But i guess it is important to have this point explicit in the help which pops up when you click the icon of tolerance or set decimal places so that a teacher knows what he/she is bargaining for.

Show
Dr S Bhatia added a comment - We can live with this Pierre But i guess it is important to have this point explicit in the help which pops up when you click the icon of tolerance or set decimal places so that a teacher knows what he/she is bargaining for.
Hide
Pierre Pichet added a comment -

see http://moodle.org/mod/forum/discuss.php?d=55849#254804 for a more complete explanation

Show
Pierre Pichet added a comment - see http://moodle.org/mod/forum/discuss.php?d=55849#254804 for a more complete explanation
Hide
Pierre Pichet added a comment -

see http://moodle.org/mod/forum/discuss.php?d=55849#254986 for a solution tested and the tests results

Show
Pierre Pichet added a comment - see http://moodle.org/mod/forum/discuss.php?d=55849#254986 for a solution tested and the tests results
Hide
Dr S Bhatia added a comment -

Pierre has done the requisite I Guess.
This can be closed now, I suppose.

Show
Dr S Bhatia added a comment - Pierre has done the requisite I Guess. This can be closed now, I suppose.
Hide
Pierre Pichet added a comment -

This is not so simple because if the nb of significant figures is defined in calculated question, it is not defined in numerical question.
This has to be set before as a new element of the editing display of numerical question.

Show
Pierre Pichet added a comment - This is not so simple because if the nb of significant figures is defined in calculated question, it is not defined in numerical question. This has to be set before as a new element of the editing display of numerical question.
Hide
Pierre Pichet added a comment -

As a possible solution we can use the fact that when $answer is coming from calcualted question the $answer->correctanswerlength (i.e. number of decimals) is defined but not defined in numerical

if(isset(answer->correctanserlength && $answer->correctansewrlength >= 0) {
return (round($answer->min,$answer->correctanswerlength) <= $response && $response <= round($answer->max ,$answer->correctanswerlength));
}
else{
return ($answer->min <= $response && $response <= $answer->max );
}

Show
Pierre Pichet added a comment - As a possible solution we can use the fact that when $answer is coming from calcualted question the $answer->correctanswerlength (i.e. number of decimals) is defined but not defined in numerical if(isset(answer->correctanserlength && $answer->correctansewrlength >= 0) { return (round($answer->min,$answer->correctanswerlength) <= $response && $response <= round($answer->max ,$answer->correctanswerlength)); } else{ return ($answer->min <= $response && $response <= $answer->max ); }
Hide
Pierre Pichet added a comment -

This is more complex because correctanswerlength is not the right parameter.It has to go with correctanswerformat.
Perhaps the best way will be to create a get_tolerance_interval specific to calculated question

Show
Pierre Pichet added a comment - This is more complex because correctanswerlength is not the right parameter.It has to go with correctanswerformat. Perhaps the best way will be to create a get_tolerance_interval specific to calculated question
Hide
Dr S Bhatia added a comment -

Frankly Pierre,
i am not really able to follow what you are telling coz of limited tech knowledge.
however if you have realized this is a proper bug, then please go ahead to involve other people too.
I can see that i am not being very helpful to you coz i can't follow much ;-(

Show
Dr S Bhatia added a comment - Frankly Pierre, i am not really able to follow what you are telling coz of limited tech knowledge. however if you have realized this is a proper bug, then please go ahead to involve other people too. I can see that i am not being very helpful to you coz i can't follow much ;-(
Hide
Pierre Pichet added a comment -

My comments are mostly for Tim as the bug is assigned to him.
So when the teacher is creating the datasets he see the result of calculated/questiontype.php/ function comment_on_datasetitems($question, $data, $number user )
this function before calling numerical/get_tolerance_interval() add the followiing parameters
$calculated->tolerance = $answer->tolerance;
$calculated->tolerancetype = $answer->tolerancetype;
$calculated->correctanswerlength = $answer->correctanswerlength;
$calculated->correctanswerformat = $answer->correctanswerformat;
$virtualqtype->get_tolerance_interval($calculated);
if ($calculated->min === '') { // This should mean that something is wrong $errors .= " -$calculated->answer"; $stranswers .= $delimiter; } else {
$stranswers .= $delimiter.$calculated->answer;
$strmin .= $delimiter.$calculated->min;
$strmax .= $delimiter.$calculated->max;
expecting that numerical/get_tolerance_interval() wil use the $answer->correctanswerlength and $answer->correctanswerformat the same way that they are used in qtype_calculated_calculate_answer($formula, $individualdata,
$tolerance, $tolerancetype, $answerlength, $answerformat='1', $unit='')
i.e. a somewhat multistep code (see the code in calculated/questiontype.php)
I will try to figure if the modifications should be done in calculated/questiontype.php or in numerical/questiontype.php.
Because a value of tolerance of 0.001 can be represented by 0.001 or 1.0e-3 the code should be able to handle the two solutions with the right significant figures in min and max.

Show
Pierre Pichet added a comment - My comments are mostly for Tim as the bug is assigned to him. So when the teacher is creating the datasets he see the result of calculated/questiontype.php/ function comment_on_datasetitems($question, $data, $number user ) this function before calling numerical/get_tolerance_interval() add the followiing parameters $calculated->tolerance = $answer->tolerance; $calculated->tolerancetype = $answer->tolerancetype; $calculated->correctanswerlength = $answer->correctanswerlength; $calculated->correctanswerformat = $answer->correctanswerformat; $virtualqtype->get_tolerance_interval($calculated); if ($calculated->min === '') { // This should mean that something is wrong $errors .= " -$calculated->answer"; $stranswers .= $delimiter; } else { $stranswers .= $delimiter.$calculated->answer; $strmin .= $delimiter.$calculated->min; $strmax .= $delimiter.$calculated->max; expecting that numerical/get_tolerance_interval() wil use the $answer->correctanswerlength and $answer->correctanswerformat the same way that they are used in qtype_calculated_calculate_answer($formula, $individualdata, $tolerance, $tolerancetype, $answerlength, $answerformat='1', $unit='') i.e. a somewhat multistep code (see the code in calculated/questiontype.php) I will try to figure if the modifications should be done in calculated/questiontype.php or in numerical/questiontype.php. Because a value of tolerance of 0.001 can be represented by 0.001 or 1.0e-3 the code should be able to handle the two solutions with the right significant figures in min and max.
Hide
Pierre Pichet added a comment -

I propose a solution which copy to numerical/questiontype.php with some modifications the qtype_calculated_calculate_answer from calculated/questiontype.php
The resulting function has been tested at http://132.208.141.198/moodle_head/testnumericala.php
There are some problems when the values are near the PHP precision limit. should we test this further?
The code modification have been done on http://132.208.141.198/moodle_head/

So Tim, when you are ready to work on, just add a comment, i am on the watching linst of this bug

Show
Pierre Pichet added a comment - I propose a solution which copy to numerical/questiontype.php with some modifications the qtype_calculated_calculate_answer from calculated/questiontype.php The resulting function has been tested at http://132.208.141.198/moodle_head/testnumericala.php There are some problems when the values are near the PHP precision limit. should we test this further? The code modification have been done on http://132.208.141.198/moodle_head/ So Tim, when you are ready to work on, just add a comment, i am on the watching linst of this bug
Hide
Pierre Pichet added a comment -

Will add some further validation procedure when buiding datasetitems (datasetitems_form.php) so that problems with significant figures and tolerance values are pinpointed and corrected.
see http://moodle.org/mod/forum/discuss.php?d=87939

Show
Pierre Pichet added a comment - Will add some further validation procedure when buiding datasetitems (datasetitems_form.php) so that problems with significant figures and tolerance values are pinpointed and corrected. see http://moodle.org/mod/forum/discuss.php?d=87939
Hide
Ralf Hilgenstock added a comment -
Show
Ralf Hilgenstock added a comment - Similar problem at http://tracker.moodle.org/browse/MDL-14433
Hide
Michael de Raadt added a comment -

Thanks for reporting this issue.

We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

Michael d;

lqjjLKA0p6

Show
Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
Hide
Michael de Raadt added a comment -

I'm closing this issue as it has become inactive and does not appear to affect a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Show
Michael de Raadt added a comment - I'm closing this issue as it has become inactive and does not appear to affect a current supported version. If you are encountering this problem or one similar, please launch a new issue.

People

Vote (2)
Watch (4)

Dates

  • Created:
    Updated:
    Resolved: