Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Why couln't you identify the appropriate course_delete() course API function (highest call level), say, digging the course management API, put it in a variable, whatever it is called, and then run a loop as
include_once("../config.php");
$coursedeletefunction = '...'; // what is the right top level call
$courses = get_records('course');
foreach($courses as $acourse){
$coursedeletefunction($acourse->id);
}
assuming this is located in a mypowerscripts directory at Moodle install root.
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
In addition, and taking a step back my previous answer...
it is a real good idea to identify, in each major entity API (groups, courses, modules, users, servers, etc...) the end_user "use cases" branch point (usually should be a function call, in most cases). In a (so) nicely designed application such as Moodle, many use cases do have their entry in the whole Moodle API. I tried to setup a student project on the theme : why not designing an administration macro language, as simple as an ultra BASIC SCRIPTING for Moodle, that sits on those high level API function, and should allow many power moves with a really simple syntax (and with the gain of having a consistent and homogeneous semantical layer of this primitive set). I came too late this year, and there are no student available for projects (they are all engaged).
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
I've attached the category.php page, it should be all you need. If you use it then backup the same file on your system first because the file I have uploaded is taken from the 1.9 beta version of moodle from mid august so there may be differences with your version.
For reference the relevant code is between line 149 and 173 for deleting the submitted courses, and line 460 to 463 to create the delete button itself.
If you want to add a 'select all' button so you don't have to click each individual button examples of these can be found on the web. They literally loop through each form item and check or uncheck them.
I hope this helps
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
I will try it
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Only suggestion would be a count on first page, for example,
"Are you absolutely sure you want to completely delete the following 323 courses"
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Hi, Greg,
Why not post a featuure request to http://tracker.moodle.org/? If enough Moodlers vote for it, maybe this feature will show up soon.
Couldn't hurt to ask, right?
Regards,
Art
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Actually, I am wrong. It doesn't seem to be there, but it does not hurt to reinforce the message that before you create a new issue in the tracker, it is good if you can search first to make sure it is not already there.
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
I have found with this script that about 1000 courses at a time is the most it can do before the script times out. At lease thats what I found on our test box. I think the php max_execution_time is 300 seconds. I could have bumped up the time but I just split the file into a few parts and it went fine.
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
require_once($CFG->libdir.'/uploadlib.php');
it still throws some errors, but seems to work.
Thanks for the script, BTW, it's going to be a lifesaver!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Have you posted the files and instructions yet? I think we tried the one for version 1.8 and since we were not able to access it from the web page we removed it. We are wanting to find some solution for deleting courses in bulk.
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Also, thanks to the folks who originally developed both scripts! I hope that this functionality gets put into the core someday.
Michael, you indicate that someone gave you a code snippet, but there is nothing in the forum which appears to be a response to you post.
Additionally it is confusing as to whether you were using the initial code that Jeff posted or the code that Chad posted here:
http://moodle.org/mod/forum/discuss.php?d=96736
So as to clarify the situation, could you post which code you used, which posting you relied on vis-a-vis patching, and the nature of your results?
Anthony, could you perhaps ask Chad/Jeff about an M&P entry for the deletion tool Chad posted at the URL above? As I understand it, he used the tool initially posted by Jeff CHurch and then made some alterations to get it working under 1.9 - not sure of whether the 1.9 version works for any earlier version and maybe Chad and Jeff could comment?
I had asked Anthony to check on this and I think with him on the run the last month this must have gotten lost as I didn't see his response until just now.
Going back through the discussion it appears that Chad posted a working enhancement to the work that Jeff Church's people did (thanks to all who contributed) and that Chad posted the zip here.
http://moodle.org/mod/forum/discuss.php?d=96736
We need a new M&P page for this tool and I don't know if Chad intends to maintain it.
Anthony, can you address this? Maybe the bulk course add and delete tools should be bundled as I think Jeff first envisioned it?
Marc
This forum post has been removed
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
There are so many people asking about this would you consider pursuing a M&P page or trying to assume responsibility for Rory's page if you haven't done so already?
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
This also works in concert with our simplified restore tool, which searches for archives based on username (or other field) and allows instructors to restore these otherwise non-accessible courses.
We do this so instructors do not have the ability to download course archives onto unprotected computers.
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Are you interested in having this in M&P and serving as the maintainer?
See http://tracker.moodle.org/browse/CONTRIB-605
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
We would gladly support our system (we have to for our university anyway). Let me know if this is acceptable and I will send you the code.
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Our courses are organized by department (category) and tied to a specific semester. So at the end of each semester we backup and delete these courses. We allow restore access via a separate tool that searches the Backup and Delete backup directory for courses that the user has a right to access.
Example: we need to backup and delete all Spring Intersession courses, so we do a search for 2008SpringInt (following our shortname conventions) and schedule a backup. After the backup is completed via cron, we get an email and now the tool will allow us to delete the courses. The system updates the screen as deletes are completed using mtrace.
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
If you have a list of courses listed with shortname, fullname, description, idnumber, instructor then you can write a regex to convert it to xml for use in the included Moodle IMS enrollment system.
The best part about IMS is that it can run during cron, so you can just replace the xml file when you have new courses to add and it will automatically pick it up on the next cron run.
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
<recstatus>3</recstatus>
or like this:
<group recstatus="3">
Ditto for <person>.
I couldn't get either to work for <person> or for <group>, and neither could I get updates to work with recstatus "2" ! On the other hand I was able to get both updates and deletes for <membership> (enrollment).
This is in Moodle 1.9 with the built-in IMS Enterprise plugin. I enabled the "Delete user accounts when specified in IMS data" option in the IMS configuration page. BTW, we use LDAP for authentication, and the external DB plugin for enrollments. Our interest in IMS was for batch operations because we have other integration projects that are IMS compliant.
All help MUCH appreciated!
Alan
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
It has been quite a while since I posted the reply to your note, but we are returning to the IMS option and I am wondering if you might revisit this briefly.
What is the correct XML for deleting a student. I have tried
...
<person>
<recstatus>3</recstatus>
...
and even
<recstatus=3 />
but neither has any effect on the account.
I am using Moodle 1.9.4 and whatever IMS plugin is part of that build. That is, I did not install any special "mint" IMS Enterprise plugin.
Thanks for any advise you might have.
Alan
PS/ I am attaching a sample XML file in the hope you can give it a quick look.
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
We also ended up rewriting the IMS enterprise plugin to better suit our needs. Unfortunately, I doubt anyone else will find our IMS mods useful and we're about to ditch it for another enrollment solution called our Course Preferences System.
I will gladly email you with the latest zip of our backadel block if you would like to use it. Please send me an email as you seem to be hiding your email address from other users.
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
Just in case you ever need to know this, I finally figured out how to delete users via IMS-- not sure why I didn't think of trying it earlier:
Alan
Re: Is there a way to bulk delete courses. I have 77 to delete one at a time!
/* Removed to not require login
require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
if (!$site = get_site()) {
redirect("index.php");
}
*/
if (!empty($CFG->cronremotepassword)) {
$pass = optional_param('password', '', PARAM_RAW);
if($pass != $CFG->cronremotepassword) {
// wrong password.
print_error('cronerrorpassword', 'admin');
exit;
}
}
/// get language strings
I have tried using the bulk delete function.
I upload the course file one shortname per line but when it goes to the preview page no courses are listed.
And consequently nothing is deleted.
Any ideas appreciated?