MDL-59299 filemanager: Display what filetypes are accepted

This commit is contained in:
John Okely 2017-07-14 11:55:34 +08:00
parent 847a4e219a
commit 320889c02b
5 changed files with 11 additions and 10 deletions

View File

@ -42,6 +42,7 @@ $string['err_numeric'] = 'You must enter a number here.';
$string['err_rangelength'] = 'You must enter between {$a->format[0]} and {$a->format[1]} characters here.';
$string['err_required'] = 'You must supply a value here.';
$string['err_wrongfileextension'] = 'Some files ({$a->wrongfiles}) cannot be uploaded. Only file types {$a->whitelist} are allowed.';
$string['filesofthesetypes'] = 'Accepted files types:';
$string['filetypesany'] = 'All file types';
$string['filetypesnotall'] = 'It is not allowed to select \'All file types\' here';
$string['filetypesnotwhitelisted'] = 'These file types are not allowed here: {$a}';

View File

@ -300,6 +300,14 @@ class MoodleQuickForm_filemanager extends HTML_QuickForm_element implements temp
// label element needs 'for' attribute work
$html .= html_writer::empty_tag('input', array('value' => '', 'id' => 'id_'.$elname, 'type' => 'hidden'));
if (!empty($options->accepted_types) && $options->accepted_types != '*') {
$html .= html_writer::tag('p', get_string('filesofthesetypes', 'form'));
$util = new \core_form\filetypes_util();
$filetypes = $options->accepted_types;
$filetypedescriptions = $util->describe_file_types($filetypes);
$html .= $OUTPUT->render_from_template('core_form/filetypes-descriptions', $filetypedescriptions);
}
return $html;
}

View File

@ -34,7 +34,6 @@ $string['enabled'] = 'File submissions';
$string['enabled_help'] = 'If enabled, students are able to upload one or more files as their submission.';
$string['eventassessableuploaded'] = 'A file has been uploaded.';
$string['file'] = 'File submissions';
$string['filesofthesetypes'] = 'Files of these types may be added to the submission:';
$string['maxbytes'] = 'Maximum file size';
$string['maxfiles'] = 'Maximum files per submission';
$string['maxfiles_help'] = 'If file submissions are enabled, each assignment can be set to accept up to this number of files for their submission.';
@ -47,5 +46,6 @@ $string['pluginname'] = 'File submissions';
$string['siteuploadlimit'] = 'Site upload limit';
$string['submissionfilearea'] = 'Uploaded submission files';
// Deprecated since Moodle 3.4.
$string['filesofthesetypes'] = 'Files of these types may be added to the submission:';
$string['filetypewithexts'] = '{$a->name} — {$a->extlist}';
$string['nonexistentfiletypes'] = 'The following file types were not recognised: {$a}';

View File

@ -1,2 +1,3 @@
filesofthesetypes,assignsubmission_file
filetypewithexts,assignsubmission_file
nonexistentfiletypes,assignsubmission_file

View File

@ -183,15 +183,6 @@ class assign_submission_file extends assign_submission_plugin {
$submissionid);
$mform->addElement('filemanager', 'files_filemanager', $this->get_name(), null, $fileoptions);
if (!empty($this->get_config('filetypeslist'))) {
$text = html_writer::tag('p', get_string('filesofthesetypes', 'assignsubmission_file'));
$util = new \core_form\filetypes_util();
$filetypes = $this->get_configured_typesets();
$filetypedescriptions = $util->describe_file_types($filetypes);
$text .= $OUTPUT->render_from_template('core_form/filetypes-descriptions', $filetypedescriptions);
$mform->addElement('static', '', '', $text);
}
return true;
}