Skip to content

Commit

Permalink
Fix issues that got lost with the last rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
srobotta committed Aug 26, 2024
1 parent cf57ff1 commit 498f149
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 15 additions & 13 deletions classes/question/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,22 @@ protected function question_survey_display($response, $descendantsdata, $blankqu
} else {
$draftitemid = file_get_submitted_draft_itemid($elname);
}
$options = self::get_file_manager_option();
if ($draftitemid > 0) {
file_prepare_draft_area($draftitemid, $this->context->id, 'mod_questionnaire', 'file', $this->id, $options);
file_prepare_draft_area($draftitemid, $this->context->id,
'mod_questionnaire', 'file', $this->id, self::get_file_manager_option());
} else {
$draftitemid = file_get_unused_draft_itemid();
}
// Filemanager form element implementation is far from optimal, we need to rework this if we ever fix it...
require_once("$CFG->dirroot/lib/form/filemanager.php");

$options->client_id = uniqid();
$options->itemid = $draftitemid;
$options->target = $this->id;
$options->name = $elname;
$fm = new form_filemanager($options);
$options = array_merge(self::get_file_manager_option(), [
'client_id' => uniqid(),
'itemid' => $draftitemid,
'target' => $this->id,
'name' => $elname,
]);
$fm = new form_filemanager((object)$options);
$output = $PAGE->get_renderer('core', 'files');

$html = '<div class="form-filemanager" data-fieldtype="filemanager">' .
Expand Down Expand Up @@ -141,12 +143,12 @@ public function response_complete($responsedata) {
* @return array
*/
public static function get_file_manager_option() {
$options = new \stdClass();
$options->mainfile = '';
$options->subdirs = false;
$options->accepted_types = ['image', '.pdf'];
$options->maxfiles = 1;
return $options;
return [
'mainfile' => '',
'subdirs' => false,
'accepted_types' => ['image', '.pdf'],
'maxfiles' => 1,
];
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/responsetypes_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace mod_questionnaire;

defined('MOODLE_INTERNAL') || die();

global $CFG;
require_once($CFG->dirroot.'/mod/questionnaire/locallib.php');
require_once($CFG->dirroot . '/mod/questionnaire/tests/generator_test.php');
Expand Down

0 comments on commit 498f149

Please sign in to comment.