Moodle
  1. Moodle
  2. MDL-33532

Setting a maximum grade for a quiz doesn't work well with comma as a decimal separator (decsep).

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.3, 2.3
    • Fix Version/s: 2.1.7, 2.2.4, 2.3
    • Component/s: General, Quiz
    • Labels:
    • Testing Instructions:
      Hide

      1. With your language set to Croatian (or any other language that uses , for decsep)
      2. Go do Quiz settings -> Edit quiz (or whatever the translation is).
      3. Make sure you can set non-integer maximum grade (e.g. 65,5) , and maximum mark for each question.
      4. Make sure the value is saved as the non-integer value

      Show
      1. With your language set to Croatian (or any other language that uses , for decsep) 2. Go do Quiz settings -> Edit quiz (or whatever the translation is). 3. Make sure you can set non-integer maximum grade (e.g. 65,5) , and maximum mark for each question. 4. Make sure the value is saved as the non-integer value
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      41457

      Description

      If the user's language uses comma as a decimal separator, setting a maximum grade doesn't work well.

      Steps to reproduce:
      1. Set your language to a language that uses comma as decimal separator (decsep). (I'm using Hrvatski / Croatian)
      2. Create a quiz and open "Edit quiz" page. (Or do this step first, then change the language in a new tab, and refresh "Edit quiz" page. )
      3. Set maximum grade (najveća ocjena) to "65,5" (comma) and click "Save"/"Pohrani".
      4. Maximum grade is now 65 instead of 65,5.
      5. Set 65.5 (dot) as maximum grade and click "Save".
      6. Maximum grade is now 65,5 (notice the comma).
      7. Click "Save" without changing the grade.
      8. Maximum grade is now back to 65.

      This isn't a big issue in quiz editing, but maybe some other important part of Moodle is broken too. The problem seems to be within the function optional_param() which rounds the value because php's floatval() works only with dots.

        Activity

        Hide
        Tim Hunt added a comment -

        I think that we really need a PARAM_LOCALENUMBER for this, which is a core change. Until we have that, it is hard to fix this.

        Note for anyone implementing this, that 1,000 is an ambiguous string, if you want to convert that to a float.

        Show
        Tim Hunt added a comment - I think that we really need a PARAM_LOCALENUMBER for this, which is a core change. Until we have that, it is hard to fix this. Note for anyone implementing this, that 1,000 is an ambiguous string, if you want to convert that to a float.
        Hide
        Tim Hunt added a comment -

        Note that I have reviewed all uses of PARAM_FLOAT in quiz and question code.

        There are three remaining uses in question, that are all in formslib forms, and there is no way to fix those yet.

        Show
        Tim Hunt added a comment - Note that I have reviewed all uses of PARAM_FLOAT in quiz and question code. There are three remaining uses in question, that are all in formslib forms, and there is no way to fix those yet.
        Hide
        Dan Poltawski added a comment -

        Integrated, thanks.

        Thanks also for improving that that PARAM_FLOAT comment, I think that is very useful.

        Show
        Dan Poltawski added a comment - Integrated, thanks. Thanks also for improving that that PARAM_FLOAT comment, I think that is very useful.
        Hide
        Dan Poltawski added a comment -

        Tested on 21, 22 and master.

        thanks

        Show
        Dan Poltawski added a comment - Tested on 21, 22 and master. thanks
        Hide
        Eloy Lafuente (stronk7) added a comment -

        We could celebrate it today... but better if we perform a bigger party after releasing Moodle 2.3.

        Print this message and come to Perth that day, it's valid for one beer, wine, coke or... water, as you wish.

        Many thanks for your collaboration!

        Ciao

        Show
        Eloy Lafuente (stronk7) added a comment - We could celebrate it today... but better if we perform a bigger party after releasing Moodle 2.3. Print this message and come to Perth that day, it's valid for one beer, wine, coke or... water, as you wish. Many thanks for your collaboration! Ciao

          People

          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: