mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
MDL-79980 mod_survey: remove responses link if user cannot access.
Update Behat scenario to match.
This commit is contained in:
parent
76c940134c
commit
f188214e7e
@ -814,10 +814,19 @@ function survey_supports($feature) {
|
||||
*/
|
||||
function survey_extend_settings_navigation(settings_navigation $settings, navigation_node $surveynode) {
|
||||
global $DB;
|
||||
if (has_capability('mod/survey:readresponses', $settings->get_page()->cm->context)) {
|
||||
$cm = get_coursemodule_from_id('survey', $settings->get_page()->cm->id);
|
||||
|
||||
$cm = get_coursemodule_from_id('survey', $settings->get_page()->cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
// Check to see if groups are being used in this survey, confirm user can access.
|
||||
$groupmode = groups_get_activity_groupmode($cm);
|
||||
$currentgroup = groups_get_activity_group($cm, true);
|
||||
|
||||
if (has_capability('mod/survey:readresponses', $context) &&
|
||||
!($currentgroup === 0 && $groupmode == SEPARATEGROUPS && !has_capability('moodle/site:accessallgroups', $context))) {
|
||||
|
||||
$survey = $DB->get_record("survey", ["id" => $cm->instance]);
|
||||
$url = new moodle_url('/mod/survey/report.php', ['id' => $settings->get_page()->cm->id]);
|
||||
$url = new moodle_url('/mod/survey/report.php', ['id' => $cm->id]);
|
||||
if ($survey && ($survey->template != SURVEY_CIQ)) {
|
||||
$url->param('action', 'summary');
|
||||
} else {
|
||||
|
@ -76,7 +76,10 @@ Feature: Viewing response reports by group
|
||||
| survey | user | all | G1 | G2 | user1 | user2 | user3 | user4 |
|
||||
| survey1 | teacher1 | should | should | should | should | should | should | should |
|
||||
| survey1 | noneditor1 | should not | should | should not | should | should not | should not | should not |
|
||||
| survey1 | noneditor2 | should | should not | should not | should | should | should | should |
|
||||
| survey2 | teacher1 | should | should | should | should | should | should | should |
|
||||
| survey2 | noneditor1 | should | should | should | should | should not | should not | should not |
|
||||
| survey2 | noneditor2 | should | should | should | should | should not | should not | should not |
|
||||
|
||||
Scenario: Non-editing teacher without access to any groups should not see survey results in separate groups mode
|
||||
Given I am on the "survey1" "survey activity" page logged in as "noneditor2"
|
||||
Then I should not see "Response reports"
|
||||
|
Loading…
x
Reference in New Issue
Block a user