MDL-37710 Assign: Fix pluginfile permission checks for student viewing their own team submission.

This change adds a function to the assign class to allow the permissions for a group submission
to be checked and updates all the submission plugins to call it.
This commit is contained in:
Damyon Wiese 2013-01-29 16:07:08 +08:00
parent cbb26eb0ec
commit 3e1b63f1c8
4 changed files with 62 additions and 29 deletions

View file

@ -2784,6 +2784,30 @@ class assign {
return false;
}
/**
* Perform an access check to see if the current $USER can view this group submission.
*
* @param int $groupid
* @return bool
*/
public function can_view_group_submission($groupid) {
global $USER;
if (!is_enrolled($this->get_course_context(), $USER->id)) {
return false;
}
if (has_capability('mod/assign:grade', $this->context)) {
return true;
}
$members = $this->get_submission_group_members($groupid, true);
foreach ($members as $member) {
if ($member->id == $USER->id) {
return true;
}
}
return false;
}
/**
* Perform an access check to see if the current $USER can view this users submission.
*