MDL-79044 gradebook: Add default export method setting

Introduces a new admin setting to configure the default export method
used for redirecting the user via /grade/export/index.php

Signed-off-by: Gregor Eichelberger <[email protected]>
This commit is contained in:
Gregor Eichelberger
2024-02-09 22:31:57 +01:00
parent 328b48ebc5
commit 7c4ca5f269
5 changed files with 81 additions and 1 deletions
+48
View File
@@ -6165,6 +6165,54 @@ class admin_setting_special_gradeexport extends admin_setting_configmulticheckbo
}
}
/**
* A setting for the default grade export plugin.
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class admin_setting_special_gradeexportdefault extends admin_setting_configselect {
/**
* Calls parent::__construct with specific arguments
*/
public function __construct() {
parent::__construct('gradeexport_default', get_string('gradeexportdefault', 'admin'),
get_string('configgradeexportdefault', 'admin'), null, null);
}
/**
* Returns the default option
*
* @return string default option
*/
public function get_defaultsetting() {
$this->load_choices();
$defaultsetting = parent::get_defaultsetting();
if (array_key_exists($defaultsetting, $this->choices)) {
return $defaultsetting;
} else {
return array_key_first($this->choices);
}
}
/**
* Load the available choices for the configselect
*
* @return bool always returns true
*/
public function load_choices() {
if (is_array($this->choices)) {
return true;
}
$this->choices = [];
if ($plugins = core_component::get_plugin_list('gradeexport')) {
foreach ($plugins as $plugin => $unused) {
$this->choices[$plugin] = get_string('pluginname', 'gradeexport_'.$plugin);
}
}
return true;
}
}
/**
* A setting for setting the default grade point value. Must be an integer between 1 and $CFG->gradepointmax.