diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 72bcf376bec..5c7bbfd5bf5 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -2831,7 +2831,12 @@ class assign { $item = $this->get_submission($submissionid); // Check permissions. - $this->require_view_submission($item->userid); + if (empty($item->userid)) { + // Group submission. + $this->require_view_group_submission($item->groupid); + } else { + $this->require_view_submission($item->userid); + } $o .= $this->get_renderer()->render(new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), @@ -3026,6 +3031,18 @@ class assign { return ''; } + /** + * Throw an error if the permissions to view this users' group submission are missing. + * + * @param int $groupid Group id. + * @throws required_capability_exception + */ + public function require_view_group_submission($groupid) { + if (!$this->can_view_group_submission($groupid)) { + throw new required_capability_exception($this->context, 'mod/assign:viewgrades', 'nopermission', ''); + } + } + /** * Throw an error if the permissions to view this users submission are missing. *