Beispiel #1
0
require_once $CFG->dirroot . '/grade/export/uag/grade_export_uag.php';
$id = required_param('id', PARAM_INT);
$groupid = optional_param('groupid', 0, PARAM_INT);
$itemids = required_param('itemids', PARAM_RAW);
$exportfeedback = optional_param('export_feedback', 0, PARAM_BOOL);
$separator = optional_param('separator', 'comma', PARAM_ALPHA);
$displaytype = optional_param('displaytype', $CFG->grade_export_displaytype, PARAM_RAW);
$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');
}
require_user_key_login('grade/export', $id);
// We want different keys for each course.
if (empty($CFG->gradepublishing)) {
    print_error('gradepubdisable');
}
$context = context_course::instance($id);
require_capability('moodle/grade:export', $context);
require_capability('gradeexport/uag:publish', $context);
require_capability('gradeexport/uag:view', $context);
if (!groups_group_visible($groupid, $COURSE)) {
    print_error('cannotaccessgroup', 'grades');
}
$coursegradeitem = $DB->get_record('grade_items', array('courseid' => $id, 'itemtype' => 'course'));
$itemids = $coursegradeitem->id;
// Get all url parameters and create an object to simulate a form submission.
$formdata = grade_export::export_bulk_export_data($id, $itemids, $exportfeedback, $onlyactive, $displaytype, $decimalpoints, null, $separator);
$export = new grade_export_uag($course, $groupid, $formdata);
$export->finalitemid = $coursegradeitem->id;
$export->print_grades();
$groupid = groups_get_course_group($course, true);
require_capability('moodle/grade:export', $context);
require_capability('gradeexport/uag:view', $context);
// We need to call this method here before any print otherwise the menu won't display.
// If you use this method without this check, will break the direct grade exporting (without publishing).
$key = optional_param('key', '', PARAM_RAW);
if (!empty($CFG->gradepublishing) && !empty($key)) {
    print_grade_page_head($COURSE->id, 'export', 'uag', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_uag'));
}
if (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
    if (!groups_is_member($groupid, $USER->id)) {
        print_error('cannotaccessgroup', 'grades');
    }
}
$params = array('includeseparator' => true, 'publishing' => true, 'simpleui' => true, 'multipledisplaytypes' => true);
$mform = new uag_export_form(null, $params);
$data = $mform->get_data();
$data->itemids["{$data->whattograde}"] = 1;
if (!$data->gradeboundaryreview) {
    $url = new moodle_url('/grade/export/uag/index.php', array('id' => $course->id, 'boundaryreview' => 1));
    redirect($url);
}
$export = new grade_export_uag($course, $groupid, $data);
// If the gradepublishing is enabled and user key is selected print the grade publishing link.
if (!empty($CFG->gradepublishing) && !empty($key)) {
    groups_print_course_menu($course, 'index.php?id=' . $id);
    echo $export->get_grade_publishing_url();
    echo $OUTPUT->footer();
} else {
    $export->print_grades();
}