/** * Performs the reset of all teamwork instances in the course. * * @param stdClass $data The actual course reset settings. * @return array List of results, each being array[(string)component, (string)item, (string)error] */ function teamwork_reset_userdata(stdClass $data) { global $CFG, $DB; if (empty($data->reset_teamwork_submissions) and empty($data->reset_teamwork_assessments) and empty($data->reset_teamwork_phase)) { // Nothing to do here. return array(); } $teamworkrecords = $DB->get_records('teamwork', array('course' => $data->courseid)); if (empty($teamworkrecords)) { // What a boring course - no teamworks here! return array(); } require_once $CFG->dirroot . '/mod/teamwork/locallib.php'; $course = $DB->get_record('course', array('id' => $data->courseid), '*', MUST_EXIST); $status = array(); foreach ($teamworkrecords as $teamworkrecord) { $cm = get_coursemodule_from_instance('teamwork', $teamworkrecord->id, $course->id, false, MUST_EXIST); $teamwork = new teamwork($teamworkrecord, $cm, $course); $status = array_merge($status, $teamwork->reset_userdata($data)); } return $status; }