This commit is contained in:
Ilya Tregubov
2024-03-08 11:15:16 +08:00
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.