Skip to content

Commit

Permalink
Merge branch 'MDL-72257-310' of git://github.com/paulholden/moodle in…
Browse files Browse the repository at this point in the history
…to MOODLE_310_STABLE
  • Loading branch information
sarjona committed Aug 23, 2021
2 parents bfaeecb + 6ab27a7 commit 5666d8e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
15 changes: 8 additions & 7 deletions grade/export/lib.php
Expand Up @@ -24,6 +24,9 @@
*/
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
Expand Down Expand Up @@ -112,9 +115,8 @@ protected function deprecated_constructor($course,
//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) {
Expand Down Expand Up @@ -149,9 +151,8 @@ function process_form($formdata) {

$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];
Expand Down Expand Up @@ -411,7 +412,7 @@ public function get_export_params() {
$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.
Expand Down
14 changes: 14 additions & 0 deletions grade/export/xml/grade_export_xml.php
Expand Up @@ -33,6 +33,20 @@ private static function xml_export_idnumber(string $idnumber): string {
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
Expand Down

0 comments on commit 5666d8e

Please sign in to comment.