moodle/grade/export/xml/index.php

96 lines
3.8 KiB
PHP
Raw Normal View History

<?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
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
$id = required_param('id', PARAM_INT); // course id
2007-05-15 08:49:49 +00:00
$feedback = optional_param('feedback', '', PARAM_ALPHA);
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');
$actionstr = get_string('modulename', 'gradeexport_xml');
$navigation = grade_build_nav(__FILE__, $actionstr, array('courseid' => $course->id));
print_header($course->shortname.': '.get_string('grades'), $course->fullname, $navigation);
print_grade_plugin_selector($id, 'export', 'xml');
2007-08-29 16:47:16 +00:00
$mform = new grade_export_form(null, array('idnumberrequired'=>true, 'publishing'=>true));
// process post information
if ($data = $mform->get_data()) {
2007-08-30 08:19:44 +00:00
$itemids = array();
if ($data->itemids) {
foreach ($data->itemids as $itemid=>$selected) {
if ($selected) {
2007-08-30 08:19:44 +00:00
$itemids[] = $itemid;
}
}
2007-08-30 08:19:44 +00:00
$itemidsurl = implode(",", $itemids);
} else {
//error?
$itemidsurl = '';
}
2007-05-15 08:49:49 +00:00
// print the grades on screen for feedbacks
2007-08-30 08:19:44 +00:00
$export = new grade_export($id, $itemids, $data->export_letters, !empty($data->key));
2007-08-13 08:50:17 +00:00
$export->display_grades($feedback, $data->previewrows);
// this redirect should trigger a download prompt
if (empty($data->key)) {
print_continue('export.php?id='.$id.'&amp;itemids='.$itemidsurl.'&amp;export_letters='.$data->export_letters);
} else {
if ($data->key == 1) {
$data->key = create_user_key('grade/export', $USER->id, $COURSE->id, $data->iprestriction, $data->validuntil);
}
$link = $CFG->wwwroot.'/grade/export/xml/dump.php?id='.$id.'&amp;itemids='.$itemidsurl.'&amp;export_letters='.$data->export_letters.'&amp;key='.$data->key;
2007-08-30 07:12:03 +00:00
echo '<p>';
echo '<a href="'.$link.'">'.$link.'</a>';
echo '</p>';
print_footer();
}
exit;
2007-05-15 08:49:49 +00:00
}
2007-07-03 06:20:07 +00:00
$mform->display();
print_footer();
?>