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

Assignment restore fails with deleted group

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      • Create a course
      • Create a group
      • Enrol 2 students in the course, 1 in the group, 1 not in the group
      • Create an assignment, with group submission on, but do not require users to be a member of a group to submit
      • Log in as each of the students and submit something for the assignment
      • Log back in as admin and delete the group
      • Backup + restore the course

      Check:

      • Course restores without any errors
      Show
      Create a course Create a group Enrol 2 students in the course, 1 in the group, 1 not in the group Create an assignment, with group submission on, but do not require users to be a member of a group to submit Log in as each of the students and submit something for the assignment Log back in as admin and delete the group Backup + restore the course Check: Course restores without any errors
    • Affected Branches:
      MOODLE_35_STABLE, MOODLE_36_STABLE
    • Fixed Branches:
      MOODLE_35_STABLE
    • Pull 3.5 Branch:
      MDL-63798_assign_restore_groups_35
    • Pull Master Branch:
      MDL-63798_assign_restore_groups

      Description

      Steps to reproduce:

      • Create a course
      • Create a group
      • Enrol 2 users in the course, 1 in the group, 1 not in the group
      • Create an assignment, with group submission on, but do not require users to be a member of a group to submit
      • Log in as each of the users and submit something for the assignment
      • Log back in as admin and delete the group
      • Backup + restore the course

      Expected result:

      • Backup restores successfully

      Actual result:

      • Error: "ERROR: duplicate key value violates unique constraint "mdl_assisubm_assusegroatt_uix"
        DETAIL: Key (assignment, userid, groupid, attemptnumber)=(2, 0, 0, 0) already exists.
        INSERT INTO mdl_assign_submission (userid,timecreated,timemodified,status,groupid,attemptnumber,latest,assignment) VALUES($1,$2,$3,$4,$5,$6,$7,$8) RETURNING id
        [array (
        'userid' => '0',
        'timecreated' => '1540804290',
        'timemodified' => '1540804297',
        'status' => 'submitted',
        'groupid' => 0,
        'attemptnumber' => '0',
        'latest' => 0,
        'assignment' => 2,
        )]
        Error code: dmlwriteexception"

      Reason: during restore, mod_assign maps any groupids it can't find onto 0 (no group), but there is already a no group submission in the same backup, so this causes the unique key violation.

      Suggested fix: skip restore of any assign submissions where the groupid is set but the group does not exist in the backup (as those submissions cannot be viewed anyway).

        Attachments

          Activity

            People

            Assignee:
            davosmith Davo Smith
            Reporter:
            davosmith Davo Smith
            Peer reviewer:
            Damyon Wiese
            Integrator:
            Eloy Lafuente (stronk7)
            Tester:
            Anna Carissa Sadia
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              14/Jan/19

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 30 minutes
                30m