Moodle
  1. Moodle
  2. MDL-36712

assignment grading screen does not retain grade if grading scale used

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3, 2.3.3
    • Fix Version/s: 2.3.4, 2.4.1
    • Component/s: Assignment
    • Labels:
    • Testing Instructions:
      Hide
      1. Create a custom scale with values "1,2,3,4,5,6"
      2. Create an assignment and set it to use this new scale
      3. Grade a student in this assignment and set the grade to "4"
      4. Change the current language to french (install the lang pack if required)
      5. Go back to the assignment and click the grade button for that student
      6. The default in the custom scale menu should be the same as previously set: "4"
      Show
      Create a custom scale with values "1,2,3,4,5,6" Create an assignment and set it to use this new scale Grade a student in this assignment and set the grade to "4" Change the current language to french (install the lang pack if required) Go back to the assignment and click the grade button for that student The default in the custom scale menu should be the same as previously set: "4"
    • Workaround:
      Hide

      Use quick grading.

      Show
      Use quick grading.
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-36712-master
    • Rank:
      46216

      Description

      When the teacher grades students assignments, the form does not display already present (default) values.

      1.- make a new assignment, using a grading scale (for instance, use the "1 to 6" scale) and activate feedback comments
      2.- have a student make a submission to this assignment
      3.- grade the student's submission (for instance, give him a "4") and write a comment, and validate
      4.- check that the table of submitted assignments lists all your students, and that the student has a grade of "4" and that the comment was saved
      5.- click the "Grade" button to re-grade the assignment
      6.- check that the comment is displayed in the edit form, BUT that the grade selector now says "6"

      The actual grade is indeed displayed, but if the teacher just wants to modify the comment and does not set the grade AGAIN, then the grade is reset to "6"!

      Expected behavior : the grade drop-down menu in step 6 above should have "4" selected.

        Activity

        Hide
        Nicolas Dunand added a comment -

        It seems that QuickForm fails to set the default values to the <select> element because in this case the grade value is "4,00" whereas the <option> value attribute is "4".
        Possible fix:

        diff --git a/mod/assign/gradeform.php b/mod/assign/gradeform.php
        index 366d5d8..004b987 100644
        --- a/mod/assign/gradeform.php
        +++ b/mod/assign/gradeform.php
        @@ -54,6 +54,23 @@ class mod_assign_grade_form extends moodleform {
                 $this->assignment = $assignment;
                 $assignment->add_grade_form_elements($mform, $data, $params);
         
        +        if ($this->assignment->get_instance()->grade < 0) {
        +            $data->grade = (int)$data->grade;
        +        }
                 if ($data) {
                     $this->set_data($data);
                 }
        
        Show
        Nicolas Dunand added a comment - It seems that QuickForm fails to set the default values to the <select> element because in this case the grade value is "4,00" whereas the <option> value attribute is "4". Possible fix: diff --git a/mod/assign/gradeform.php b/mod/assign/gradeform.php index 366d5d8..004b987 100644 --- a/mod/assign/gradeform.php +++ b/mod/assign/gradeform.php @@ -54,6 +54,23 @@ class mod_assign_grade_form extends moodleform { $ this ->assignment = $assignment; $assignment->add_grade_form_elements($mform, $data, $params); + if ($ this ->assignment->get_instance()->grade < 0) { + $data->grade = ( int )$data->grade; + } if ($data) { $ this ->set_data($data); }
        Hide
        Damyon Wiese added a comment -

        Hi Nicolas,

        I think this is affected by your locale - what language / locale are you using?

        Regards, Damyon

        Show
        Damyon Wiese added a comment - Hi Nicolas, I think this is affected by your locale - what language / locale are you using? Regards, Damyon
        Hide
        Nicolas Dunand added a comment -

        Hi Damyon,

        I'm using the 'fr' locale (French), and indeed changing the locale to 'en' solved the problem.
        How can this be? Is it expected behavior, then?

        Thanks, Nicolas

        Show
        Nicolas Dunand added a comment - Hi Damyon, I'm using the 'fr' locale (French), and indeed changing the locale to 'en' solved the problem. How can this be? Is it expected behavior, then? Thanks, Nicolas
        Hide
        Damyon Wiese added a comment -

        No - it's definitely a bug - thanks for confirming its a locale issue for me. It is caused because somewhere in quickforms it is casting the value to an int without using the current locale settings.

        Show
        Damyon Wiese added a comment - No - it's definitely a bug - thanks for confirming its a locale issue for me. It is caused because somewhere in quickforms it is casting the value to an int without using the current locale settings.
        Hide
        Damyon Wiese added a comment -

        Thanks for reporting this issue Nicolas. I have added a patch to this issue which is slightly different to yours - the main difference is that it is using unformat_float instead of casting to an integer which should be more reliable at addressing any locale/language issues.

        Show
        Damyon Wiese added a comment - Thanks for reporting this issue Nicolas. I have added a patch to this issue which is slightly different to yours - the main difference is that it is using unformat_float instead of casting to an integer which should be more reliable at addressing any locale/language issues.
        Hide
        Nicolas Dunand added a comment -

        Thanks for the explanation and the improved fix Damyon. I patched our code here and everything seems to be fine.

        Show
        Nicolas Dunand added a comment - Thanks for the explanation and the improved fix Damyon. I patched our code here and everything seems to be fine.
        Hide
        Damyon Wiese added a comment -

        Thanks for letting us know this fix works for you - that will help the integrators.

        Cheers, Damyon

        Show
        Damyon Wiese added a comment - Thanks for letting us know this fix works for you - that will help the integrators. Cheers, Damyon
        Hide
        Dan Poltawski added a comment -

        Hi Damyon,

        I don't quite understand why we are casting to an int, couldn't we have a float value here validly?

        Show
        Dan Poltawski added a comment - Hi Damyon, I don't quite understand why we are casting to an int, couldn't we have a float value here validly?
        Hide
        Damyon Wiese added a comment -

        Hi Dan

        This code is dealing with custom scales only - so the value must be an int.

        Regards, Damyon

        Show
        Damyon Wiese added a comment - Hi Dan This code is dealing with custom scales only - so the value must be an int. Regards, Damyon
        Hide
        Dan Poltawski added a comment -

        Integrated to master, 24 and 23, thanks!

        Show
        Dan Poltawski added a comment - Integrated to master, 24 and 23, thanks!
        Hide
        Frédéric Massart added a comment -

        Test passed on 2.4 and 2.3. This wild notice appeared after grading the student on 2.4 (but confirmed with Damyon that this is not related to this issue, as it happened because I didn't visit the notifications page):

        Notice: Undefined property: stdClass::$feedback_plugin_for_gradebook in /home/fred/www/repositories/i24/moodle/mod/assign/locallib.php on line 4298 Call Stack: 0.0002 661856 1. {main}() /home/fred/www/repositories/i24/moodle/mod/assign/view.php:0 0.2324 54880704 2. assign->view() /home/fred/www/repositories/i24/moodle/mod/assign/view.php:53 0.2325 54881368 3. assign->process_save_grade() /home/fred/www/repositories/i24/moodle/mod/assign/locallib.php:362 0.2800 57416760 4. assign->apply_grade_to_user() /home/fred/www/repositories/i24/moodle/mod/assign/locallib.php:4408
        
        Show
        Frédéric Massart added a comment - Test passed on 2.4 and 2.3. This wild notice appeared after grading the student on 2.4 (but confirmed with Damyon that this is not related to this issue, as it happened because I didn't visit the notifications page): Notice: Undefined property: stdClass::$feedback_plugin_for_gradebook in /home/fred/www/repositories/i24/moodle/mod/assign/locallib.php on line 4298 Call Stack: 0.0002 661856 1. {main}() /home/fred/www/repositories/i24/moodle/mod/assign/view.php:0 0.2324 54880704 2. assign->view() /home/fred/www/repositories/i24/moodle/mod/assign/view.php:53 0.2325 54881368 3. assign->process_save_grade() /home/fred/www/repositories/i24/moodle/mod/assign/locallib.php:362 0.2800 57416760 4. assign->apply_grade_to_user() /home/fred/www/repositories/i24/moodle/mod/assign/locallib.php:4408
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Many thanks for your effort, the whole Moodle Community will be enjoying your great solutions starting now!

        Closing, ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Many thanks for your effort, the whole Moodle Community will be enjoying your great solutions starting now! Closing, ciao

          People

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

            Dates

            • Created:
              Updated:
              Resolved: