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

    • MOODLE_37_STABLE, MOODLE_38_STABLE
    • MOODLE_37_STABLE
    • MDL-65886-MOODLE-master
    • 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 assignsubmission_file table.
      4. Log in as the user and click 'remove submission'. You should now see numfiles change to 0 in the assignsubmission_file 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 assignsubmission_file table. Log in as the user and click 'remove submission'. You should now see numfiles change to 0 in the assignsubmission_file table, since the number of files has been recounted with this change.

      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?

        1. assignment_file_submitted.png
          16 kB
          Kristian Ringer
        2. image-2019-08-20-10-25-45-909.png
          125 kB
          Janelle Barcega
        3. removed_submission.png
          44 kB
          Kristian Ringer
        4. submitted_test_assignment.png
          49 kB
          Kristian Ringer

            kristianr Kristian Ringer
            kristianr Kristian Ringer
            Mihail Geshoski Mihail Geshoski
            Adrian Greeve Adrian Greeve
            Janelle Barcega Janelle Barcega
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 45 minutes
                1h 45m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.