public function cleanup() {
        global $DB;
        $courseid = $this->controller->get_courseid();
        if ($this->is_temporary_course_created($courseid) && $course = $DB->get_record('course', array('id' => $courseid))) {
            $course->deletesource = 'restore';
            delete_course($course, false);
        }
    }