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

Decimal places in question grades: "same as for overall grade" does not work - it shows 0 decimal places regardless of overall grade setting

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.3, 2.3.1, 2.4
    • Fix Version/s: 2.2.5, 2.3.2
    • Component/s: Quiz
    • Labels:
      None
    • Testing Instructions:
      Hide

      1. If you have an old site that was upgraded from 1.9, have a look in the mdl_quiz table, and see if you have any rows where the questiondecimalpoints column contains the incorrect default value of -2.

      If you don't artificially edit a row to have that value.

      2. Run the upgrade.

      3. Verify that that column now has default -1 in the database schema.

      4. Verify all the rows that contained -2 now contain -1 there.

      Show
      1. If you have an old site that was upgraded from 1.9, have a look in the mdl_quiz table, and see if you have any rows where the questiondecimalpoints column contains the incorrect default value of -2. If you don't artificially edit a row to have that value. 2. Run the upgrade. 3. Verify that that column now has default -1 in the database schema. 4. Verify all the rows that contained -2 now contain -1 there.
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      Decimal places in question grades: "same as for overall grade" does not work - it shows 0 decimal places regardless of overall grade setting

      The only way to show 2 decimal places (like the overall grade) is to choose 2 manually from this list. Setting 2 as the default in the site wide settings doesn't override this either - it only changes it for new quizzes.

        Gliffy Diagrams

        1. screenshot-1.jpg
          414 kB
        2. screenshot-2.jpg
          204 kB
        3. screenshot-3.jpg
          156 kB

          Activity

          Hide
          timhunt Tim Hunt added a comment -

          Screen-grab please. Where does this happen?

          Show
          timhunt Tim Hunt added a comment - Screen-grab please. Where does this happen?
          Hide
          jgramp Jessica Gramp added a comment -

          This shows a negative -0 grade being given for students in the bottom, left corner for Q.3. This is because it is rounding the question grades to 0 decimal places (the real score is -0.33), even though the "Decimal places in question grades" setting for this quiz is "same as for overall grade". The overall grade setting (Decimal places in grades), shown in another screenshot, is set to 2, so this should be 2 as well.

          Show
          jgramp Jessica Gramp added a comment - This shows a negative -0 grade being given for students in the bottom, left corner for Q.3. This is because it is rounding the question grades to 0 decimal places (the real score is -0.33), even though the "Decimal places in question grades" setting for this quiz is "same as for overall grade". The overall grade setting (Decimal places in grades), shown in another screenshot, is set to 2, so this should be 2 as well.
          Hide
          jgramp Jessica Gramp added a comment -

          Here's what the quiz should be showing. I can only see this if I manually change the "Decimal places in question grades" setting to 2.

          Show
          jgramp Jessica Gramp added a comment - Here's what the quiz should be showing. I can only see this if I manually change the "Decimal places in question grades" setting to 2.
          Hide
          jgramp Jessica Gramp added a comment -

          This shows the quiz settings page where:

          Decimal places in question grades: "same as for overall grade"

          Show
          jgramp Jessica Gramp added a comment - This shows the quiz settings page where: Decimal places in question grades: "same as for overall grade"
          Hide
          timhunt Tim Hunt added a comment -

          Well, it is working for me. I just tested. I also reviewed the code, and I cannot see any way that it would not work.

          If you can follow PHP code, look at the other_cols method in mod/quiz/report/overview/overview_table.php and the functions it calls, quiz_rescale_grade in mod/quiz/locallib.php and quiz_format_grade and quiz_format_question_grade in mod/quiz/lib.php.

          Show
          timhunt Tim Hunt added a comment - Well, it is working for me. I just tested. I also reviewed the code, and I cannot see any way that it would not work. If you can follow PHP code, look at the other_cols method in mod/quiz/report/overview/overview_table.php and the functions it calls, quiz_rescale_grade in mod/quiz/locallib.php and quiz_format_grade and quiz_format_question_grade in mod/quiz/lib.php.
          Hide
          jgramp Jessica Gramp added a comment -

          Hi Tim,

          Our developer has identified that all quizzes that were upgraded from Moodle 1.9 to 2.2.3 have -2 as the default value for the questiondecimalpoints setting, rather than the -1 being checked for in the code and which I assume is set for all new quizzes (hence you not seeing the issue occur yourself). We are going to change our code to check for any value below 0 instead of the exact value of -1, which will fix the issue for us without us having to touch any data in our database.

          In mod/quiz/lib.php function quiz_format_question_grade
          There's a test for "if ($quiz->questiondecimalpoints == -1)"
          We have 3050 quizzes where that value is -2 (the upgraded quizzes)
          So we can chang the test to :
          if ($quiz->questiondecimalpoints < 0)

          Is this something that can be fixed in the core code?

          Show
          jgramp Jessica Gramp added a comment - Hi Tim, Our developer has identified that all quizzes that were upgraded from Moodle 1.9 to 2.2.3 have -2 as the default value for the questiondecimalpoints setting, rather than the -1 being checked for in the code and which I assume is set for all new quizzes (hence you not seeing the issue occur yourself). We are going to change our code to check for any value below 0 instead of the exact value of -1, which will fix the issue for us without us having to touch any data in our database. In mod/quiz/lib.php function quiz_format_question_grade There's a test for "if ($quiz->questiondecimalpoints == -1)" We have 3050 quizzes where that value is -2 (the upgraded quizzes) So we can chang the test to : if ($quiz->questiondecimalpoints < 0) Is this something that can be fixed in the core code?
          Hide
          timhunt Tim Hunt added a comment -

          Great detective work. Please pass on my thanks to your developer. It will now be trivial to fix this in core. I suspect I will do it by adding an upgrade step to replace -2 with -1.

          Show
          timhunt Tim Hunt added a comment - Great detective work. Please pass on my thanks to your developer. It will now be trivial to fix this in core. I suspect I will do it by adding an upgrade step to replace -2 with -1.
          Hide
          jgramp Jessica Gramp added a comment -

          Thanks Tim, but is it also possible to fix it for those who have already upgraded? Otherwise we'll either need to update our database code or continue to re-apply our patch every time we upgrade. Or will this be something that is also resolved when we do a less major upgrade for example from 2.2.3 to 2.3 ?

          Show
          jgramp Jessica Gramp added a comment - Thanks Tim, but is it also possible to fix it for those who have already upgraded? Otherwise we'll either need to update our database code or continue to re-apply our patch every time we upgrade. Or will this be something that is also resolved when we do a less major upgrade for example from 2.2.3 to 2.3 ?
          Hide
          timhunt Tim Hunt added a comment -

          I think you should just directly update you database:

          UPDATE mdl_quiz SET questiondecimalpoints = -1 WHERE questiondecimalpoints = -2

          or

          UPDATE mdl_quiz SET questiondecimalpoints = -1 WHERE questiondecimalpoints < -1

          if you prefer.

          Alternatively, you can just wait until you next do a minor upgrade.

          Show
          timhunt Tim Hunt added a comment - I think you should just directly update you database: UPDATE mdl_quiz SET questiondecimalpoints = -1 WHERE questiondecimalpoints = -2 or UPDATE mdl_quiz SET questiondecimalpoints = -1 WHERE questiondecimalpoints < -1 if you prefer. Alternatively, you can just wait until you next do a minor upgrade.
          Hide
          timhunt Tim Hunt added a comment -

          Submitting for integration.

          This fix will correct any wrong values when people next upgrade on any of the supported stable branches.

          Show
          timhunt Tim Hunt added a comment - Submitting for integration. This fix will correct any wrong values when people next upgrade on any of the supported stable branches.
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          Integrated (22, 23 & master), thanks!

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - Integrated (22, 23 & master), thanks!
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          Note: extra commit added to 22_STABLE to fix one non-matching savepoint. Yay CI!

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - Note: extra commit added to 22_STABLE to fix one non-matching savepoint. Yay CI!
          Hide
          dmonllao David Monllaó added a comment -

          It passes. In 1.9 the 'questiondecimalpoints' field does not exists, and with the patch applied the field is created with value -1, so to test the 2.2 upgrade process I've begun with a 2.1 (forcing 'questiondecimalpoints' to -2) and then upgrade to 2.2; the value is -1 after the upgrade process

          In a Moodle 2.2 and forcing 'questiondecimalpoints' to be -2, when upgrading to 2.3 the value is also updated to -1

          Show
          dmonllao David Monllaó added a comment - It passes. In 1.9 the 'questiondecimalpoints' field does not exists, and with the patch applied the field is created with value -1, so to test the 2.2 upgrade process I've begun with a 2.1 (forcing 'questiondecimalpoints' to -2) and then upgrade to 2.2; the value is -1 after the upgrade process In a Moodle 2.2 and forcing 'questiondecimalpoints' to be -2, when upgrading to 2.3 the value is also updated to -1
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          YEAR!*

          CAF*, TOT!*

          • Your effort amazingly resulted. (unbelievable :-P)
          • Closing as fixed.
          • Tons of thanks.
          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - YEAR!* CAF*, TOT!* Your effort amazingly resulted. (unbelievable :-P) Closing as fixed. Tons of thanks.

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                10/Sep/12