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

Assignment file submission: when removing a submission, numfiles in mdl_assignsubmission_file should be reset to 0

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Waiting for integration review
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.7, 3.8
    • Fix Version/s: None
    • Component/s: Assignment
    • Labels:
    • Testing Instructions:
      Hide

      To see this issue fixed:

      1. Set up a clean moodle instance with a test course and enrol a user.
      2. Create an assignment with 'file' as a submission type, and allow re-attempts.
      3. As the user, submit a file to the assignment. You should see numfiles change to 1 in the mdl_assign_submission table.
      4. Log in as the user and click 'remove submission'. You should now see numfiles change to 0 in the mdl_assign_submission table, since the number of files has been recounted with this change.
      Show
      To see this issue fixed: Set up a clean moodle instance with a test course and enrol a user. Create an assignment with 'file' as a submission type, and allow re-attempts. As the user, submit a file to the assignment. You should see numfiles change to 1 in the mdl_assign_submission table. Log in as the user and click 'remove submission'. You should now see numfiles change to 0 in the mdl_assign_submission table, since the number of files has been recounted with this change.
    • Affected Branches:
      MOODLE_37_STABLE, MOODLE_38_STABLE
    • Pull 3.7 Branch:
      MDL-65886-MOODLE-37
    • Pull Master Branch:
      MDL-65886-MOODLE-master

      Description

      When removing a submission, the remove() function is called in our file submission plugin in mod/assign/submission/file/locallib.php. (https://github.com/moodle/moodle/blob/master/mod/assign/submission/file/locallib.php#L316)

      This remove() function does not change the numfiles field in the mdl_assignsubmission_file table. When we remove a submission, we delete the files, but the numfiles field here stays at 1, and is never reset back to 0.

       

      To see this issue:

      1. Set up a clean moodle 37 with a test course and enrol a user.
      2. Create an assignment with 'file' as a submission type, and allow re-attempts.
      3. As the user, submit a file to the assignment. We now see the state shown in assignment_file_submitted.png and submitted_test_assignment.png
      4. As the user, click 'remove submission'. The file is removed and we see in the UI removed_submission.png, which shows our file is removed. But in the database, we still have numfiles=1, the same state as shown in assignment_file_submitted.png.

      Have noticed this because some plugins look for a numfiles = 1 here to do other submission related tasks, and if the submission is removed but this numfiles stays at 1, we get errors. If we remove a submission and its files, shouldn't the numfiles field should reset to 0 too?

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 55 minutes
                55m