MDL-47761 enrol: Show more detail for self-enrolment errors
[moodle.git] / grade / export / xls / export.php
blob4cbe5bbe55f9c5e30cce8222dedab08cc2759594
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 require_once '../../../config.php';
19 require_once $CFG->dirroot.'/grade/export/lib.php';
20 require_once 'grade_export_xls.php';
22 $id = required_param('id', PARAM_INT); // course id
23 $groupid = optional_param('groupid', 0, PARAM_INT);
24 $itemids = required_param('itemids', PARAM_RAW);
25 $export_feedback = optional_param('export_feedback', 0, PARAM_BOOL);
26 $updatedgradesonly = optional_param('updatedgradesonly', false, PARAM_BOOL);
27 $displaytype = optional_param('displaytype', $CFG->grade_export_displaytype, PARAM_INT);
28 $decimalpoints = optional_param('decimalpoints', $CFG->grade_export_decimalpoints, PARAM_INT);
29 $onlyactive = optional_param('export_onlyactive', 0, PARAM_BOOL);
31 if (!$course = $DB->get_record('course', array('id'=>$id))) {
32 print_error('nocourseid');
35 require_login($course);
36 $context = context_course::instance($id);
38 require_capability('moodle/grade:export', $context);
39 require_capability('gradeexport/xls:view', $context);
41 if (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
42 if (!groups_is_member($groupid, $USER->id)) {
43 print_error('cannotaccessgroup', 'grades');
47 // print all the exported data here
48 $export = new grade_export_xls($course, $groupid, $itemids, $export_feedback, $updatedgradesonly, $displaytype, $decimalpoints, $onlyactive, true);
49 $export->print_grades();