mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
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:
parent
cbb26eb0ec
commit
3e1b63f1c8
4 changed files with 62 additions and 29 deletions
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue