tags:

views:

370

answers:

1

Moodle has a built in per course reset ability. I want to reset all my courses.

A: 

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);
}
?>