Skip to content

Commit

Permalink
Update version to 2023101500.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Apr 4, 2024
1 parent 10a7ac8 commit 85ebdb3
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: plugin

Expand Down
4 changes: 4 additions & 0 deletions classes/feedback_section_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
require_once($CFG->libdir . '/formslib.php');
require_once($CFG->dirroot.'/mod/questionnaire/lib.php');

#[\AllowDynamicProperties]
/**
* Print the form to add or edit a questionnaire-instance
*
Expand All @@ -38,6 +39,9 @@ class feedback_section_form extends \moodleform {
*/
public $context;

/** @var int $sid The section id. */
protected $sid;

/**
* Form definition.
*/
Expand Down
77 changes: 40 additions & 37 deletions classes/question/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,44 +136,47 @@ protected function response_survey_display($response) {
$fs = get_file_storage();
$file = $fs->get_file_by_id($answer->value);

$moodleurl = moodle_url::make_pluginfile_url(
$file->get_contextid(),
$file->get_component(),
$file->get_filearea(),
$file->get_itemid(),
$file->get_filepath(),
$file->get_filename());

$mimetype = $file->get_mimetype();
$title = '';

$extension = resourcelib_get_extension($file->get_filename());

$mediamanager = core_media_manager::instance($PAGE);
$embedoptions = array(
core_media_manager::OPTION_TRUSTED => true,
core_media_manager::OPTION_BLOCK => true,
);

if (file_mimetype_in_typegroup($mimetype, 'web_image')) { // It's an image.
$code = resourcelib_embed_image($moodleurl->out(), $title);

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

} else if ($mediamanager->can_embed_url($moodleurl, $embedoptions)) {
// Media (audio/video) file.
$code = $mediamanager->embed_url($moodleurl, $title, 0, 0, $embedoptions);

} else {
// We need a way to discover if we are loading remote docs inside an iframe.
$moodleurl->param('embed', 1);

// Anything else - just try object tag enlarged as much as possible.
$code = resourcelib_embed_general($moodleurl, $title, get_string('view'), $mimetype);
if ($file) {
// There is a file.
$moodleurl = moodle_url::make_pluginfile_url(
$file->get_contextid(),
$file->get_component(),
$file->get_filearea(),
$file->get_itemid(),
$file->get_filepath(),
$file->get_filename()
);

$mimetype = $file->get_mimetype();
$title = '';

$extension = resourcelib_get_extension($file->get_filename());

$mediamanager = core_media_manager::instance($PAGE);
$embedoptions = array(
core_media_manager::OPTION_TRUSTED => true,
core_media_manager::OPTION_BLOCK => true,
);

if (file_mimetype_in_typegroup($mimetype, 'web_image')) { // It's an image.
$code = resourcelib_embed_image($moodleurl->out(), $title);

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

} else if ($mediamanager->can_embed_url($moodleurl, $embedoptions)) {
// Media (audio/video) file.
$code = $mediamanager->embed_url($moodleurl, $title, 0, 0, $embedoptions);

} else {
// We need a way to discover if we are loading remote docs inside an iframe.
$moodleurl->param('embed', 1);

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

$output = '';
$output .= '<div class="response text">';
$output .= $code;
Expand Down
33 changes: 18 additions & 15 deletions classes/responsetype/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,23 +259,26 @@ public function get_results_tags($weights, $participants, $respondents, $showtot
$fs = get_file_storage();
$file = $fs->get_file_by_id($row->fileid);

$imageurl = moodle_url::make_pluginfile_url(
$file->get_contextid(),
$file->get_component(),
$file->get_filearea(),
$file->get_itemid(),
$file->get_filepath(),
$file->get_filename());
if ($file) {
// There is a file.
$imageurl = moodle_url::make_pluginfile_url(
$file->get_contextid(),
$file->get_component(),
$file->get_filearea(),
$file->get_itemid(),
$file->get_filepath(),
$file->get_filename());

$response->text = \html_writer::link($imageurl, $file->get_filename());
if ($viewsingleresponse && $nonanonymous) {
$rurl = $url . '&amp;rid=' . $row->rid . '&amp;individualresponse=1';
$title = userdate($row->submitted);
if (!isset($users[$row->userid])) {
$users[$row->userid] = $DB->get_record('user', ['id' => $row->userid]);
$response->text = \html_writer::link($imageurl, $file->get_filename());
if ($viewsingleresponse && $nonanonymous) {
$rurl = $url . '&amp;rid=' . $row->rid . '&amp;individualresponse=1';
$title = userdate($row->submitted);
if (!isset($users[$row->userid])) {
$users[$row->userid] = $DB->get_record('user', ['id' => $row->userid]);
}
$response->respondent =
'<a href="' . $rurl . '" title="' . $title . '">' . fullname($users[$row->userid]) . '</a>';
}
$response->respondent =
'<a href="' . $rurl . '" title="' . $title . '">' . fullname($users[$row->userid]) . '</a>';
} else {
$response->respondent = '';
}
Expand Down
1 change: 0 additions & 1 deletion questionnaire.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* @author Mike Churchward
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
#[AllowDynamicProperties]
class questionnaire {

// Class Properties.
Expand Down
7 changes: 3 additions & 4 deletions tests/behat/behat_mod_questionnaire.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@
use Behat\Behat\Context\Step\Given as Given,
Behat\Behat\Context\Step\When as When,
Behat\Gherkin\Node\TableNode as TableNode,
Behat\Mink\Exception\ExpectationException as ExpectationException;
Behat\Mink\Exception\ExpectationException as ExpectationException,
Behat\Mink\Element\NodeElement,
Behat\Mink\Exception\DriverException;

#[\AllowDynamicProperties]
use Behat\Mink\Element\NodeElement;
use Behat\Mink\Exception\DriverException;

/**
* Questionnaire-related steps definitions.
*
Expand Down

0 comments on commit 85ebdb3

Please sign in to comment.