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

Wrong grade letters are calculated because of a float comparison

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.3.9, BACKEND
    • None
    • Gradebook
    • None
    • 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

              Unassigned Unassigned
              brian Brian
              Adrian Greeve, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: