weekly release 5.0dev
[moodle.git] / grade / export / txt / index.php
blob3c75d95827b4e0c79844963702fa7b7b4bfc767a
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_txt.php';
22 $id = required_param('id', PARAM_INT); // course id
24 $PAGE->set_url('/grade/export/txt/index.php', array('id'=>$id));
26 if (!$course = $DB->get_record('course', array('id'=>$id))) {
27 throw new \moodle_exception('invalidcourseid');
30 require_login($course);
31 $context = context_course::instance($id);
33 require_capability('moodle/grade:export', $context);
34 require_capability('gradeexport/txt:view', $context);
36 $actionbar = new \core_grades\output\export_action_bar($context, null, 'txt');
37 print_grade_page_head($COURSE->id, 'export', 'txt',
38 get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_txt'),
39 false, false, true, null, null, null, $actionbar);
40 export_verify_grades($COURSE->id);
42 if (!empty($CFG->gradepublishing)) {
43 $CFG->gradepublishing = has_capability('gradeexport/txt:publish', $context);
46 $actionurl = new moodle_url('/grade/export/txt/export.php');
47 $formoptions = array(
48 'includeseparator'=>true,
49 'publishing' => true,
50 'simpleui' => true,
51 'multipledisplaytypes' => true
54 $mform = new grade_export_form($actionurl, $formoptions);
56 $groupmode = groups_get_course_groupmode($course); // Groups are being used.
57 $currentgroup = groups_get_course_group($course, true);
58 if (($groupmode == SEPARATEGROUPS) &&
59 (!$currentgroup) &&
60 (!has_capability('moodle/site:accessallgroups', $context))) {
62 echo $OUTPUT->heading(get_string("notingroup"));
63 echo $OUTPUT->footer();
64 die;
67 groups_print_course_menu($course, 'index.php?id='.$id);
68 echo '<div class="clearer"></div>';
70 $mform->display();
72 echo $OUTPUT->footer();