diff --git a/action_download.php b/action_download.php index 931e7f306fde20cc6c0ac833bc9bb8dc86e246e3..842edc9902fb49359a097ffdfae4162a6b8619e6 100644 --- a/action_download.php +++ b/action_download.php @@ -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); diff --git a/classes/form/evaluserexport.php b/classes/form/evaluserexport.php index 44c911e49b540fdf3c71f9164618b587c984bc97..8b4c2f5e2be91adc4354ccf570c0f8bde9111164 100644 --- a/classes/form/evaluserexport.php +++ b/classes/form/evaluserexport.php @@ -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 diff --git a/index.php b/index.php index 6a0956ba9e9f86e1305f209af75fae0e51583e15..b6774a84075ea18fa219f283f8c18aeb3f52abc3 100644 --- a/index.php +++ b/index.php @@ -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(); diff --git a/lang/de/local_hshexport.php b/lang/de/local_hshexport.php index 3a63205688476615bbf41fb8cc981e29136823bf..d16bc414354d2aa1eb35e7d2718dbc4a2565fde3 100644 --- a/lang/de/local_hshexport.php +++ b/lang/de/local_hshexport.php @@ -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.'; diff --git a/lang/en/local_hshexport.php b/lang/en/local_hshexport.php index e68e9c5b5652086b71d3a32e195cb56a1887b356..2b2c06ae950e44b3fe458f58412c4832394a26be 100644 --- a/lang/en/local_hshexport.php +++ b/lang/en/local_hshexport.php @@ -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