MDL-9628 Fixed sorting
[moodle-pu.git] / grade / export / xml / index.php
blob991ffc9c905b39a43edc9e662352e32ec1e697d1
1 <?php //$Id$
3 ///////////////////////////////////////////////////////////////////////////
4 // //
5 // NOTICE OF COPYRIGHT //
6 // //
7 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
8 // http://moodle.com //
9 // //
10 // Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
11 // //
12 // This program is free software; you can redistribute it and/or modify //
13 // it under the terms of the GNU General Public License as published by //
14 // the Free Software Foundation; either version 2 of the License, or //
15 // (at your option) any later version. //
16 // //
17 // This program is distributed in the hope that it will be useful, //
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20 // GNU General Public License for more details: //
21 // //
22 // http://www.gnu.org/copyleft/gpl.html //
23 // //
24 ///////////////////////////////////////////////////////////////////////////
26 require_once '../../../config.php';
27 require_once $CFG->dirroot.'/grade/export/lib.php';
28 require_once 'grade_export_xml.php';
30 $id = required_param('id', PARAM_INT); // course id
31 $feedback = optional_param('feedback', '', PARAM_ALPHA);
33 if (!$course = get_record('course', 'id', $id)) {
34 print_error('nocourseid');
37 require_login($course);
38 $context = get_context_instance(CONTEXT_COURSE, $id);
40 require_capability('moodle/grade:export', $context);
41 require_capability('gradeexport/xml:view', $context);
44 $strgrades = get_string('grades', 'grades');
45 $actionstr = get_string('modulename', 'gradeexport_xml');
46 $navigation = grade_build_nav(__FILE__, $actionstr, array('courseid' => $course->id));
48 print_header($course->shortname.': '.get_string('grades'), $course->fullname, $navigation);
49 print_grade_plugin_selector($id, 'export', 'xml');
50 // process post information
51 if (($data = data_submitted()) && confirm_sesskey()) {
53 if (!is_array($data->itemids)) {
54 $itemidsurl = $data->itemids;
55 } else {
56 $itemidsurl = implode(",",$data->itemids);
59 // print the grades on screen for feedbacks
61 $export = new grade_export($id, $data->itemids);
62 $export->display_grades($feedback);
64 // this redirect should trigger a download prompt
65 redirect('export.php?id='.$id.'&amp;itemids='.$itemidsurl);
66 exit;
69 print_gradeitem_selections($id);
70 print_footer();