Skip to content

Commit

Permalink
MDL-59299 filemanager: Display what filetypes are accepted
Browse files Browse the repository at this point in the history
  • Loading branch information
xow committed Jul 31, 2017
1 parent 847a4e2 commit 320889c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions lang/en/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
$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}';
Expand Down
8 changes: 8 additions & 0 deletions lib/form/filemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@ function toHtml() {
// 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
$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.';
Expand All @@ -47,5 +46,6 @@
$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}';
1 change: 1 addition & 0 deletions mod/assign/submission/file/lang/en/deprecated.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
filesofthesetypes,assignsubmission_file
filetypewithexts,assignsubmission_file
nonexistentfiletypes,assignsubmission_file
9 changes: 0 additions & 9 deletions mod/assign/submission/file/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,6 @@ public function get_form_elements($submission, MoodleQuickForm $mform, stdClass
$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;
}

Expand Down

0 comments on commit 320889c

Please sign in to comment.