Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Small numerical answers i.e. 1e-18 are not graded correctly MDL-8473 …

…merging from head
  • Loading branch information...
commit d8720eebc38bf6f04b7fed3362d9a9d5fedd6b3c 1 parent b7f1aee
pichetp authored

Showing 1 changed file with 12 additions and 1 deletion. Show diff stats Hide diff stats

  1. +12 1 question/type/numerical/questiontype.php
13 question/type/numerical/questiontype.php
@@ -356,9 +356,20 @@ function get_tolerance_interval(&$answer) {
356 356 /// Recalculate the tolerance and fall through
357 357 /// to the nominal case:
358 358 $tolerance = $answer->answer * $tolerance;
359   - // Falls through to the nominal case -
  359 + // Do not fall through to the nominal case because the tiny fraction is a factor of the answer
  360 + $tolerance = abs($tolerance); // important - otherwise min and max are swapped
  361 + $max = $answer->answer + $tolerance;
  362 + $min = $answer->answer - $tolerance;
  363 + break;
360 364 case '2': case 'nominal':
361 365 $tolerance = abs($tolerance); // important - otherwise min and max are swapped
  366 + // $answer->tolerance 0 or something else
  367 + if ((float)$answer->tolerance == 0.0 && abs((float)$answer->answer) <= $tolerance ){
  368 + $tolerance = (float) ("1.0e-".ini_get('precision')) * abs((float)$answer->answer) ; //tiny fraction
  369 + } else if ((float)$answer->tolerance != 0.0 && abs((float)$answer->tolerance) < abs((float)$answer->answer) && abs((float)$answer->answer) <= $tolerance){
  370 + $tolerance = (1+("1.0e-".ini_get('precision')) )* abs((float) $answer->tolerance) ;//tiny fraction
  371 + }
  372 +
362 373 $max = $answer->answer + $tolerance;
363 374 $min = $answer->answer - $tolerance;
364 375 break;

0 comments on commit d8720ee

Please sign in to comment.
Something went wrong with that request. Please try again.