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

Wrong grade letters are calculated because of a float comparison

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.3.9, BACKEND
    • Fix Version/s: None
    • Component/s: Gradebook
    • Labels:
      None
    • Affected Branches:
      MOODLE_23_STABLE

      Description

      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...

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              brian Brian
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: