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

Ajax grader doesn't work for non-english decimal separators

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • None
    • 3.9.12, 3.10.9, 3.11.5, 4.0, 4.0.8
    • Gradebook
    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE

      Introduction

      This is a split of MDL-73824, where it's being checked how PHP8 behaves with non-english, different from the decimal point (.) sites.

      it has been split from it, because it's a pre-existing bug, causing the AJAX grader not to work properly when any site (say Spanish, French... ) is not using the decimal point, but others (comma...) as separator.

      Reproduction

      To reproduce:

      • In a site with some course and activity grades.
      • Set the current language to Spanish, French (any lang not using the decimal point (.).
      • Go to the gradebook of the course.
      • Go to grader report preferences / settings.
      • Enable the AJAX grader.
      • Go back to the grader report.
      • Edit inline any existing activity grade and change it to something like '5,67' (using the comma decsep).

      Expected behavior:

      • The grade is stored properly in the database (5.67 float).
      • The grader report shown 5,67 (current lang) when the grade comes back from the backend.

      Current behavior:

      • Depending of the PHP version being used, the grade can end in the database as just 5 (or fail to be saved).
      • The grader report shows 5.67 (point decsep) when the grade comes back from the backend.

      The problems

      A little bit of research shows 2 problems:

      1) The grade/report/grader/ajax_callbacks.php is missing a:

      $finalvalue = format_float($finalgrade, 2);
      

      in order to send back the float in the current language (using comma).

      2) The grade/report/grader/module.js module is doing some parseFloat() executions that prevent the comma to be shown back.

      3) Also, while trying to reproduce it, Sara has found that there is a slight color difference between grades overridden without AJAX and grade overridden with the AJAX grader enabled. They both should match.

      The goals

      So, this issue should aim to:

      a) Make the backend to process and send back the floats properly.
      b) Make the JS module to accept what the backend sends back to it.
      c) Ensure the colors between non-ajax and ajax overridden changes are 100% the same.
      d) Cover both dot and comma dec separators with a behat test to ensure that everything is working ok with any supported PHP version (7.3-8.0).

      Ciao

            Unassigned Unassigned
            stronk7 Eloy Lafuente (stronk7)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

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