This commit is contained in:
Ilya Tregubov 2024-03-08 11:15:16 +08:00
commit 24e42ed7d1
5 changed files with 81 additions and 1 deletions

View File

@ -74,6 +74,8 @@ if (has_capability('moodle/grade:manage', $systemcontext)
$temp->add(new admin_setting_special_gradeexport()); $temp->add(new admin_setting_special_gradeexport());
$temp->add(new admin_setting_special_gradeexportdefault());
$temp->add(new admin_setting_special_gradelimiting()); $temp->add(new admin_setting_special_gradelimiting());
$temp->add(new admin_setting_configcheckbox('grade_report_showmin', $temp->add(new admin_setting_configcheckbox('grade_report_showmin',

View File

@ -46,7 +46,8 @@ $exportplugins = array_filter(core_component::get_plugin_list('gradeexport'),
); );
if (!empty($exportplugins)) { if (!empty($exportplugins)) {
$exportplugin = array_key_first($exportplugins); $exportplugin = isset($CFG->gradeexport_default, $exportplugins[$CFG->gradeexport_default])
? $CFG->gradeexport_default : array_key_first($exportplugins);
$url = new moodle_url("/grade/export/{$exportplugin}/index.php", ['id' => $courseid]); $url = new moodle_url("/grade/export/{$exportplugin}/index.php", ['id' => $courseid]);
redirect($url); redirect($url);
} }

View File

@ -0,0 +1,27 @@
@core @core_grades @javascript
Feature: Configurable default grade export method
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
Scenario: View default grade export method in gradebook
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "More > Export" in the course gradebook
Then I should see "Export to OpenDocument spreadsheet"
Scenario: Changing the default grade export method in gradebook
Given the following config values are set as admin:
| gradeexport_default | txt |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "More > Export" in the course gradebook
Then I should see "Export to Plain text file"

View File

@ -287,6 +287,7 @@ $string['configgeoipfile'] = 'Location of GeoLite2 City binary data file. This f
$string['configgetremoteaddrconf'] = 'If your server is behind a reverse proxy, you can use this setting to specify which HTTP headers can be trusted to contain the remote IP address. The headers are read in order, using the first one that is available.'; $string['configgetremoteaddrconf'] = 'If your server is behind a reverse proxy, you can use this setting to specify which HTTP headers can be trusted to contain the remote IP address. The headers are read in order, using the first one that is available.';
$string['configgradebookroles'] = 'This setting allows you to control who appears on the gradebook. Users need to have at least one of these roles in a course to be shown in the gradebook for that course.'; $string['configgradebookroles'] = 'This setting allows you to control who appears on the gradebook. Users need to have at least one of these roles in a course to be shown in the gradebook for that course.';
$string['configgradeexport'] = 'Choose which gradebook export formats are your primary methods for exporting grades. Chosen plugins will then set and use a "last exported" field for every grade. For example, this might result in exported records being identified as being "new" or "updated". If you are not sure about this then leave everything unchecked.'; $string['configgradeexport'] = 'Choose which gradebook export formats are your primary methods for exporting grades. Chosen plugins will then set and use a "last exported" field for every grade. For example, this might result in exported records being identified as being "new" or "updated". If you are not sure about this then leave everything unchecked.';
$string['configgradeexportdefault'] = 'Choose which gradebook export format is your default method for exporting grades.';
$string['confighiddenuserfields'] = 'Select which user information fields you wish to hide from other users other than course teachers/admins. This will increase student privacy. Hold CTRL key to select multiple fields.'; $string['confighiddenuserfields'] = 'Select which user information fields you wish to hide from other users other than course teachers/admins. This will increase student privacy. Hold CTRL key to select multiple fields.';
$string['configidnumber'] = 'This option specifies whether (a) Users are not be asked for an ID number at all, (b) Users are asked for an ID number but can leave it blank or (c) Users are asked for an ID Number and cannot leave it blank. If given the User\'s ID number is displayed in their Profile.'; $string['configidnumber'] = 'This option specifies whether (a) Users are not be asked for an ID number at all, (b) Users are asked for an ID number but can leave it blank or (c) Users are asked for an ID Number and cannot leave it blank. If given the User\'s ID number is displayed in their Profile.';
$string['configintro'] = 'On this page you can specify a number of configuration variables that help make Moodle work properly on your server. Don\'t worry too much about it - the defaults will usually work fine and you can always come back to this page later and change these settings.'; $string['configintro'] = 'On this page you can specify a number of configuration variables that help make Moodle work properly on your server. Don\'t worry too much about it - the defaults will usually work fine and you can always come back to this page later and change these settings.';
@ -701,6 +702,7 @@ $string['gradebookroles'] = 'Graded roles';
$string['gravatardefaulturl'] = 'Gravatar default image URL'; $string['gravatardefaulturl'] = 'Gravatar default image URL';
$string['gravatardefaulturl_help'] = 'Gravatar needs a default image to display if it is unable to find a picture for a given user. Provide a full URL for an image. If you leave this setting empty, Moodle will attempt to use the most appropriate default image for the page you are viewing. Note also that Gravatar has a number of codes which can be used to <a href="https://en.gravatar.com/site/implement/images/#default-image">generate default images</a>.'; $string['gravatardefaulturl_help'] = 'Gravatar needs a default image to display if it is unable to find a picture for a given user. Provide a full URL for an image. If you leave this setting empty, Moodle will attempt to use the most appropriate default image for the page you are viewing. Note also that Gravatar has a number of codes which can be used to <a href="https://en.gravatar.com/site/implement/images/#default-image">generate default images</a>.';
$string['gradeexport'] = 'Primary grade export methods'; $string['gradeexport'] = 'Primary grade export methods';
$string['gradeexportdefault'] = 'Default grade export method';
$string['guestroleid'] = 'Role for guest'; $string['guestroleid'] = 'Role for guest';
$string['guestroleid_help'] = 'This role is automatically assigned to the guest user. It is also temporarily assigned to not enrolled users that enter the course via guest enrolment plugin.'; $string['guestroleid_help'] = 'This role is automatically assigned to the guest user. It is also temporarily assigned to not enrolled users that enter the course via guest enrolment plugin.';
$string['helpadminseesall'] = 'In the site calendar, do admins see and filter events from all course calendars or just those from courses they are enrolled in? Regardless of the chosen option, admins will always be able to manage events for each course calendar by navigating to the course first, and then accessing the course calendar directly.'; $string['helpadminseesall'] = 'In the site calendar, do admins see and filter events from all course calendars or just those from courses they are enrolled in? Regardless of the chosen option, admins will always be able to manage events for each course calendar by navigating to the course first, and then accessing the course calendar directly.';

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. * A setting for setting the default grade point value. Must be an integer between 1 and $CFG->gradepointmax.