Safer delete for course modules (aka Recycle Bin)

Safer delete for course modules (aka Recycle Bin)

by Rex Lorenzo -
Number of replies: 6

We keep on running into issues every now and then about a user complaining that they deleted a file or course module and wants the data recovered.

The process often involves us taking a recent snapshot of the database, load it up another another server. If files are involved we rsync the file system to another server and "hope" that the deleted files aren't yet purged from the file cleanup cron.

Then we do a backup/restore of the single course module. This process is not always smooth and is such a hassle that involves hours of manual intervention.

What if we had a "deleted" flag in the course module data that acts like a super "visible" flag. So that the content doesn't show up for any user. Or we can overload the "visible" flag for a third state of "deleted"?

Then we have a weekly or so cron that will clean up course modules that are flagged as deleted if the flag was set at a certain time interval? Seems like a possible simple concept that would save people from shooting themselves in the foot.

We would have a report that can allow users to "undelete" deleted course modules.

This is a past discussion: Undelete or recycler for all deleted items?

It was also mentioned in the Perth Hackfest years ago, but nothing seemed to come out of it.

I hope to drum up interest and I wonder if my proposed approach is along the right way or not.

I created a tracker issue for this: https://tracker.moodle.org/browse/MDL-48012

Average of ratings: -
In reply to Rex Lorenzo

Re: Safer delete for course modules (aka Recycle Bin)

by Dan Poltawski -

Just to say +1 to the idea - the general principle of making actions reversible is a UX concept I feel we should be trying to apply more widely across Moodle.

Petr has commented on your issue concerned that this will be complex to implement - its unwise to take Petr's comments lightly ;) but i'm little a bit more optimistic about this. I've seen a lot of the course module handling improved and refactored into manageable pieces in recent releases - particularly with things like conditional availability causing change. Problem area I'd immediately think of is the gradebook..

In reply to Rex Lorenzo

Re: Safer delete for course modules (aka Recycle Bin)

by Jez H -

Hi Rex,

I hope you don't mind but I just took the liberty of rewriting your original ticket as we want to have a go at developing this. 

I did try and PM first you but you don't accept messages from strangers wink

I have attached a text file to this post with your original text in it should you need it.

In reply to Jez H

Re: Safer delete for course modules (aka Recycle Bin)

by Rex Lorenzo -

Jez, no need to save the original text. JIRA keeps the history. But glad that you are going to tackle on the task. I would think about adding another column in the table called "deleted" though. What about overriding the "visible" field?

There is another related task:

Allow resources/activities to be hidden but available/active

https://tracker.moodle.org/browse/MDL-4782

That I believe is going to be adding another status to that field. There might be some way to generalize both approaches. But your method described is more straight-forward.

Would like to help if I could with any Behat scripts that you want written to test it out.

In reply to Rex Lorenzo

Re: Safer delete for course modules (aka Recycle Bin)

by Jez H -

Hi Rex, 

The ticket says we would need to add a field "course_modules.deleted" which I think is what you originally advocated?

Our idea is to set that with 0 for false (not deleted) and timestamp for true (deleted) and use that same timestamp for the cron clear down.

I have already looked at MDL-4782 and am not sure the direction that is going in will be of any help. A recycle bin feature really needs to go further, we do not want "deleted" items appearing on "my home", in the navigation block, activities block etc which they will for course editors who have permissions to view hidden items.

I guess if we cannot resolve all these issues we could consider other ways to indicate the item is "in the bin" should it appear in other parts of the site.


In reply to Jez H

Re: Safer delete for course modules (aka Recycle Bin)

by Rex Lorenzo -

Yeah, your proposal sounds good and would like to see a proof of concept of editing the core APIs to take into account the new flag. Hopefully you can get a core developer's opinion if you can get that working.