Reputation: 35
I help maintaining a moodle enviroment (version 1.9.7) and every semester we need to perform a default reset to all courses but there are nearly five hundred courses each with a forum and two to four quizzes and doing this is extremely tedious and takes a very long time.
I have been looking everywhere for way to perform a Mass/Bulk Course Reset but nothing worked so far. For example this code:
Ok, I figued it out, but be very carful. If you do not know what you are doing do not use this code, you could do a lot of damage to your DB. This does the "default" course reset to all course ids in the array.
<?php require('../config.php'); require_once('reset_form.php'); $courseids = array(8,9,11); foreach ($courseids as &$value) { $data->MAX_FILE_SIZE = 8097152; $data->reset_start_date = 1251781200; $data->reset_events = 1; $data->reset_logs = 1; $data->reset_notes = 1; $data->reset_roles = Array(5); $data->mform_showadvanced_last = 0; $data->reset_roles_local = 1; $data->reset_gradebook_grades = 1; $data->reset_assignment_submissions = 1; $data->reset_forum_all = 1; $data->id = $value; $status = reset_course_userdata($data); } ?>
Does anyone know which SQL instrucions are used when performing a Default Reset? I'd really appreciate any help.
Upvotes: 1
Views: 633
Reputation: 10241
It will be very difficult to do a reset with just SQL I'm afraid. The reset code calls functions in each of the modules too, so they can do their own thing.
It looks like you are on the right track to reset in bulk though.
I would recommend upgrading though. Moodle 1.9.7 is very old now and unsupported. The upgrade route is:
Obviously make a back up and test on a development server first.
Upvotes: 1