Skip to content

Commit a067434

Browse files
laurentdavidsrobotta
authored andcommitted
Further fixes:
* Fix file cs issues * Fix behat test for file
1 parent 19335bf commit a067434

File tree

4 files changed

+201
-189
lines changed

4 files changed

+201
-189
lines changed

classes/question/file.php

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,27 @@
1313
//
1414
// You should have received a copy of the GNU General Public License
1515
// 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;
1622

1723
/**
1824
* This file contains the parent class for text question types.
1925
*
2026
* @author Laurent David
27+
* @author Martin Cornu-Mansuy
28+
* @copyright 2023 onward CALL Learning <[email protected]>
2129
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
22-
* @package questiontypes
30+
* @package mod_questionnaire
2331
*/
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-
3632
class file extends question {
3733

3834
/**
35+
* Get name.
36+
*
3937
* @return string
4038
*/
4139
public function helpname() {
@@ -61,15 +59,19 @@ public function response_template() {
6159
}
6260

6361
/**
62+
* Get response class.
63+
*
6464
* @return object|string
6565
*/
6666
protected function responseclass() {
6767
return '\\mod_questionnaire\\responsetype\\file';
6868
}
6969

7070
/**
71-
* @param \mod_questionnaire\responsetype\response\response $response
72-
* @param $descendantsdata
71+
* Survey display output.
72+
*
73+
* @param response $response
74+
* @param object $descendantsdata
7375
* @param bool $blankquestionnaire
7476
* @return object|string
7577
*/
@@ -103,6 +105,11 @@ protected function question_survey_display($response, $descendantsdata, $blankqu
103105
return $html;
104106
}
105107

108+
/**
109+
* Get file manager options
110+
*
111+
* @return array
112+
*/
106113
private function get_file_manager_option() {
107114
return [
108115
'mainfile' => '',
@@ -112,7 +119,9 @@ private function get_file_manager_option() {
112119
}
113120

114121
/**
115-
* @param \mod_questionnaire\responsetype\response\response $response
122+
* Response display output.
123+
*
124+
* @param response $response
116125
* @return object|string
117126
*/
118127
protected function response_survey_display($response) {
@@ -146,11 +155,11 @@ protected function response_survey_display($response) {
146155
core_media_manager::OPTION_BLOCK => true,
147156
);
148157

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.
150159
$code = resourcelib_embed_image($moodleurl->out(), $title);
151160

152161
} else if ($mimetype === 'application/pdf') {
153-
// PDF document
162+
// PDF document.
154163
$code = resourcelib_embed_pdf($moodleurl->out(), $title, get_string('view'));
155164

156165
} else if ($mediamanager->can_embed_url($moodleurl, $embedoptions)) {
@@ -161,7 +170,7 @@ protected function response_survey_display($response) {
161170
// We need a way to discover if we are loading remote docs inside an iframe.
162171
$moodleurl->param('embed', 1);
163172

164-
// anything else - just try object tag enlarged as much as possible
173+
// Anything else - just try object tag enlarged as much as possible.
165174
$code = resourcelib_embed_general($moodleurl, $title, get_string('view'), $mimetype);
166175
}
167176

@@ -172,11 +181,25 @@ protected function response_survey_display($response) {
172181
return $output;
173182
}
174183

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 = '') {
176192
return question::form_length_hidden($mform);
177193
}
178194

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 = '') {
180203
return question::form_precise_hidden($mform);
181204
}
182205

0 commit comments

Comments
 (0)