mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-46548 grades: Update xml grade export to support one step exports.
This commit is contained in:
parent
9f5834ccc7
commit
97908a2225
2 changed files with 18 additions and 28 deletions
|
@ -20,13 +20,6 @@ require_once $CFG->dirroot.'/grade/export/lib.php';
|
|||
require_once 'grade_export_xml.php';
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
$groupid = optional_param('groupid', 0, PARAM_INT);
|
||||
$itemids = required_param('itemids', PARAM_RAW);
|
||||
$export_feedback = optional_param('export_feedback', 0, PARAM_BOOL);
|
||||
$updatedgradesonly = optional_param('updatedgradesonly', false, PARAM_BOOL);
|
||||
$displaytype = optional_param('displaytype', $CFG->grade_export_displaytype, PARAM_INT);
|
||||
$decimalpoints = optional_param('decimalpoints', $CFG->grade_export_decimalpoints, PARAM_INT);
|
||||
$onlyactive = optional_param('export_onlyactive', 0, PARAM_BOOL);
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
print_error('nocourseid');
|
||||
|
@ -34,6 +27,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
|||
|
||||
require_login($course);
|
||||
$context = context_course::instance($id);
|
||||
$groupid = groups_get_course_group($course, true);
|
||||
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/xml:view', $context);
|
||||
|
@ -43,9 +37,11 @@ if (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('
|
|||
print_error('cannotaccessgroup', 'grades');
|
||||
}
|
||||
}
|
||||
$mform = new grade_export_form(null, array('publishing' => true, 'simpleui' => true));
|
||||
$formdata = $mform->get_data();
|
||||
|
||||
// print all the exported data here
|
||||
$export = new grade_export_xml($course, $groupid, $itemids, $export_feedback, $updatedgradesonly, $displaytype, $decimalpoints, $onlyactive);
|
||||
$export = new grade_export_xml($course, $groupid, $formdata);
|
||||
$export->print_grades();
|
||||
|
||||
|
||||
|
|
|
@ -40,33 +40,27 @@ if (!empty($CFG->gradepublishing)) {
|
|||
$CFG->gradepublishing = has_capability('gradeexport/xml:publish', $context);
|
||||
}
|
||||
|
||||
//'idnumberrequired'=>true excludes grade items that dont have an ID to use during import
|
||||
$mform = new grade_export_form(null, array('idnumberrequired'=>true, 'publishing'=>true, 'updategradesonly'=>true));
|
||||
$actionurl = new moodle_url('/grade/export/xml/export.php');
|
||||
// The option 'idnumberrequired' excludes grade items that dont have an ID to use during import.
|
||||
$formoptions = array(
|
||||
'idnumberrequired' => true,
|
||||
'updategradesonly' => true,
|
||||
'publishing' => true,
|
||||
'simpleui' => true
|
||||
);
|
||||
|
||||
$groupmode = groups_get_course_groupmode($course); // Groups are being used
|
||||
$mform = new grade_export_form($actionurl, $formoptions);
|
||||
|
||||
$groupmode = groups_get_course_groupmode($course); // Groups are being used.
|
||||
$currentgroup = groups_get_course_group($course, true);
|
||||
if ($groupmode == SEPARATEGROUPS and !$currentgroup and !has_capability('moodle/site:accessallgroups', $context)) {
|
||||
if (($groupmode == SEPARATEGROUPS) &&
|
||||
(!$currentgroup) &&
|
||||
(!has_capability('moodle/site:accessallgroups', $context))) {
|
||||
echo $OUTPUT->heading(get_string("notingroup"));
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
// process post information
|
||||
if ($data = $mform->get_data()) {
|
||||
$onlyactive = $data->export_onlyactive || !has_capability('moodle/course:viewsuspendedusers', $context);
|
||||
$export = new grade_export_xml($course, $currentgroup, '', false, $data->updatedgradesonly, $data->display, $data->decimals, $onlyactive);
|
||||
|
||||
// print the grades on screen for feedbacks
|
||||
$export->process_form($data);
|
||||
$export->print_continue();
|
||||
|
||||
$export->display_preview(true); //true == skip users without idnumber as they cannot be identified when importing
|
||||
echo $OUTPUT->container(get_string('useridnumberwarning','gradeexport_xml'), 'useridnumberwarning mdl-align');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
groups_print_course_menu($course, 'index.php?id='.$id);
|
||||
echo '<div class="clearer"></div>';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue