Skip to content
Snippets Groups Projects
Commit df9fd6b8 authored by Elke Kreim's avatar Elke Kreim
Browse files

Add admin settings for role choice

parent 3e58bbde
Branches
No related tags found
No related merge requests found
......@@ -58,12 +58,15 @@ class evaluserexportform extends moodleform {
$mform->addHelpButton('coursecode', 'coursecode', 'local_hshexport');
$mform->setDefault('coursecode', null);
$selectableroles = explode(',', get_config('local_hshexport', 'selectableroles'));
$viewableroles = get_roles_used_in_context($coursecontext, false);
$roles = role_fix_names($viewableroles, $coursecontext, ROLENAME_ALIAS);
$rolescheckboxes = [];
foreach ($roles as $role) {
if (in_array($role->id, $selectableroles)){
$rolescheckboxes[] =& $mform->createElement('advcheckbox', 'role_' . $role->id,
$role->localname, null, ['group' => 1], [null, $role->id]);
};
}
$mform->addGroup($rolescheckboxes, 'roles', get_string('select_roles', 'local_hshexport'), );
......
......@@ -38,5 +38,7 @@ $string['navigation'] = 'Platzierung des Links';
$string['navigation_desc'] = 'Der Ort, an dem der Link für das Formular zum Export von Nutzern zur Evaluation innerhalb eines Kurses hinzugefügt wird.';
$string['noselectedroles'] = 'Mindestens eine Rolle muss ausgewählt werden.';
$string['pluginname'] = 'HSH Nutzer Export für Evaluation';
$string['selectableroles'] = 'Auswählbare Rollen';
$string['selectableroles_desc'] = 'Rollen, die im Formular für den Nutzerexport zur Auswahl stehen können.';
$string['select_roles'] = 'Rollen';
$string['select_roles_help'] = 'Nutzer mit dieser Rolle bzw. diesen Rollen exportieren.';
......@@ -38,5 +38,7 @@ $string['navigation'] = 'Navigation node placement';
$string['navigation_desc'] = 'The location where the navigation node for evaluation user export form will be added within a course.';
$string['noselectedroles'] = 'At least one role has to be selected.';
$string['pluginname'] = 'HSH User export';
$string['selectableroles'] = 'Selectable roles';
$string['selectableroles_desc'] = 'Roles that can be selected in the user export form.';
$string['select_roles'] = 'Roles';
$string['select_roles_help'] = 'Export users with this role or these roles.';
......@@ -48,5 +48,19 @@ if ($hassiteconfig) {
unset($navigationoptions);
}
// Get roles as choicelist for selectbutton
$roles = role_fix_names(get_all_roles());
$roleslist = [];
foreach ($roles as $role) {
$roleslist[$role->id] = $role->shortname;
}
$settings -> add(new admin_setting_pickroles(
'local_hshexport/selectableroles',
get_string('selectableroles', 'local_hshexport'),
get_string('selectableroles_desc', 'local_hshexport'),
['student'],
));
$ADMIN->add('localplugins', $settings);
}
......@@ -26,6 +26,6 @@ defined('MOODLE_INTERNAL') || die();
$plugin->component = 'local_hshexport';
$plugin->release = 'v0.1-beta1';
$plugin->version = 2024110500;
$plugin->version = 2024110501;
$plugin->requires = 2022112800;
$plugin->maturity = MATURITY_BETA;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment