MDL-27508 workshop checks separate groups membership when displaying a submission

This commit is contained in:
David Mudrak
2012-04-27 14:41:58 +02:00
parent a4e848360d
commit f65bc55fcd
+15
View File
@@ -87,6 +87,21 @@ if ($submission->id and !$workshop->modifying_submission_allowed($USER->id)) {
$editable = false;
}
if ($canviewall) {
// check this flag against the group membership yet
if (groups_get_activity_groupmode($workshop->cm) == SEPARATEGROUPS) {
// user must have accessallgroups or share at least one group with the submission author
if (!has_capability('moodle/site:accessallgroups', $workshop->context)) {
$usersgroups = groups_get_activity_allowed_groups($workshop->cm);
$authorsgroups = groups_get_all_groups($workshop->course->id, $submission->authorid, $workshop->cm->groupingid, 'g.id');
$sharedgroups = array_intersect_key($usersgroups, $authorsgroups);
if (empty($sharedgroups)) {
$canviewall = false;
}
}
}
}
if ($editable and $workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_SUBMISSION
and !has_capability('mod/workshop:manageexamples', $workshop->context)) {
// check that all required examples have been assessed by the user