unikent / moodle-local_recyclebin Goto Github PK
View Code? Open in Web Editor NEWRecycle bin for Kent Moodles
License: GNU General Public License v2.0
Recycle bin for Kent Moodles
License: GNU General Public License v2.0
When the course cleanup task runs it creates a \local_recyclebin\course and then calls delete_item().
In delete item it creates an event and creates a context_course object. But if a course is deleted, the task will crash and fail.
Here is what we are getting from our command line:
Scheduled task: Clean recycle bin
[RecycleBin] Deleting item 3212...
... used 4 dbqueries
... used 0.015912055969238 seconds
Task failed: Can not find data record in database table course.
Can you put a conditional on the event creation to check if the course exists before firing the event?
The recycle bin icon does not show up unless something has been deleted, which means most instructors will not know this plugin exists.
The code at https://github.com/unikent/moodle-local_recyclebin/blob/master/lib.php#L38 checks for
// Only add this settings item on non-site course pages.
if (!$PAGE->course or $PAGE->course->id == 1) {
Instead of hard-coded 1, the core constant SITEID
should be used as there are valid cases where the site course has different id.
Hi Skylar,
I already wrote this on https://moodle.org/plugins/view/local_recyclebin before I realized that you have a Github issue tracker for this plugin. Sorry for the double post.
I think you could improve the necessary core hack by a) throwing a general event in course_delete_module() and catching this event within your plugin instead of notifying your module directly b) creating an issue on tracker.moodle.org to include throwing this event into Moodle core.
How do you think about that?
Thanks,
Alex
Hi,
I've got a new issue. Directly when updating your plugin, we get those messages:
Warning: in_array() expects parameter 2 to be array, integer given in /var/www/html/moodle_dev/lib/adminlib.php on line 3192
Warning: in_array() expects parameter 2 to be array, integer given in /var/www/html/moodle_dev/lib/adminlib.php on line 3197
Furthermore, comparing your code to the gui, in the code are chechboxes impelemented (enablecourse and enablecategory) that are not displayed in our system (assuming due to this message):
Cheers,
Kathrin
Replace the recyclebin functionality of the category manager with a similar backup/restore system to activities but for entire courses.
https://github.com/unikent/moodle-tool_cat
https://github.com/unikent/moodle-local_catman
Due to changes to language strings, some behat tests are failing. Specifically:
String change:
9bddbf5
Should be reflected here:
String change:
24b14d4#diff-28eeec1136e816b24e581f509a719aefR66
Should be reflected here:
This string should say "Save and continue":
I are running the latest master on our TEST server and updated our plugins. But when I viewed the scheduled tasks I see this error:
Failed to load task: \local_recyclebin\task\clean_recyclebin
line 255 of /lib/classes/task/manager.php: call to debugging()
line 377 of /lib/classes/task/manager.php: call to core\task\manager::scheduled_task_from_record()
line 121 of /admin/tool/task/scheduledtasks.php: call to core\task\manager::get_all_scheduled_tasks()
It seems that the splitting of the tasks (deb545c) didn't clean up the old task. Is that a core Moodle issue? I am running Moodle 2.7.10.
Hi,
we're using your plugin and like it very much. Now that you've released a new version, I had a look at the changes and saw that there were some changes to the capabilities.
The capability to empty a recycle bin is gone and I'm wondering what the reasons were for you to changing this?
For my understanding, the possibility to be able to empty a recycle bin should not be withdrawn. So I just wanted to know what your reasons are.
Cheers,
Kathrin
[vagrant@localhost moodle]$ php admin/tool/task/cli/schedule_task.php --execute=\local_recyclebin\task\clean_recyclebin
Scheduled task: Clean recycle bin
[RecycleBin] Deleting item 1...
Stacktrace:
Notice: Undefined property: stdClass::$course in /vagrant/moodle/local/recyclebin/classes/task/clean_recyclebin.php on line 58
Call Stack:
0.0003 261592 1. {main}() /vagrant/moodle/admin/tool/task/cli/schedule_task.php:0
0.5692 17385688 2. local_recyclebin\task\clean_recyclebin->execute() /vagrant/moodle/admin/tool/task/cli/schedule_task.php:131
The problem is that following query only returns ID:
$items = $DB->get_recordset_select('local_recyclebin', 'deleted < ?', array($deletefrom), '', 'id');
It should get the full record.
Maybe we should move the category recycle bin out to another plugin to reduce the code complexity..
Regardless of which item you delete in the recycling bin the last item will always be deleted. E.g. if there are 5 items in the bin, and you delete the second item, the bottom gets deleted.
After investigation I think that this is due to a javascript bug. We have found the error in version 1.4 of your plugin, but, as we are upgrading to Moodle 3, I have also downloaded your version 3 plugin and, after looking at the javascript, I can see that the bug hasn't been fixed.
File: module.js
Lines 27 to 38.
The intention is to present a confirmation button to the user and then, assuming a positive confirmation, redirect them back to the index page with the correct parameters for which item to delete in the ULR.
I think the following is happening (I may be wrong??) Unfortunately the url that is being passed to window.location is a combination of ALL href's for all of the links that contain the class of recycle-bin-delete. var = urldelete = this.get('href'); will get all hrefs from this, where, in your code, 'this' is the whole Y space and not the actual link that was clicked. I think changing this.get('href'); to e.get('href') may fix it, but I personally would actually add an extra attribute to the link, e.g. called resourceid and get that from the clicked object rather than rely on the href attribute.
If you add an alert(urldelete); after the variable is initialized then you will see that the variable contains all of the url's from all of the X links (those with the class recycle-bin-delete) concatenated together.
Anyway, at present, the delete functionality of the plugin is unusable.
Mark
Hi,
I like your recycle bin plugin for Moodle 2.9 a lot.
I translated the English language strings in AMOS (https://lang.moodle.org/) for the Mexican Spanish language pack and it works beautifully ...
... except that the name itself of the plugin appears in English inside the Administration block and in a few other places. Plese see the attached screen dump and notice correctly translated language strings inside most green rectangles and original hard-wired English text (Recycle bin) inside the upmost rectangle.
I already purged the text language caches.
BTW; I hope you don't mind that I did a Moodle Docs page for this plugin at https://docs.moodle.org/all/es/local/Recycle_bin, so that the documentation for installing this plugin can be very easily translated into several languages (spanish language to be soon).
On our system we do not allow instructors to backup user data by not allowing the 'moodle/backup:userinfo' capability for their role. We do this to protect user data.
However, a common use case that we want the recycle bin to solve is being able to restore a quiz or assignment that has student submissions if they are accidently deleted.
We cannot figure out a clean way to make this plugin include user data even if they normally cannot do it in the Moodle backup procedure. Got any ideas of how to accomplish that?
This should ask the user if they are sure they want to delete all items forever, to be similar to other software that use a recycle bin feature
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.