. require_once '../../../config.php'; require_once $CFG->dirroot.'/grade/export/lib.php'; require_once 'grade_export_txt.php'; $id = required_param('id', PARAM_INT); // course id if (!$course = $DB->get_record('course', array('id'=>$id))) { print_error('nocourseid'); } require_login($course); $context = context_course::instance($id); $groupid = groups_get_course_group($course, true); require_capability('moodle/grade:export', $context); require_capability('gradeexport/txt:view', $context); if (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) { if (!groups_is_member($groupid, $USER->id)) { print_error('cannotaccessgroup', 'grades'); } } $params = array( 'includeseparator'=>true, 'publishing' => true, 'simpleui' => true, 'multipledisplaytypes' => true ); $mform = new grade_export_form(null, $params); $data = $mform->get_data(); // Print all the exported data here. $export = new grade_export_txt($course, $groupid, $data); $export->print_grades();