3232 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3333 */
3434class qtype_fileresponse_edit_form extends question_edit_form {
35-
36-
3735 protected function definition_inner ($ mform ) {
3836 $ qtype = question_bank::get_qtype ('fileresponse ' );
3937
4038 /* Display the ?forcedownload=1 advice. */
41- $ mform ->addElement ('static ' , 'advice ' , get_string ('advice ' , 'qtype_fileresponse ' ),
39+ $ mform ->addElement (
40+ 'static ' ,
41+ 'advice ' ,
42+ get_string ('advice ' , 'qtype_fileresponse ' ),
4243 '<div style="width:496px;"> ' . get_string ('questiontextforcedownload ' , 'qtype_fileresponse ' ) .
43- '</div> ' );
44+ '</div> ' ,
45+ );
4446
4547 /* fileresponse only accepts 'formatplain' as format */
4648 $ mform ->setDefault ('responseformat ' , 'plain ' );
@@ -52,13 +54,21 @@ protected function definition_inner($mform) {
5254
5355 /* Response required element removed from qtype_essay. */
5456
55- $ mform ->addElement ('select ' , 'responsefieldlines ' ,
56- get_string ('responsefieldlines ' , 'qtype_fileresponse ' ), $ qtype ->response_sizes ());
57+ $ mform ->addElement (
58+ 'select ' ,
59+ 'responsefieldlines ' ,
60+ get_string ('responsefieldlines ' , 'qtype_fileresponse ' ),
61+ $ qtype ->response_sizes ()
62+ );
5763 $ mform ->setDefault ('responsefieldlines ' , 15 );
5864
5965 /* Fileresponse has to have at least one file required */
60- $ mform ->addElement ('select ' , 'attachments ' ,
61- get_string ('amountofexpectedfiles ' , 'qtype_fileresponse ' ), $ qtype ->attachment_options ());
66+ $ mform ->addElement (
67+ 'select ' ,
68+ 'attachments ' ,
69+ get_string ('amountofexpectedfiles ' , 'qtype_fileresponse ' ),
70+ $ qtype ->attachment_options (),
71+ );
6272 $ mform ->setDefault ('attachments ' , 1 );
6373
6474 /* Attachment required element removed from qtype_essay. */
@@ -68,21 +78,34 @@ protected function definition_inner($mform) {
6878 $ mform ->disabledIf ('filetypeslist ' , 'attachments ' , 'eq ' , 0 );
6979
7080 /* The element to allow or disallow repositories. */
71- $ mform ->addElement ('select ' , 'forcedownload ' ,
72- get_string ('forcedownload ' , 'qtype_fileresponse ' ), $ qtype ->forcedownload_options ());
81+ $ mform ->addElement (
82+ 'select ' ,
83+ 'forcedownload ' ,
84+ get_string ('forcedownload ' , 'qtype_fileresponse ' ),
85+ $ qtype ->forcedownload_options (),
86+ );
7387 $ mform ->setDefault ('forcedownload ' , 0 );
7488
7589 /* The element to allow or disallow repositories. */
76- $ mform ->addElement ('select ' , 'allowpickerplugins ' ,
77- get_string ('allowpickerplugins ' , 'qtype_fileresponse ' ), $ qtype ->allowpickerplugins_options ());
90+ $ mform ->addElement (
91+ 'select ' ,
92+ 'allowpickerplugins ' ,
93+ get_string ('allowpickerplugins ' , 'qtype_fileresponse ' ),
94+ $ qtype ->allowpickerplugins_options ()
95+ );
7896 $ mform ->setDefault ('allowpickerplugins ' , 0 );
7997
8098 /* Response template element removed from qtype_essay. */
8199
82100 $ mform ->addElement ('header ' , 'graderinfoheader ' , get_string ('graderinfoheader ' , 'qtype_fileresponse ' ));
83101 $ mform ->setExpanded ('graderinfoheader ' );
84- $ mform ->addElement ('editor ' , 'graderinfo ' , get_string ('graderinfo ' , 'qtype_fileresponse ' ),
85- array ('rows ' => 10 ), $ this ->editoroptions );
102+ $ mform ->addElement (
103+ 'editor ' ,
104+ 'graderinfo ' ,
105+ get_string ('graderinfo ' , 'qtype_fileresponse ' ),
106+ ['rows ' => 10 ],
107+ $ this ->editoroptions ,
108+ );
86109 }
87110
88111 protected function data_preprocessing ($ question ) {
@@ -103,13 +126,13 @@ protected function data_preprocessing($question) {
103126 $ draftid = file_get_submitted_draft_itemid ('graderinfo ' );
104127 $ question ->graderinfo = array ();
105128 $ question ->graderinfo ['text ' ] = file_prepare_draft_area (
106- $ draftid , // Draftid.
129+ $ draftid , // Draftid.
107130 $ this ->context ->id , // Context.
108- 'qtype_fileresponse ' , // Component.
109- 'graderinfo ' , // Filarea .
131+ 'qtype_fileresponse ' , // Component.
132+ 'graderinfo ' , // Filearea .
110133 !empty ($ question ->id ) ? (int ) $ question ->id : null , // Itemid.
111134 $ this ->fileoptions , // Options.
112- $ question ->options ->graderinfo // Text.
135+ $ question ->options ->graderinfo , // Text.
113136 );
114137 $ question ->graderinfo ['format ' ] = $ question ->options ->graderinfoformat ;
115138 $ question ->graderinfo ['itemid ' ] = $ draftid ;
@@ -128,8 +151,10 @@ public function validation($fromform, $files) {
128151
129152 // Don't allow the teacher to require more attachments than they allow; as this would
130153 // create a condition that it's impossible for the student to meet.
131- if ((isset ($ fromform ['attachmentsrequired ' ])) &&
132- ($ fromform ['attachments ' ] != -1 && $ fromform ['attachments ' ] < $ fromform ['attachmentsrequired ' ])) {
154+ if (
155+ (isset ($ fromform ['attachmentsrequired ' ])) &&
156+ ($ fromform ['attachments ' ] != -1 && $ fromform ['attachments ' ] < $ fromform ['attachmentsrequired ' ])
157+ ) {
133158 $ errors ['attachmentsrequired ' ] = get_string ('mustrequirefewer ' , 'qtype_fileresponse ' );
134159 }
135160
0 commit comments