-
New Feature
-
Resolution: Fixed
-
Minor
-
2.8.1, 3.1
-
MOODLE_28_STABLE, MOODLE_31_STABLE
-
MOODLE_31_STABLE
-
MDL-48012_master -
-
If you delete an activity or resource in error there is no way for a course editor to undo / recover the item.
Currently the only way to recover items is from either course or database backups. Even then restoring grades back into a live course from a restored (outdated) copy is not always possible.
The addition of a “recycle bin” would remedy this. This could be achieved by:
- Adding a deleted field to the course_modules table (course_modules.deleted) with a default value of 0 (not deleted and visible on the course)
- When an item is deleted this field is set with the current timestamp indicating it has been “deleted”
- Extend the course_delete_module function. When the function is first called, it checks if the deleted flag in course_modules is 0, if so then set course_modules.deleted = timenow. When the function is called again, if the flag is > 0 then the rest of the function will continue as normal, without interfering with the existing the processes
- Modify get_course_mods (lib\datalib.php) to exclude deleted items from rendering in the page (and test \ find other areas where the course modules are queried directly)
- Add a link to “recycle bin” in the course administration block
- Add a site admin setting “recycle_bin_retention (or similar) which would accept a value in days
- Add a routine to cron to call delete functions for all items where (timenow – timestamp) > retention period
- Other processes still to be investigated:
- Gradebook
- Access Restrictions
- Activity Completion
- Course Completion
User Interface:
- Users could delete activities / resources from a course as they do now
- Users could click a link in the course administration block to go to “recycle bin”
- The recycle bin would state “items recoverable for x days” at the top of the page (taken from admin setting)
- Recycle bin would list all recoverable items with:
- activity / resource title (name)
- date deleted from course (course_modules.deleted timestamp)
- date to clear down (timestamp + retention period)
- button to permanently delete
- button to restore to course
Once items reached their expiry date they would automatically be cleared down by a cron process and removed from the list of recoverable items.
We do not believe there would be any impact on course backup / restore beyond capturing the new course_modules.timestap database field as this code would not be checking the field. Thus any courses backed up / restored should do so with files in the recycle bin / “deleted” status.
We do not believe we need additional capabilities beyond course:manageactivites particularly as there are no existing capabilities relating specifically to deletion of activites / resources.
However it may make sense to add a capability for course:recycledelete (or similar) which would control the ability to permanently delete from the recycle bin interface leaving that part of the process to cron.
Navigation:
Hide all navigation links from all roles in:
- Course Page
- Navigation Block (which expands to show individual links to activities / resources)
- My Home
- Course Completion Block
- Activities Block
- Gradebook (see below)
Activity Completion
There should be no issue with completion tracking as defined in the given resource as these settings are encapsulated within the specific activity / resource
Restrict Access Rules
Currently if you delete an activity on which another activity has an access rule set, the other activity shows "(missing)" in the text of the course page.
If instead of deleting files we set a status for "recycle" then instead of showing "missing" they will show the activity which will still be in the database.
Resolution of that issue is not only one of concern for any "recycle bin" feature but a wider issue with managing access restrictions. For example if you hide an activity on which another access rule depends there is no warning to indicate students will never be able to access that resource (as the one on which the access rule depends is hidden).
Thus, for the purpose of this specific feature request It maybe better to ignore / accept this issue until such time as it is addressed in the wider process for managing resources. For example, if there were routines to update the (json?) in course_modules.availability fired on the existing delete method we could call those same routines when sending files to "recycle bin".
Course Completion
Course Completion builds a dependency on Activity Completion which could cause issues. Currently it seems if you hide a resource students are still required to complete the activity and can still access the hidden resource via the Course Completion Block?
If hiding the resource were sufficient to remove it from Course Completion tracking then any "recycle" process could simply hide the resource at the same time it is flagged as being "deleted".
Again I would suggest these issues are not addressed as part of a "recycle" feature but looked at in a separate tracker if required.
Gradebook
- When activities are "deleted" / restored corresponding entries must be made visible / invisible in gradebook (to all roles)
- We must be able to restore all grades / feedback intact
- Items in recycle bin must not continue to influence grade aggregation / category weighting
We may need to accept that category weightings can not be recovered. One reason for this is that we do not know what other changes have been made to category weightings between delete and restore, i.e. the course may have changed between those two points and the original category weightings are no longer valid.
Considering User Behavior
Currently a lot of users choose to "hide" resources for a while before deleting them. The presence of a "recycle bin" may encourage users to delete more and hide less which could present a problem if there are limitations on the restore process, losing grade aggregation for example. At a minimum we would need to make any limitations known during the restore process. We could also consider altering messages on delete / recycle.
Related forum discussion: https://moodle.org/mod/forum/discuss.php?d=274203
- caused a regression
-
MDL-54751 Recycle Bin - deleting large complex objects forces user to wait
- Closed
-
MDL-54072 Recycle bin test should avoid reliance on hardcoded course_modules counts
- Closed
- has a non-specific relationship to
-
MDL-4782 allow resources/activities to be hidden but available/active
- Closed
-
MDL-79013 migrate pre_course_delete callback to hook
- Open
- has a QA test
-
MDLQA-9242 A teacher can restore a deleted activity from recycle bin
- Open
-
MDLQA-9243 Manager can restore a deleted course from recycle bin
- Open
-
MDLQA-15265 CLONE - A teacher can restore a deleted activity from recycle bin
- Passed
-
MDLQA-15854 CLONE - A teacher can restore a deleted activity from recycle bin
- Passed
-
MDLQA-16500 CLONE - A teacher can restore a deleted activity from recycle bin
- Passed
- is blocked by
-
MDL-53216 Create new recycle bin icon
- Closed
- is duplicated by
-
MDL-37139 Recycling of deleted course content and student data
- Closed
-
MDL-49102 Create a 'Recycle Bin' for course modules
- Closed
- will be (partly) resolved by
-
MDL-44078 Proposal: API standard in Moodle that uses autoloading (hooks)
- Closed
- will help resolve
-
MDL-37139 Recycling of deleted course content and student data
- Closed