From b48c52b48d33cb5576b69bb363d60ecb5d1ac70f Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Tue, 15 Aug 2017 10:11:51 +0530 Subject: [PATCH] MDL-55937 assign: Check for group submission caps when userid=0 --- mod/assign/locallib.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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. *