Moodle
  1. Moodle
  2. MDL-31407

Quiz grades are not saved properly when the submitter is not the user taking the quiz.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.1.4, 2.2.1, 2.3
    • Fix Version/s: 2.1.5, 2.2.2
    • Component/s: Quiz
    • Labels:
      None
    • Testing Instructions:
      Hide

      The main thing is to test there are no regressions.

      1. Create a quiz that allows two attempts.
      2. Preview it as teacher. Verify that there are no errors, particularly when doing submit all and finish.
      3. Attempt the quiz as a student. Verify that there are no errors, particularly when doing submit all and finish. Then verify that the grade is displayed correct on the quiz view.php page and in the gradebook.
      4. Now make a second attempt as a student getting a different (higher) grade. Verify that the grade is updated on view.php and in the gradebook.

      5. If you really want to test this thoroughly, Create a script that submits open quiz attempts belonging to someone other than the logged in user, and then make sure that it works. However, I really don't think that is necessary.

      Show
      The main thing is to test there are no regressions. 1. Create a quiz that allows two attempts. 2. Preview it as teacher. Verify that there are no errors, particularly when doing submit all and finish. 3. Attempt the quiz as a student. Verify that there are no errors, particularly when doing submit all and finish. Then verify that the grade is displayed correct on the quiz view.php page and in the gradebook. 4. Now make a second attempt as a student getting a different (higher) grade. Verify that the grade is updated on view.php and in the gradebook. 5. If you really want to test this thoroughly, Create a script that submits open quiz attempts belonging to someone other than the logged in user, and then make sure that it works. However, I really don't think that is necessary.
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      37929

      Description

      Currently, the finish_attempt() function updates the quiz grade for the currently logged in user ($USER) no matter whose quiz attempt is being finished. The cause is the following line:

      quiz_save_best_grade($this->get_quiz());

      As a result, the finished attempt grade is never pushed to the gradebook. It would make more sense for finish_attempt() to update the grade for the user whose quiz attempt is being closed, a la:

      quiz_save_best_grade($this->get_quiz(), $this->attempt->userid);

      As far as I know, this does't currently cause issues in the Moodle core code, because Quiz attempts are always submitted by the owning user. Plugins which use question_usage_by_activity are affected; and this will likely cause issues with MDL-3030, when that comes to fruition.

      1. mdl_31407_typofixed.patch
        0.6 kB
        Kyle Temkin
      2. mdl_31407_typofixed.patch
        0.6 kB
        Kyle Temkin
      3. mdl_31407.patch
        0.6 kB
        Kyle Temkin

        Activity

        Kyle Temkin created issue -
        Kyle Temkin made changes -
        Field Original Value New Value
        Pull Master Diff URL https://github.com/ktemkin/moodle/commit/5895011c4dc74d5dcf5db4bda3844e8e09544159
        Pull Master Branch https://github.com/ktemkin/moodle/tree/MDL-31407
        Pull 2.0 Branch https://github.com/ktemkin/moodle/commit/5895011c4dc74d5dcf5db4bda3844e8e09544159
        Priority Minor [ 4 ] Trivial [ 5 ]
        Attachment mdl_31407.patch [ 26495 ]
        Difficulty Easy [ 10023 ]
        Kyle Temkin made changes -
        Attachment mdl_31407_typofixed.patch [ 26496 ]
        Kyle Temkin made changes -
        Attachment mdl_31407_typofixed.patch [ 26497 ]
        Kyle Temkin made changes -
        Tim Hunt made changes -
        Status Open [ 1 ] Peer review in progress [ 10013 ]
        Peer reviewer timhunt
        Tim Hunt made changes -
        Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
        Tim Hunt made changes -
        Status Development in progress [ 3 ] Waiting for integration review [ 10010 ]
        Pull Master Diff URL https://github.com/ktemkin/moodle/compare/master...MDL-31407 https://github.com/timhunt/moodle/compare/master...MDL-31407
        Pull Master Branch https://github.com/ktemkin/moodle/tree/MDL-31407 MDL-31407
        Pull from Repository git://github.com/timhunt/moodle.git
        Pull 2.0 Branch https://github.com/ktemkin/moodle/commit/5895011c4dc74d5dcf5db4bda3844e8e09544159
        Fix Version/s 2.1.5 [ 11553 ]
        Fix Version/s 2.2.2 [ 11552 ]
        Fix Version/s 2.3 [ 10657 ]
        Testing Instructions The main thing is to test there are no regressions.

        1. Create a quiz that allows two attempts.
        2. Preview it as teacher. Verify that there are no errors, particularly when doing submit all and finish.
        3. Attempt the quiz as a student. Verify that there are no errors, particularly when doing submit all and finish. Then verify that the grade is displayed correct on the quiz view.php page and in the gradebook.
        4. Now make a second attempt as a student getting a different (higher) grade. Verify that the grade is updated on view.php and in the gradebook.

        5. If you really want to test this thoroughly, Create a script that submits open quiz attempts belonging to someone other than the logged in user, and then make sure that it works. However, I really don't think that is necessary.
        Pull 2.1 Branch MDL-31407_21
        Pull 2.2 Diff URL https://github.com/timhunt/moodle/compare/MOODLE_22_STABLE...MDL-31407_22
        Pull 2.1 Diff URL https://github.com/timhunt/moodle/compare/MOODLE_21_STABLE...MDL-31407_21
        Pull 2.2 Branch MDL-31407_22
        Eloy Lafuente (stronk7) made changes -
        Currently in integration Yes [ 10041 ]
        Aparup Banerjee made changes -
        Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
        Integrator nebgor
        Eloy Lafuente (stronk7) made changes -
        Status Integration review in progress [ 10004 ] Waiting for integration review [ 10010 ]
        Eloy Lafuente (stronk7) made changes -
        Currently in integration Yes [ 10041 ]
        Eloy Lafuente (stronk7) made changes -
        Currently in integration Yes [ 10041 ]
        Aparup Banerjee made changes -
        Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
        Aparup Banerjee made changes -
        Status Integration review in progress [ 10004 ] Waiting for testing [ 10005 ]
        Affects Version/s 2.1.4 [ 11452 ]
        Affects Version/s 2.1 [ 10370 ]
        Fix Version/s 2.3 [ 10657 ]
        Ankit Agarwal made changes -
        Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
        Tester ankit_frenz
        Ankit Agarwal made changes -
        Status Testing in progress [ 10011 ] Tested [ 10006 ]
        Eloy Lafuente (stronk7) made changes -
        Status Tested [ 10006 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]
        Currently in integration Yes [ 10041 ]
        Integration date 13/Feb/12

          People

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

            Dates

            • Created:
              Updated:
              Resolved: