2007-07-24 08:51:45 +00:00
|
|
|
<?php //$Id$
|
|
|
|
|
2007-05-15 08:49:49 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// //
|
|
|
|
// NOTICE OF COPYRIGHT //
|
|
|
|
// //
|
|
|
|
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
|
|
|
// http://moodle.com //
|
|
|
|
// //
|
2007-07-31 17:02:43 +00:00
|
|
|
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
|
2007-05-15 08:49:49 +00:00
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License for more details: //
|
|
|
|
// //
|
|
|
|
// http://www.gnu.org/copyleft/gpl.html //
|
|
|
|
// //
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2007-07-18 08:13:09 +00:00
|
|
|
|
2007-07-24 08:51:45 +00:00
|
|
|
require_once '../../../config.php';
|
|
|
|
require_once $CFG->dirroot.'/grade/export/lib.php';
|
|
|
|
require_once 'grade_export_xml.php';
|
2007-07-18 08:13:09 +00:00
|
|
|
|
2007-07-24 08:51:45 +00:00
|
|
|
$id = required_param('id', PARAM_INT); // course id
|
2007-05-15 08:49:49 +00:00
|
|
|
$feedback = optional_param('feedback', '', PARAM_ALPHA);
|
2007-07-18 19:56:07 +00:00
|
|
|
|
2007-07-24 08:51:45 +00:00
|
|
|
if (!$course = get_record('course', 'id', $id)) {
|
|
|
|
print_error('nocourseid');
|
|
|
|
}
|
|
|
|
|
|
|
|
require_login($course);
|
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $id);
|
|
|
|
|
|
|
|
require_capability('moodle/grade:export', $context);
|
|
|
|
require_capability('gradeexport/xml:view', $context);
|
|
|
|
|
|
|
|
|
2007-07-17 03:32:10 +00:00
|
|
|
$strgrades = get_string('grades', 'grades');
|
2007-07-23 08:13:59 +00:00
|
|
|
$actionstr = get_string('modulename', 'gradeexport_xml');
|
2007-08-01 06:47:35 +00:00
|
|
|
$navigation = grade_build_nav(__FILE__, $actionstr, array('courseid' => $course->id));
|
|
|
|
|
|
|
|
print_header($course->shortname.': '.get_string('grades'), $course->fullname, $navigation);
|
2007-07-30 06:28:41 +00:00
|
|
|
print_grade_plugin_selector($id, 'export', 'xml');
|
2007-08-27 12:23:50 +00:00
|
|
|
|
2007-08-29 16:47:16 +00:00
|
|
|
$mform = new grade_export_form(null, array('idnumberrequired'=>true, 'publishing'=>true));
|
2007-05-16 08:21:46 +00:00
|
|
|
|
2007-08-29 12:38:23 +00:00
|
|
|
// process post information
|
|
|
|
if ($data = $mform->get_data()) {
|
2007-08-30 08:19:44 +00:00
|
|
|
$itemids = array();
|
2007-08-29 12:38:23 +00:00
|
|
|
if ($data->itemids) {
|
2007-08-29 13:00:10 +00:00
|
|
|
foreach ($data->itemids as $itemid=>$selected) {
|
|
|
|
if ($selected) {
|
2007-08-30 08:19:44 +00:00
|
|
|
$itemids[] = $itemid;
|
2007-08-29 13:00:10 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-30 08:19:44 +00:00
|
|
|
$itemidsurl = implode(",", $itemids);
|
2007-08-29 12:38:23 +00:00
|
|
|
} else {
|
|
|
|
//error?
|
|
|
|
$itemidsurl = '';
|
2007-05-16 08:21:46 +00:00
|
|
|
}
|
2007-07-18 19:56:07 +00:00
|
|
|
|
2007-05-15 08:49:49 +00:00
|
|
|
// print the grades on screen for feedbacks
|
2007-07-18 19:56:07 +00:00
|
|
|
|
2007-08-30 08:19:44 +00:00
|
|
|
$export = new grade_export($id, $itemids, $data->export_letters, !empty($data->key));
|
2007-08-27 12:23:50 +00:00
|
|
|
|
2007-08-13 08:50:17 +00:00
|
|
|
$export->display_grades($feedback, $data->previewrows);
|
2007-07-18 19:56:07 +00:00
|
|
|
|
2007-05-16 08:21:46 +00:00
|
|
|
// this redirect should trigger a download prompt
|
2007-08-28 08:29:40 +00:00
|
|
|
if (empty($data->key)) {
|
|
|
|
print_continue('export.php?id='.$id.'&itemids='.$itemidsurl.'&export_letters='.$data->export_letters);
|
|
|
|
|
|
|
|
} else {
|
2007-08-29 12:38:23 +00:00
|
|
|
if ($data->key == 1) {
|
|
|
|
$data->key = create_user_key('grade/export', $USER->id, $COURSE->id, $data->iprestriction, $data->validuntil);
|
|
|
|
}
|
2007-08-28 08:29:40 +00:00
|
|
|
$link = $CFG->wwwroot.'/grade/export/xml/dump.php?id='.$id.'&itemids='.$itemidsurl.'&export_letters='.$data->export_letters.'&key='.$data->key;
|
2007-08-30 07:12:03 +00:00
|
|
|
|
|
|
|
echo '<p>';
|
|
|
|
echo '<a href="'.$link.'">'.$link.'</a>';
|
|
|
|
echo '</p>';
|
|
|
|
print_footer();
|
2007-08-28 08:29:40 +00:00
|
|
|
}
|
2007-05-24 02:16:31 +00:00
|
|
|
exit;
|
2007-05-15 08:49:49 +00:00
|
|
|
}
|
2007-07-03 06:20:07 +00:00
|
|
|
|
2007-08-29 12:38:23 +00:00
|
|
|
$mform->display();
|
|
|
|
|
2007-05-22 02:05:00 +00:00
|
|
|
print_footer();
|
2007-07-23 08:13:59 +00:00
|
|
|
?>
|