13
13
//
14
14
// You should have received a copy of the GNU General Public License
15
15
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
+ namespace mod_questionnaire \question ;
17
+ use core_media_manager ;
18
+ use form_filemanager ;
19
+ use mod_questionnaire \responsetype \response \response ;
20
+ use moodle_url ;
21
+ use MoodleQuickForm ;
16
22
17
23
/**
18
24
* This file contains the parent class for text question types.
19
25
*
20
26
* @author Laurent David
27
+ * @author Martin Cornu-Mansuy
28
+ * @copyright 2023 onward CALL Learning <[email protected] >
21
29
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
22
- * @package questiontypes
30
+ * @package mod_questionnaire
23
31
*/
24
-
25
- namespace mod_questionnaire \question ;
26
-
27
- use context_module ;
28
- use core_media_manager ;
29
- use form_filemanager ;
30
- use mod_questionnaire \file_storage ;
31
- use moodle_url ;
32
- use stdClass ;
33
-
34
- defined ('MOODLE_INTERNAL ' ) || die ();
35
-
36
32
class file extends question {
37
33
38
34
/**
35
+ * Get name.
36
+ *
39
37
* @return string
40
38
*/
41
39
public function helpname () {
@@ -61,15 +59,19 @@ public function response_template() {
61
59
}
62
60
63
61
/**
62
+ * Get response class.
63
+ *
64
64
* @return object|string
65
65
*/
66
66
protected function responseclass () {
67
67
return '\\mod_questionnaire \\responsetype \\file ' ;
68
68
}
69
69
70
70
/**
71
- * @param \mod_questionnaire\responsetype\response\response $response
72
- * @param $descendantsdata
71
+ * Survey display output.
72
+ *
73
+ * @param response $response
74
+ * @param object $descendantsdata
73
75
* @param bool $blankquestionnaire
74
76
* @return object|string
75
77
*/
@@ -103,6 +105,11 @@ protected function question_survey_display($response, $descendantsdata, $blankqu
103
105
return $ html ;
104
106
}
105
107
108
+ /**
109
+ * Get file manager options
110
+ *
111
+ * @return array
112
+ */
106
113
private function get_file_manager_option () {
107
114
return [
108
115
'mainfile ' => '' ,
@@ -112,7 +119,9 @@ private function get_file_manager_option() {
112
119
}
113
120
114
121
/**
115
- * @param \mod_questionnaire\responsetype\response\response $response
122
+ * Response display output.
123
+ *
124
+ * @param response $response
116
125
* @return object|string
117
126
*/
118
127
protected function response_survey_display ($ response ) {
@@ -146,11 +155,11 @@ protected function response_survey_display($response) {
146
155
core_media_manager::OPTION_BLOCK => true ,
147
156
);
148
157
149
- if (file_mimetype_in_typegroup ($ mimetype , 'web_image ' )) { // It's an image
158
+ if (file_mimetype_in_typegroup ($ mimetype , 'web_image ' )) { // It's an image.
150
159
$ code = resourcelib_embed_image ($ moodleurl ->out (), $ title );
151
160
152
161
} else if ($ mimetype === 'application/pdf ' ) {
153
- // PDF document
162
+ // PDF document.
154
163
$ code = resourcelib_embed_pdf ($ moodleurl ->out (), $ title , get_string ('view ' ));
155
164
156
165
} else if ($ mediamanager ->can_embed_url ($ moodleurl , $ embedoptions )) {
@@ -161,7 +170,7 @@ protected function response_survey_display($response) {
161
170
// We need a way to discover if we are loading remote docs inside an iframe.
162
171
$ moodleurl ->param ('embed ' , 1 );
163
172
164
- // anything else - just try object tag enlarged as much as possible
173
+ // Anything else - just try object tag enlarged as much as possible.
165
174
$ code = resourcelib_embed_general ($ moodleurl , $ title , get_string ('view ' ), $ mimetype );
166
175
}
167
176
@@ -172,11 +181,25 @@ protected function response_survey_display($response) {
172
181
return $ output ;
173
182
}
174
183
175
- protected function form_length (\MoodleQuickForm $ mform , $ helpname = '' ) {
184
+ /**
185
+ * Add the length element as hidden.
186
+ *
187
+ * @param \MoodleQuickForm $mform
188
+ * @param string $helpname
189
+ * @return \MoodleQuickForm
190
+ */
191
+ protected function form_length (MoodleQuickForm $ mform , $ helpname = '' ) {
176
192
return question::form_length_hidden ($ mform );
177
193
}
178
194
179
- protected function form_precise (\MoodleQuickForm $ mform , $ helpname = '' ) {
195
+ /**
196
+ * Add the precise element as hidden.
197
+ *
198
+ * @param \MoodleQuickForm $mform
199
+ * @param string $helpname
200
+ * @return \MoodleQuickForm
201
+ */
202
+ protected function form_precise (MoodleQuickForm $ mform , $ helpname = '' ) {
180
203
return question::form_precise_hidden ($ mform );
181
204
}
182
205
0 commit comments