Merge branch 'MDL-48679-28' of git://github.com/lameze/moodle into MOODLE_28_STABLE
This commit is contained in:
@@ -196,6 +196,8 @@ class grade_export_form extends moodleform {
|
||||
$submitstring = get_string('download');
|
||||
if (empty($features['simpleui'])) {
|
||||
$submitstring = get_string('submit');
|
||||
} else if (!empty($CFG->gradepublishing)) {
|
||||
$submitstring = get_string('export', 'grades');
|
||||
}
|
||||
|
||||
$this->add_action_buttons(false, $submitstring);
|
||||
|
||||
+169
-10
@@ -383,16 +383,30 @@ abstract class grade_export {
|
||||
$itemidsparam = '-1';
|
||||
}
|
||||
|
||||
$params = array('id' =>$this->course->id,
|
||||
'groupid' =>$this->groupid,
|
||||
'itemids' =>$itemidsparam,
|
||||
'export_letters' =>$this->export_letters,
|
||||
'export_feedback' =>$this->export_feedback,
|
||||
'updatedgradesonly' =>$this->updatedgradesonly,
|
||||
'displaytype' =>$this->displaytype,
|
||||
'decimalpoints' =>$this->decimalpoints,
|
||||
'export_onlyactive' =>$this->onlyactive,
|
||||
'usercustomfields' =>$this->usercustomfields);
|
||||
// We have a single grade display type constant.
|
||||
if (!is_array($this->displaytype)) {
|
||||
$displaytypes = $this->displaytype;
|
||||
} else {
|
||||
// Implode the grade display types array as moodle_url function doesn't accept arrays.
|
||||
$displaytypes = implode(',', $this->displaytype);
|
||||
}
|
||||
|
||||
if (!empty($this->updatedgradesonly)) {
|
||||
$updatedgradesonly = $this->updatedgradesonly;
|
||||
} else {
|
||||
$updatedgradesonly = 0;
|
||||
}
|
||||
$params = array('id' => $this->course->id,
|
||||
'groupid' => $this->groupid,
|
||||
'itemids' => $itemidsparam,
|
||||
'export_letters' => $this->export_letters,
|
||||
'export_feedback' => $this->export_feedback,
|
||||
'updatedgradesonly' => $updatedgradesonly,
|
||||
'decimalpoints' => $this->decimalpoints,
|
||||
'export_onlyactive' => $this->onlyactive,
|
||||
'usercustomfields' => $this->usercustomfields,
|
||||
'displaytype' => $displaytypes,
|
||||
'key' => $this->userkey);
|
||||
|
||||
return $params;
|
||||
}
|
||||
@@ -436,6 +450,151 @@ abstract class grade_export {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the export url.
|
||||
*
|
||||
* Get submitted form data and create the url to be used on the grade publish feature.
|
||||
*
|
||||
* @return moodle_url the url of grade publishing export.
|
||||
*/
|
||||
public function get_export_url() {
|
||||
return new moodle_url('/grade/export/'.$this->plugin.'/dump.php', $this->get_export_params());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the grade display types parameter into the required array to grade exporting class.
|
||||
*
|
||||
* In order to export, the array key must be the display type name and the value must be the grade display type
|
||||
* constant.
|
||||
*
|
||||
* Note: Added support for combined display types constants like the (GRADE_DISPLAY_TYPE_PERCENTAGE_REAL) as
|
||||
* the $CFG->grade_export_displaytype config is still used on 2.7 in case of missing displaytype url param.
|
||||
* In these cases, the file will be exported with a column for each display type.
|
||||
*
|
||||
* @param string $displaytypes can be a single or multiple display type constants comma separated.
|
||||
* @return array $types
|
||||
*/
|
||||
public static function convert_flat_displaytypes_to_array($displaytypes) {
|
||||
$types = array();
|
||||
|
||||
// We have a single grade display type constant.
|
||||
if (is_int($displaytypes)) {
|
||||
$displaytype = clean_param($displaytypes, PARAM_INT);
|
||||
|
||||
// Let's set a default value, will be replaced below by the grade display type constant.
|
||||
$display[$displaytype] = 1;
|
||||
} else {
|
||||
// Multiple grade display types constants.
|
||||
$display = array_flip(explode(',', $displaytypes));
|
||||
}
|
||||
|
||||
// Now, create the array in the required format by grade exporting class.
|
||||
foreach ($display as $type => $value) {
|
||||
$type = clean_param($type, PARAM_INT);
|
||||
if ($type == GRADE_DISPLAY_TYPE_LETTER) {
|
||||
$types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
|
||||
} else if ($type == GRADE_DISPLAY_TYPE_PERCENTAGE) {
|
||||
$types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
|
||||
} else if ($type == GRADE_DISPLAY_TYPE_REAL) {
|
||||
$types['real'] = GRADE_DISPLAY_TYPE_REAL;
|
||||
} else if ($type == GRADE_DISPLAY_TYPE_REAL_PERCENTAGE) {
|
||||
$types['real'] = GRADE_DISPLAY_TYPE_REAL;
|
||||
$types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
|
||||
} else if ($type == GRADE_DISPLAY_TYPE_REAL_LETTER) {
|
||||
$types['real'] = GRADE_DISPLAY_TYPE_REAL;
|
||||
$types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
|
||||
} else if ($type == GRADE_DISPLAY_TYPE_LETTER_REAL) {
|
||||
$types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
|
||||
$types['real'] = GRADE_DISPLAY_TYPE_REAL;
|
||||
} else if ($type == GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE) {
|
||||
$types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
|
||||
$types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
|
||||
} else if ($type == GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER) {
|
||||
$types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
|
||||
$types['letter'] = GRADE_DISPLAY_TYPE_LETTER;
|
||||
} else if ($type == GRADE_DISPLAY_TYPE_PERCENTAGE_REAL) {
|
||||
$types['percentage'] = GRADE_DISPLAY_TYPE_PERCENTAGE;
|
||||
$types['real'] = GRADE_DISPLAY_TYPE_REAL;
|
||||
}
|
||||
}
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the item ids parameter into the required array to grade exporting class.
|
||||
*
|
||||
* In order to export, the array key must be the grade item id and all values must be one.
|
||||
*
|
||||
* @param string $itemids can be a single item id or many item ids comma separated.
|
||||
* @return array $items correctly formatted array.
|
||||
*/
|
||||
public static function convert_flat_itemids_to_array($itemids) {
|
||||
$items = array();
|
||||
|
||||
// We just have one single item id.
|
||||
if (is_int($itemids)) {
|
||||
$itemid = clean_param($itemids, PARAM_INT);
|
||||
$items[$itemid] = 1;
|
||||
} else {
|
||||
// Few grade items.
|
||||
$items = array_flip(explode(',', $itemids));
|
||||
foreach ($items as $itemid => $value) {
|
||||
$itemid = clean_param($itemid, PARAM_INT);
|
||||
$items[$itemid] = 1;
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the html code of the grade publishing feature.
|
||||
*
|
||||
* @return string $output html code of the grade publishing.
|
||||
*/
|
||||
public function get_grade_publishing_url() {
|
||||
$url = $this->get_export_url();
|
||||
$output = html_writer::start_div();
|
||||
$output .= html_writer::tag('p', get_string('gradepublishinglink', 'grades', html_writer::link($url, $url)));
|
||||
$output .= html_writer::end_div();
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a stdClass object from URL parameters to be used by grade_export class.
|
||||
*
|
||||
* @param int $id course id.
|
||||
* @param string $itemids grade items comma separated.
|
||||
* @param bool $exportfeedback export feedback option.
|
||||
* @param bool $onlyactive only enrolled active students.
|
||||
* @param string $displaytype grade display type constants comma separated.
|
||||
* @param int $decimalpoints grade decimal points.
|
||||
* @param null $updatedgradesonly recently updated grades only (Used by XML exporting only).
|
||||
* @param null $separator separator character: tab, comma, colon and semicolon (Used by TXT exporting only).
|
||||
*
|
||||
* @return stdClass $formdata
|
||||
*/
|
||||
public static function export_bulk_export_data($id, $itemids, $exportfeedback, $onlyactive, $displaytype,
|
||||
$decimalpoints, $updatedgradesonly = null, $separator = null) {
|
||||
|
||||
$formdata = new \stdClass();
|
||||
$formdata->id = $id;
|
||||
$formdata->itemids = self::convert_flat_itemids_to_array($itemids);
|
||||
$formdata->exportfeedback = $exportfeedback;
|
||||
$formdata->export_onlyactive = $onlyactive;
|
||||
$formdata->display = self::convert_flat_displaytypes_to_array($displaytype);
|
||||
$formdata->decimals = $decimalpoints;
|
||||
|
||||
if (!empty($updatedgradesonly)) {
|
||||
$formdata->updatedgradesonly = $updatedgradesonly;
|
||||
}
|
||||
|
||||
if (!empty($separator)) {
|
||||
$formdata->separator = $separator;
|
||||
}
|
||||
|
||||
return $formdata;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,8 +17,16 @@
|
||||
|
||||
define('NO_MOODLE_COOKIES', true); // session not used here
|
||||
require_once '../../../config.php';
|
||||
require_once($CFG->dirroot.'/grade/export/ods/grade_export_ods.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);
|
||||
$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);
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
@@ -30,9 +38,19 @@ if (empty($CFG->gradepublishing)) {
|
||||
}
|
||||
|
||||
$context = context_course::instance($id);
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/ods:view', $context);
|
||||
require_capability('gradeexport/ods:publish', $context);
|
||||
|
||||
// use the same page parameters as export.php and append &key=sdhakjsahdksahdkjsahksadjksahdkjsadhksa
|
||||
require 'export.php';
|
||||
if (!groups_group_visible($groupid, $COURSE)) {
|
||||
print_error('cannotaccessgroup', 'grades');
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
$export = new grade_export_ods($course, $groupid, $formdata);
|
||||
$export->print_grades();
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ require_once $CFG->dirroot.'/grade/export/lib.php';
|
||||
require_once 'grade_export_ods.php';
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
$PAGE->set_url('/grade/export/ods/export.php', array('id'=>$id));
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
print_error('nocourseid');
|
||||
@@ -32,6 +33,13 @@ $groupid = groups_get_course_group($course, true);
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/ods:view', $context);
|
||||
|
||||
// We need to call this method here before any output 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', 'ods', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_ods'));
|
||||
}
|
||||
|
||||
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');
|
||||
@@ -39,9 +47,16 @@ if (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('
|
||||
}
|
||||
$mform = new grade_export_form(null, array('publishing' => true, 'simpleui' => true, 'multipledisplaytypes' => true));
|
||||
$data = $mform->get_data();
|
||||
|
||||
// print all the exported data here
|
||||
$export = new grade_export_ods($course, $groupid, $data);
|
||||
$export->print_grades();
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -17,8 +17,17 @@
|
||||
|
||||
define('NO_MOODLE_COOKIES', true); // session not used here
|
||||
require_once '../../../config.php';
|
||||
require_once($CFG->dirroot.'/grade/export/txt/grade_export_txt.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);
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
@@ -30,9 +39,19 @@ if (empty($CFG->gradepublishing)) {
|
||||
}
|
||||
|
||||
$context = context_course::instance($id);
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/txt:publish', $context);
|
||||
require_capability('gradeexport/txt:view', $context);
|
||||
|
||||
// use the same page parameters as export.php and append &key=sdhakjsahdksahdkjsahksadjksahdkjsadhksa
|
||||
require 'export.php';
|
||||
if (!groups_group_visible($groupid, $COURSE)) {
|
||||
print_error('cannotaccessgroup', 'grades');
|
||||
}
|
||||
|
||||
// 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_txt($course, $groupid, $formdata);
|
||||
$export->print_grades();
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ require_once $CFG->dirroot.'/grade/export/lib.php';
|
||||
require_once 'grade_export_txt.php';
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
$PAGE->set_url('/grade/export/txt/export.php', array('id'=>$id));
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
print_error('nocourseid');
|
||||
@@ -32,6 +33,13 @@ $groupid = groups_get_course_group($course, true);
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/txt: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', 'txt', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_txt'));
|
||||
}
|
||||
|
||||
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');
|
||||
@@ -46,8 +54,15 @@ $params = array(
|
||||
);
|
||||
$mform = new grade_export_form(null, $params);
|
||||
$data = $mform->get_data();
|
||||
|
||||
// Print all the exported data here.
|
||||
$export = new grade_export_txt($course, $groupid, $data);
|
||||
$export->print_grades();
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,8 +17,16 @@
|
||||
|
||||
define('NO_MOODLE_COOKIES', true); // session not used here
|
||||
require_once '../../../config.php';
|
||||
require_once($CFG->dirroot.'/grade/export/xls/grade_export_xls.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);
|
||||
$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);
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
@@ -30,9 +38,19 @@ if (empty($CFG->gradepublishing)) {
|
||||
}
|
||||
|
||||
$context = context_course::instance($id);
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/xls:view', $context);
|
||||
require_capability('gradeexport/xls:publish', $context);
|
||||
|
||||
// use the same page parameters as export.php and append &key=sdhakjsahdksahdkjsahksadjksahdkjsadhksa
|
||||
require 'export.php';
|
||||
if (!groups_group_visible($groupid, $COURSE)) {
|
||||
print_error('cannotaccessgroup', 'grades');
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
$export = new grade_export_xls($course, $groupid, $formdata);
|
||||
$export->print_grades();
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ require_once $CFG->dirroot.'/grade/export/lib.php';
|
||||
require_once 'grade_export_xls.php';
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
$PAGE->set_url('/grade/export/xls/export.php', array('id'=>$id));
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
print_error('nocourseid');
|
||||
@@ -32,6 +33,13 @@ $groupid = groups_get_course_group($course, true);
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/xls: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', 'xls', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_xls'));
|
||||
}
|
||||
|
||||
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');
|
||||
@@ -39,9 +47,14 @@ if (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('
|
||||
}
|
||||
$mform = new grade_export_form(null, array('publishing' => true, 'simpleui' => true, 'multipledisplaytypes' => true));
|
||||
$formdata = $mform->get_data();
|
||||
|
||||
// print all the exported data here
|
||||
$export = new grade_export_xls($course, $groupid, $formdata);
|
||||
$export->print_grades();
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,17 @@
|
||||
|
||||
define('NO_MOODLE_COOKIES', true); // session not used here
|
||||
require_once '../../../config.php';
|
||||
require_once($CFG->dirroot.'/grade/export/xml/grade_export_xml.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);
|
||||
$updatedgradesonly = optional_param('updatedgradesonly', false, PARAM_BOOL);
|
||||
$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);
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
@@ -30,9 +39,19 @@ if (empty($CFG->gradepublishing)) {
|
||||
}
|
||||
|
||||
$context = context_course::instance($id);
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/xml:publish', $context);
|
||||
require_capability('gradeexport/xml:view', $context);
|
||||
|
||||
// use the same page parameters as export.php and append &key=sdhakjsahdksahdkjsahksadjksahdkjsadhksa
|
||||
require 'export.php';
|
||||
if (!groups_group_visible($groupid, $COURSE)) {
|
||||
print_error('cannotaccessgroup', 'grades');
|
||||
}
|
||||
|
||||
// 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, $updatedgradesonly, null);
|
||||
|
||||
$export = new grade_export_xml($course, $groupid, $formdata);
|
||||
$export->print_grades();
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ require_once $CFG->dirroot.'/grade/export/lib.php';
|
||||
require_once 'grade_export_xml.php';
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
$PAGE->set_url('/grade/export/xml/export.php', array('id'=>$id));
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
print_error('nocourseid');
|
||||
@@ -32,17 +33,30 @@ $groupid = groups_get_course_group($course, true);
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/xml: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', 'xml', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_xml'));
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
$mform = new grade_export_form(null, array('publishing' => true, 'simpleui' => true, 'multipledisplaytypes' => false,
|
||||
'idnumberrequired' => true));
|
||||
'idnumberrequired' => true, 'updategradesonly' => true));
|
||||
$formdata = $mform->get_data();
|
||||
|
||||
// print all the exported data here
|
||||
$export = new grade_export_xml($course, $groupid, $formdata);
|
||||
$export->print_grades();
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -305,6 +305,7 @@ $string['gradepointmax_validateerror'] = 'This setting must be an integer betwee
|
||||
$string['gradepreferences'] = 'Grade preferences';
|
||||
$string['gradepreferenceshelp'] = 'Grade preferences Help';
|
||||
$string['gradepublishing'] = 'Enable publishing';
|
||||
$string['gradepublishinglink'] = 'Download: {$a}';
|
||||
$string['gradepublishing_help'] = 'Enable publishing in exports and imports: Exported grades can be accessed by accessing a URL, without having to log on to a Moodle site. Grades can be imported by accessing such a URL (which means that a Moodle site can import grades published by another site). By default only administrators may use this feature, please educate users before adding required capabilities to other roles (dangers of bookmark sharing and download accelerators, IP restrictions, etc.).';
|
||||
$string['gradereport'] = 'Grade report';
|
||||
$string['graderreport'] = 'Grader report';
|
||||
|
||||
Reference in New Issue
Block a user