General developer forum

 
 
Picture of Tony Box
Creating a mass course restore feature to reset large batches of courses
 

After running into an issue with the mdl_question_state table in 1.9.3 (yeah I know... we are upgrading this Fall), I found the only safe way to purge all 10gigs of data in it is to do course resets. Unfortunately, we never had a policy in place to consistantly reset courses after each semester sad

I am sort of surprised that there isn't already a mass course-reset option available. I think it would be beneficial to all parties; administrators wouldn't have to worry about enforcing a course reset policy for each single person and users (instructors) wouldn't have to worry about remembering to reset their courses.

I've created a ticket in the tracker for this new feature that has other details in it, but I figured I'd also advertise and open discussion for it here.

http://tracker.moodle.org/browse/MDL-26936

My university is currently getting the go-ahead to allocate some resources towards building a tool for doing this but it will be somewhat crude, won't have a UI, and will only be designed to work with 1.9. The next step might be to make it more user friendly.

By the way, I found this bit of code that supposedly does what I'm looking for. I'm in the process of modifying it to pick out courses by itself (instead of manually inputting them). http://stackoverflow.com/questions/1061563/how-do-i-delete-course-enrolments-in-moodle-in-bulk

 
Average of ratings: -
Picture of Domingo Fernandez
Re: Creating a mass course restore feature to reset large batches of courses
 

Hello Tony.

I just finished an script to do what you propose. It doesn't have a G.I. You have to indicate which courses you want to delete, all if you want, and which roles. I haven't use it in production yet.

 

If you are interested I'll be happy to pass you the code.

 

 

 
Average of ratings: -
Picture of Emilio Rodriguez
Re: Creating a mass course restore feature to reset large batches of courses
 

Hello Domingo,  

I'm interested in a script to restore multiple courses at once.  
Can this be done with the script you refer?
Thanks in advance
Regards
Emilio

 
Average of ratings: -
Picture of Tomasz Muras
Re: Creating a mass course restore feature to reset large batches of courses
 
Average of ratings: -
Oam
Re: Creating a mass course restore feature to reset large batches of courses
Group Particularly helpful Moodlers

Hi,

We need the same and have developped the attached script. It displays the reset course form but you can choose which courses must be resetted (all, only specific courses or all excluded a list of specific courses).

However, you need to check the PHP server configuration (max_execution_time value) if you plan to reset a lot of courses.

2 ways to do this :
- in the php.ini file (max_execution_time = "300000")
- using php_value in a .htaccess file : php_value max_execution_time "300000"

Note : I tried with "0" and I get "PHP Fatal error:  Maximum execution time of 0 seconds exceeded" !

I used this script on my Moodle 2.5.1 production site with 1200 courses (database size : 4 Go). It took 5 hours to reset all courses (except few). It could happened that the page never stops loading. But the job is done. It could be a good idea to add an entry in the table log to be sure that all course are resetted.

I discover the Tomasz Muras' (command line) script. Maybe it is a best option for large batches of courses.

Pascal

 

 
Average of ratings:Useful (1)
Picture of Antonio Crespo
Re: Creating a mass course restore feature to reset large batches of courses
 

Hi Pascal,

 

Can you give me some light on how to run these scripts?

I put them in a folder I created inside moodle_dir and did chmod 0777, then went to the browser and tried to run, but i got Direct access to this script is forbidden.

Any help is greatly appreciated,

 
Average of ratings: -
Oam
Re: Creating a mass course restore feature to reset large batches of courses
Group Particularly helpful Moodlers

Hi !

You have to put these scripts in a folder like "restore_mass" in the local folder of moodle :

/moodle_dir/local/restore_mass/commit_reset_course.php
/moodle_dir/local/restore_mass/commit_reset_course_form.php

Then, you call the script in your browser :

http://yourmoodle.fr/local/restore_mass/commit_reset_course.php

Tell me if it works for you and if not, please tell me which version of Moodle you use ...

Pascal

 
Average of ratings: -