}
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') == ';') {
} 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'));
}
$string['csvfile'] = 'CSV file';
$string['csvimport'] = 'CSV file import';
$string['csvimport_help'] = 'Entries may be imported via a plain text file with a list of field names as the first line, then the data, with one record per line.';
-$string['csvwithselecteddelimiter'] = '<acronym title="Comma Separated Values">CSV</acronym> text with selected delimiter:';
+$string['csvwithselecteddelimiter'] = '<abbr title="Comma Separated Values">CSV</abbr>';
$string['data:addinstance'] = 'Add a new database';
$string['data:approve'] = 'Approve and undo approved entries';
$string['data:comment'] = 'Write comments';
$string['exportaszip_help'] = 'The export as zip feature allows you to save the templates and fields as a preset zip for download. The zip may then be imported to another course.';
$string['exportedtozip'] = 'Exported to temporary zip...';
$string['exportentries'] = 'Export entries';
+$string['exportformat'] = 'Export format';
+$string['exportoptions'] = 'Export options';
$string['exportownentries'] = 'Export your own entries only? ({$a->mine}/{$a->all})';
$string['failedpresetdelete'] = 'Error deleting a preset!';
$string['fieldadded'] = 'Field added';
$string['fieldmappings_help'] = 'This menu allows you to keep the data from the existing database. To preserve the data in a field, you must map it to a new field, where the data will appear. Any field can also be left blank, with no information copied into it. Any old field not mapped to a new one will be lost and all its data removed.
You can only map fields of the same type, so each drop-down menu will have different fields in it. Also, you must be careful not to try and map one old field to more than one new field.';
$string['fieldname'] = 'Field name';
+$string['fieldnametype'] = '{$a->name} ({$a->type})';
$string['fieldnotmatched'] = 'The following fields in your file are not known in this database: {$a}';
$string['fieldoptions'] = 'Options (one per line)';
$string['fields'] = 'Fields';
$string['headerrsstemplate'] = 'Defines appearance of entries in RSS feeds';
$string['headersingletemplate'] = 'Defines browsing interface for a single entry';
$string['checkbox'] = 'Checkbox';
-$string['chooseexportfields'] = 'Choose the fields you wish to export:';
-$string['chooseexportformat'] = 'Choose the format you wish to export to:';
+$string['chooseexportfields'] = 'Choose the fields you wish to export';
+$string['chooseexportformat'] = 'Choose the format you wish to export to';
$string['chooseorupload'] = 'Choose file';
$string['expired'] = 'Sorry, this activity closed on {$a} and is no longer available';
$string['importentries'] = 'Import entries';
$string['numberrssarticles'] = 'Entries in the RSS feed';
$string['numnotapproved'] = 'Pending';
$string['numrecords'] = '{$a} entries';
-$string['ods'] = '<acronym title="OpenDocument Spreadsheet">ODS</acronym> (OpenOffice)';
+$string['ods'] = '<abbr title="OpenDocument Spreadsheet">ODS</abbr> (OpenOffice)';
$string['openafterclose'] = 'You have specified an open date after the close date';
$string['optionaldescription'] = 'Short description (optional)';
$string['optionalfilename'] = 'Filename (optional)';
$string['search:activity'] = 'Database - activity information';
$string['search:entry'] = 'Database - entries';
$string['selectedrequired'] = 'All selected required';
+$string['selectfields'] = 'Select fields';
+$string['selectexportoptions'] = 'Select export options';
$string['showall'] = 'Show all entries';
$string['single'] = 'View single';
$string['singletemplate'] = 'Single template';
$string['type'] = 'Field type';
$string['undefinedprocessactionmethod'] = 'No action method defined in Data_Preset to handle action "{$a}".';
$string['unsupportedexport'] = '({$a->fieldtype}) cannot be exported.';
+$string['unsupportedfields'] = 'Unsupported fields';
+$string['unsupportedfieldslist'] = 'The following fields cannot be exported:';
$string['updatefield'] = 'Update an existing field';
$string['uploadfile'] = 'Upload file';
$string['uploadrecords'] = 'Upload entries from a file';