Skip to content

Commit

Permalink
MDL-79980 mod_survey: respect activity group mode getting report.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden authored and junpataleta committed Dec 7, 2023
1 parent f764c33 commit d1ccb87
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mod/survey/report.php
Expand Up @@ -106,9 +106,16 @@
echo $renderer->response_actionbar($actionbar);

// Check to see if groups are being used in this survey.
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
$groupmode = groups_get_activity_groupmode($cm);
if ($groupmode != NOGROUPS) {
$menuaction = $action == "student" ? "students" : $action;

// Get the current activity group, confirm user can access.
$currentgroup = groups_get_activity_group($cm, true);
if ($currentgroup === 0 && $groupmode == SEPARATEGROUPS && !has_capability('moodle/site:accessallgroups', $context)) {
throw new moodle_exception('notingroup');
}

$groupsactivitymenu = groups_print_activity_menu($cm, new moodle_url('/mod/survey/report.php',
['id' => $cm->id, 'action' => $menuaction, 'qid' => $qid]), true);
} else {
Expand Down Expand Up @@ -365,8 +372,9 @@
break;

case "student":
if (!$user = $DB->get_record("user", array("id" => $student))) {
throw new moodle_exception('invaliduserid');
$user = core_user::get_user($student, '*', MUST_EXIST);
if ($currentgroup && !array_key_exists($user->id, $users)) {
throw new moodle_exception('usernotavailable', 'error');
}

echo $OUTPUT->heading(get_string("analysisof", "survey", fullname($user)), 3);
Expand Down

0 comments on commit d1ccb87

Please sign in to comment.