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

Select roles by checkboxes

parent b4b68414
No related branches found
No related tags found
No related merge requests found
......@@ -34,9 +34,11 @@ if (!confirm_sesskey()) {
}
$course_code = optional_param('course_code', null, PARAM_ALPHANUMEXT);
$roleids = required_param_array('select_roles', PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
$coursecontextid = required_param('coursecontextid', PARAM_INT);
$roles = required_param_array('roles',PARAM_INT);
$roleids = array_values(array_filter($roles));
$filename = download::get_evaluation_filename($courseid, $course_code);
$users = local_hshexport\local\helpers\user_query::get_users_by_role($courseid, $coursecontextid, $roleids);
......
......@@ -47,20 +47,33 @@ class evaluserexport extends moodleform {
}
$placeholder = get_string('course_code_placeholder', 'local_hshexport');
$mform->addElement('text', 'course_code', get_string('course_code', 'local_hshexport'), 'maxlength="100" size="50" placeholder="'.$placeholder.'"');
$mform->setType('course_code', PARAM_ALPHANUMEXT);
$mform->addElement('text', 'course_code', get_string('course_code', 'local_hshexport'), 'maxlength="150" size="50" placeholder="'.$placeholder.'"');
$mform->setType('course_code', PARAM_TEXT);
$mform->addHelpButton('course_code', 'course_code', 'local_hshexport');
$mform->setDefault('course_code', null);
$roles = role_fix_names($viewableroles, $coursecontext, ROLENAME_ALIAS);
$options = [];
$roles_checkboxes = [];
foreach ($roles as $role) {
$options[$role->id] = $role->localname;
$roles_checkboxes[] =& $mform->createElement('advcheckbox', 'role_'.$role->id, $role->localname, null, ['group' => 1], [null, $role->id]);
}
$select = $mform->addElement('select', 'select_roles', get_string('select_roles', 'local_hshexport'), $options);
$select->setMultiple(true);
$mform->addHelpButton('select_roles', 'select_roles', 'local_hshexport');
$mform->addRule('select_roles', get_string('noselectedroles', 'local_hshexport'), 'required', 'null', true);
$mform->addGroup($roles_checkboxes, 'roles', 'Roles', ['<br/>'], true);
$mform->addHelpButton('roles', 'select_roles', 'local_hshexport');
$mform->addGroupRule(
'roles',
get_string('noselectedroles', 'local_hshexport'),
'required',
null,
1,
'client'
);
$this->add_checkbox_controller(
1,
get_string("checkall", "local_hshexport")
);
$mform->addElement('hidden', 'courseid', $courseid);
$mform->setType('courseid', PARAM_INT);
......@@ -73,4 +86,10 @@ class evaluserexport extends moodleform {
}
function validation($data, $files)
{
$errors = parent::validation($data, $files); // TODO: Change the autogenerated stub
return $errors;
}
}
\ No newline at end of file
......@@ -50,5 +50,9 @@ $customdata = [
$mform = new evaluserexport('action_download.php', $customdata);
//if ($mform->get_data()) {
// redirect(new moodle_url('local/hshexport/action_download.php'));
//}
$mform->display();
echo $OUTPUT->footer();
......@@ -36,6 +36,7 @@ $string['course_code'] = 'LV-Kennung';
$string['course_code_help'] = 'Eine LV-Kennung muss eindeutig und einmalig sein, z.B. eine Modulkurzbezeichnung. Sie ist die eindeutige Kennung, unter der die Evaluation durchgeführt wird. Beispiele: BBA-422-01 oder 010-103';
$string['select_roles'] = 'Rollen';
$string['select_roles_help'] = 'Nutzer mit dieser Rolle bzw. diesen Rollen exportieren.';
$string['checkall'] = 'Alle auswählen';
$string['csvdownload'] = 'CSV herunterladen';
$string['noselectedroles'] = 'Mindestens eine Rolle muss ausgewählt werden.';
$string['evaluserexport_form_into'] = 'Nutzen Sie dieses Formular um eine CSV-Datei mit den Nutzern der ausgewählten Rollen für die Evaluation zu erzeugen.';
......@@ -36,6 +36,7 @@ $string['course_code'] = 'Course code';
$string['course_code_help'] = 'A course code must be unique and unambiguous, e.g. a module abbreviation. It is the unique identifier under which the evaluation is carried out. Examples BBA-422-01 or 010-103';
$string['select_roles'] = 'Roles';
$string['select_roles_help'] = 'Export users with this role or these roles.';
$string['checkall'] = 'Check all';
$string['csvdownload'] = 'Download csv';
$string['noselectedroles'] = 'At least one role has to be selected.';
$string['evaluserexport_form_into'] = 'Use this form to generate a CSV file with users of selected roles for evaluation purposes.';
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment