Skip to content

Commit 570275e

Browse files
committed
Fix issues that got lost with the last rebase
1 parent b18321e commit 570275e

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

classes/question/file.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,22 @@ protected function question_survey_display($response, $descendantsdata, $blankqu
8686
} else {
8787
$draftitemid = file_get_submitted_draft_itemid($elname);
8888
}
89-
$options = self::get_file_manager_option();
9089
if ($draftitemid > 0) {
91-
file_prepare_draft_area($draftitemid, $this->context->id, 'mod_questionnaire', 'file', $this->id, $options);
90+
file_prepare_draft_area($draftitemid, $this->context->id,
91+
'mod_questionnaire', 'file', $this->id, self::get_file_manager_option());
9292
} else {
9393
$draftitemid = file_get_unused_draft_itemid();
9494
}
9595
// Filemanager form element implementation is far from optimal, we need to rework this if we ever fix it...
9696
require_once("$CFG->dirroot/lib/form/filemanager.php");
9797

98-
$options->client_id = uniqid();
99-
$options->itemid = $draftitemid;
100-
$options->target = $this->id;
101-
$options->name = $elname;
102-
$fm = new form_filemanager($options);
98+
$options = array_merge(self::get_file_manager_option(), [
99+
'client_id' => uniqid(),
100+
'itemid' => $draftitemid,
101+
'target' => $this->id,
102+
'name' => $elname,
103+
]);
104+
$fm = new form_filemanager((object)$options);
103105
$output = $PAGE->get_renderer('core', 'files');
104106

105107
$html = '<div class="form-filemanager" data-fieldtype="filemanager">' .
@@ -141,12 +143,12 @@ public function response_complete($responsedata) {
141143
* @return array
142144
*/
143145
public static function get_file_manager_option() {
144-
$options = new \stdClass();
145-
$options->mainfile = '';
146-
$options->subdirs = false;
147-
$options->accepted_types = ['image', '.pdf'];
148-
$options->maxfiles = 1;
149-
return $options;
146+
return [
147+
'mainfile' => '',
148+
'subdirs' => false,
149+
'accepted_types' => ['image', '.pdf'],
150+
'maxfiles' => 1,
151+
];
150152
}
151153

152154
/**

tests/responsetypes_test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
namespace mod_questionnaire;
1818

19+
defined('MOODLE_INTERNAL') || die();
20+
1921
global $CFG;
2022
require_once($CFG->dirroot.'/mod/questionnaire/locallib.php');
2123
require_once($CFG->dirroot . '/mod/questionnaire/tests/generator_test.php');

0 commit comments

Comments
 (0)