Uploaded image for project: '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
    • Status: Closed
    • Priority: 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:

      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.

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  12/Mar/12