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

Deleting uploaded files when deleting an assignment instance

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 1.6.1, 1.6.2, 1.7
    • Fix Version/s: 1.7, 1.8
    • Component/s: Assignment (2.2)
    • Labels:
      None
    • Affected Branches:
      MOODLE_16_STABLE, MOODLE_17_STABLE
    • Fixed Branches:
      MOODLE_17_STABLE, MOODLE_18_STABLE

      Description

      I think it would be a good idea to try to keep the systems as tidy as possible.
      I have realized that upon deleting an assignment instance the database records are efectively removed, but data files in moodledata moddata folder are left there. These files are no more accessible (the instance id is lost), I consider a good idea to delete those files.

      At our ULPG site I have added
      file mod/assignment/lib.php, function delete_instance()

      if (! delete_records('grade_item', 'modid', $cm->id, 'cminstance', $assignment->id))

      { $result = false; }

      }

      this part inserted

      // ecastro ULPGC : keep it tidy, delete uploaded files
      if ($result && $assignment->assignmenttype != 'offline')

      { require_once($CFG->libdir.'/filelib.php'); echo ($CFG->dataroot."/".$assignment->course."/".$CFG->moddata."/assignment/".$assignment->id); $res = fulldelete($CFG->dataroot."/".$assignment->course."/".$CFG->moddata."/assignment/".$assignment->id); }

      ^^^^^^^^^^^^^^^

      return $result;
      }

      Hope this can be useful

        Attachments

          Activity

            People

            • Assignee:
              skodak Petr Skoda
              Reporter:
              ecastro Enrique Castro
              Tester:
              Ken Wilson
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                7/Nov/06