/** * This function is used by the reset_course_userdata function in moodlelib. * This function will remove all seplment submissions and feedbacks in the database * and clean up any related data. * * @param stdClass $data the data submitted from the reset course. * @return array */ function sepl_reset_userdata($data) { global $CFG, $DB; require_once $CFG->dirroot . '/mod/sepl/locallib.php'; $status = array(); $params = array('courseid' => $data->courseid); $sql = "SELECT a.id FROM {sepl} a WHERE a.course=:courseid"; $course = $DB->get_record('course', array('id' => $data->courseid), '*', MUST_EXIST); if ($sepls = $DB->get_records_sql($sql, $params)) { foreach ($sepls as $sepl) { $cm = get_coursemodule_from_instance('sepl', $sepl->id, $data->courseid, false, MUST_EXIST); $context = context_module::instance($cm->id); $seplment = new sepl($context, $cm, $course); $status = array_merge($status, $seplment->reset_userdata($data)); } } return $status; }