Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
matrix:
include:
- php: '8.4'
moodle-branch: 'main'
moodle-branch: 'MOODLE_502_STABLE'
database: 'mariadb'
- php: '8.4'
moodle-branch: 'MOODLE_501_STABLE'
Expand Down
4 changes: 4 additions & 0 deletions questionnaire.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,10 @@ public function view_response(
$currentgroupid = 0,
$outputtarget = 'html'
) {
if (!$this->can_view_response($rid)) {
throw new \moodle_exception('nopermissions', 'mod_questionnaire');
}

$this->print_survey_start('', 1, 1, 0, $rid, false, $outputtarget);

$i = 0;
Expand Down
8 changes: 5 additions & 3 deletions report.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@

// If you can't view the questionnaire, or can't view a specified response, error out.
$context = context_module::instance($cm->id);
if (!$questionnaire->can_view_all_responses(null, true) && !$individualresponse) {
// Should never happen, unless called directly by a snoop...
if (
!$questionnaire->can_view_all_responses(null, true) &&
!($individualresponse && $questionnaire->can_view_response($rid))
) {
throw new \moodle_exception('nopermissions', 'mod_questionnaire');
}

Expand Down Expand Up @@ -903,7 +905,7 @@
if ($outputtarget == 'html') {
$questionnaire->survey_results_navbar_alpha($rid, $currentgroupid, $cm, $byresponse);
}
if (!$byresponse) { // Show respondents individual responses.
if (!$byresponse && $questionnaire->can_view_response($rid)) { // Show respondents individual responses.
$questionnaire->view_response($rid, '', $resps, true, true, false, $currentgroupid, $outputtarget);
}
echo $questionnaire->renderer->header();
Expand Down
5 changes: 2 additions & 3 deletions tests/custom_completion_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,12 @@ public function test_get_available_custom_rules(int $status, array $expected): v
// Build a mock cm_info instance.
$mockcminfo = $this->getMockBuilder(cm_info::class)
->disableOriginalConstructor()
->onlyMethods(['__get'])
->onlyMethods(['get_custom_data'])
->getMock();

// Mock the return of magic getter for the customdata attribute.
$mockcminfo->expects($this->any())
->method('__get')
->with('customdata')
->method('get_custom_data')
->willReturn($customdataval);

$customcompletion = new custom_completion($mockcminfo, 1);
Expand Down
Loading