Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-42450

Wrong grade letters are calculated because of a float comparison

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • 2.3.9, BACKEND
    • Gradebook
    • None
    • MOODLE_23_STABLE

      When grade letters get calculated in file lib/gradelib.php, divisions and multiplications are made on the given (float) grades (function grade_format_gradevalue_letter($value, $grade_item)). Thereby floating point errors can occur, for instance, if $value=58 is given, after those operations 57.99999999999999289457264239899814128875732421875000.
      Then, the comparison between 57.999999999 >= 58 does not work anymore. Therefore, the student gets a worse grade (letter) as he deserves.

      The fix could be a simple
      $value = round($value, 10);
      before the comparison loop starts...

            Unassigned Unassigned
            brian Brian
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.