MDL-69422 mod_data: Export form accessibility fixes
* Set appropriate heading element IDs * Replace usages of deprecated HTML tag acronym with abbr instead. * Add a label for the export fields fieldset. * Move the CSV delimiter list outside the radio group. * Fix div under a label element and duplicate labels for the checkboxes of the fields to be exported by showing the field name and type together. * Group the fields to be exported as a fieldset. * Move unsupported fields into a separate list. * Move export options into its own section and group the options as a fieldset.
This commit is contained in:
+53
-29
@@ -31,25 +31,31 @@ class mod_data_export_form extends moodleform {
|
||||
}
|
||||
|
||||
function definition() {
|
||||
global $CFG;
|
||||
$mform =& $this->_form;
|
||||
$mform->addElement('header', 'notice', get_string('chooseexportformat', 'data'));
|
||||
$choices = csv_import_reader::get_delimiter_list();
|
||||
$key = array_search(';', $choices);
|
||||
if (! $key === FALSE) {
|
||||
// array $choices contains the semicolon -> drop it (because its encrypted form also contains a semicolon):
|
||||
unset($choices[$key]);
|
||||
}
|
||||
$mform->addElement('header', 'exportformat', get_string('chooseexportformat', 'data'));
|
||||
|
||||
$optionattrs = ['class' => 'mt-1 mb-1'];
|
||||
|
||||
// Export format type radio group.
|
||||
$typesarray = array();
|
||||
$str = get_string('csvwithselecteddelimiter', 'data');
|
||||
$typesarray[] = $mform->createElement('radio', 'exporttype', null, $str . ' ', 'csv');
|
||||
$typesarray[] = $mform->createElement('select', 'delimiter_name', null, $choices);
|
||||
//temporarily commenting out Excel export option. See MDL-19864
|
||||
$typesarray[] = $mform->createElement('radio', 'exporttype', null, get_string('csvwithselecteddelimiter', 'data'), 'csv',
|
||||
$optionattrs);
|
||||
// Temporarily commenting out Excel export option. See MDL-19864.
|
||||
//$typesarray[] = $mform->createElement('radio', 'exporttype', null, get_string('excel', 'data'), 'xls');
|
||||
$typesarray[] = $mform->createElement('radio', 'exporttype', null, get_string('ods', 'data'), 'ods');
|
||||
$mform->addGroup($typesarray, 'exportar', '', array(''), false);
|
||||
$typesarray[] = $mform->createElement('radio', 'exporttype', null, get_string('ods', 'data'), 'ods', $optionattrs);
|
||||
$mform->addGroup($typesarray, 'exportar', get_string('exportformat', 'data'), null, false);
|
||||
$mform->addRule('exportar', null, 'required');
|
||||
$mform->setDefault('exporttype', 'csv');
|
||||
|
||||
// CSV delimiter list.
|
||||
$choices = csv_import_reader::get_delimiter_list();
|
||||
$key = array_search(';', $choices);
|
||||
if ($key !== false) {
|
||||
// Array $choices contains the semicolon -> drop it (because its encrypted form also contains a semicolon):
|
||||
unset($choices[$key]);
|
||||
}
|
||||
$mform->addElement('select', 'delimiter_name', get_string('fielddelimiter', 'data'), $choices);
|
||||
$mform->hideIf('delimiter_name', 'exporttype', 'neq', 'csv');
|
||||
if (array_key_exists('cfg', $choices)) {
|
||||
$mform->setDefault('delimiter_name', 'cfg');
|
||||
} else if (get_string('listsep', 'langconfig') == ';') {
|
||||
@@ -57,38 +63,56 @@ class mod_data_export_form extends moodleform {
|
||||
} else {
|
||||
$mform->setDefault('delimiter_name', 'comma');
|
||||
}
|
||||
$mform->addElement('header', 'notice', get_string('chooseexportfields', 'data'));
|
||||
|
||||
// Fields to be exported.
|
||||
$mform->addElement('header', 'exportfieldsheader', get_string('chooseexportfields', 'data'));
|
||||
$mform->setExpanded('exportfieldsheader');
|
||||
$numfieldsthatcanbeselected = 0;
|
||||
foreach($this->_datafields as $field) {
|
||||
if($field->text_export_supported()) {
|
||||
$exportfields = [];
|
||||
$unsupportedfields = [];
|
||||
foreach ($this->_datafields as $field) {
|
||||
$label = get_string('fieldnametype', 'data', (object)['name' => $field->field->name, 'type' => $field->name()]);
|
||||
if ($field->text_export_supported()) {
|
||||
$numfieldsthatcanbeselected++;
|
||||
$html = '<div title="' . s($field->field->description) . '" ' .
|
||||
'class="d-inline-block">' . $field->field->name . '</div>';
|
||||
$name = ' (' . $field->name() . ')';
|
||||
$mform->addElement('advcheckbox', 'field_' . $field->field->id, $html, $name, array('group' => 1));
|
||||
$exportfields[] = $mform->createElement('advcheckbox', 'field_' . $field->field->id, '', $label,
|
||||
array_merge(['group' => 1], $optionattrs));
|
||||
$mform->setDefault('field_' . $field->field->id, 1);
|
||||
} else {
|
||||
$a = new stdClass();
|
||||
$a->fieldtype = $field->name();
|
||||
$str = get_string('unsupportedexport', 'data', $a);
|
||||
$mform->addElement('static', 'unsupported' . $field->field->id, $field->field->name, $str);
|
||||
$unsupportedfields[] = $label;
|
||||
}
|
||||
}
|
||||
$mform->addGroup($exportfields, 'exportfields', get_string('selectfields', 'data'), ['<br>'], false);
|
||||
|
||||
if ($numfieldsthatcanbeselected > 1) {
|
||||
$this->add_checkbox_controller(1, null, null, 1);
|
||||
}
|
||||
|
||||
// List fields that cannot be exported.
|
||||
if (!empty($unsupportedfields)) {
|
||||
$unsupportedfieldslist = html_writer::tag('p', get_string('unsupportedfieldslist', 'data'), ['class' => 'mt-1']);
|
||||
$unsupportedfieldslist .= html_writer::alist($unsupportedfields);
|
||||
$mform->addElement('static', 'unsupportedfields', get_string('unsupportedfields', 'data'), $unsupportedfieldslist);
|
||||
}
|
||||
|
||||
// Export options.
|
||||
$mform->addElement('header', 'exportoptionsheader', get_string('exportoptions', 'data'));
|
||||
$mform->setExpanded('exportoptionsheader');
|
||||
$exportoptions = [];
|
||||
if (core_tag_tag::is_enabled('mod_data', 'data_records')) {
|
||||
$mform->addElement('checkbox', 'exporttags', get_string('includetags', 'data'));
|
||||
$exportoptions[] = $mform->createElement('checkbox', 'exporttags', get_string('includetags', 'data'), '', $optionattrs);
|
||||
$mform->setDefault('exporttags', 1);
|
||||
}
|
||||
$context = context_module::instance($this->_cm->id);
|
||||
if (has_capability('mod/data:exportuserinfo', $context)) {
|
||||
$mform->addElement('checkbox', 'exportuser', get_string('includeuserdetails', 'data'));
|
||||
$exportoptions[] = $mform->createElement('checkbox', 'exportuser', get_string('includeuserdetails', 'data'), '',
|
||||
$optionattrs);
|
||||
}
|
||||
$mform->addElement('checkbox', 'exporttime', get_string('includetime', 'data'));
|
||||
$exportoptions[] = $mform->createElement('checkbox', 'exporttime', get_string('includetime', 'data'), '', $optionattrs);
|
||||
if ($this->_data->approval) {
|
||||
$mform->addElement('checkbox', 'exportapproval', get_string('includeapproval', 'data'));
|
||||
$exportoptions[] = $mform->createElement('checkbox', 'exportapproval', get_string('includeapproval', 'data'), '',
|
||||
$optionattrs);
|
||||
}
|
||||
$mform->addGroup($exportoptions, 'exportoptions', get_string('selectexportoptions', 'data'), ['<br>'], false);
|
||||
|
||||
$this->add_action_buttons(true, get_string('exportentries', 'data'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user