mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-72257 gradeexport_xml: detect absense of grade items to export.
Where there are no grade items with idnumbers for selection, then nothing should be exported. Currently, this is being interpreted as the user exporting all grade items.
This commit is contained in:
parent
dc437b5171
commit
858bcbab0a
@ -24,6 +24,9 @@ require_once($CFG->dirroot.'/grade/export/grade_export_form.php');
|
||||
*/
|
||||
abstract class grade_export {
|
||||
|
||||
/** @var int Value to state nothing is being exported. */
|
||||
protected const EXPORT_SELECT_NONE = -1;
|
||||
|
||||
public $plugin; // plgin name - must be filled in subclasses!
|
||||
|
||||
public $grade_items; // list of all course grade items
|
||||
@ -112,9 +115,8 @@ abstract class grade_export {
|
||||
//with an empty $itemlist then reconstruct it in process_form() using $formdata
|
||||
$this->columns = array();
|
||||
if (!empty($itemlist)) {
|
||||
if ($itemlist=='-1') {
|
||||
//user deselected all items
|
||||
} else {
|
||||
// Check that user selected something.
|
||||
if ($itemlist != self::EXPORT_SELECT_NONE) {
|
||||
$itemids = explode(',', $itemlist);
|
||||
// remove items that are not requested
|
||||
foreach ($itemids as $itemid) {
|
||||
@ -149,9 +151,8 @@ abstract class grade_export {
|
||||
|
||||
$this->columns = array();
|
||||
if (!empty($formdata->itemids)) {
|
||||
if ($formdata->itemids=='-1') {
|
||||
//user deselected all items
|
||||
} else {
|
||||
// Check that user selected something.
|
||||
if ($formdata->itemids != self::EXPORT_SELECT_NONE) {
|
||||
foreach ($formdata->itemids as $itemid=>$selected) {
|
||||
if ($selected and array_key_exists($itemid, $this->grade_items)) {
|
||||
$this->columns[$itemid] =& $this->grade_items[$itemid];
|
||||
@ -411,7 +412,7 @@ abstract class grade_export {
|
||||
$itemids = array_keys($this->columns);
|
||||
$itemidsparam = implode(',', $itemids);
|
||||
if (empty($itemidsparam)) {
|
||||
$itemidsparam = '-1';
|
||||
$itemidsparam = self::EXPORT_SELECT_NONE;
|
||||
}
|
||||
|
||||
// We have a single grade display type constant.
|
||||
|
@ -33,6 +33,20 @@ class grade_export_xml extends grade_export {
|
||||
return htmlspecialchars($idnumber, ENT_QUOTES | ENT_XML1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle form processing for export. Note we need to handle the case where there are no 'itemids[]' being included in the
|
||||
* form, because each is disabled for selection due to having empty idnumber
|
||||
*
|
||||
* @param stdClass $formdata
|
||||
*/
|
||||
public function process_form($formdata) {
|
||||
if (!isset($formdata->itemids)) {
|
||||
$formdata->itemids = self::EXPORT_SELECT_NONE;
|
||||
}
|
||||
|
||||
parent::process_form($formdata);
|
||||
}
|
||||
|
||||
/**
|
||||
* To be implemented by child classes
|
||||
* @param boolean $feedback
|
||||
|
Loading…
x
Reference in New Issue
Block a user