-
Bug
-
Resolution: Fixed
-
Minor
-
3.3
-
MOODLE_33_STABLE
-
MOODLE_32_STABLE, MOODLE_33_STABLE
-
MDL-59195_assign_comment_permissions -
Hi there,
we encountered a bug with the "switch role to" feature together with assignments that can be submitted in group mode.
- Steps to reproduce:
- Login as teacher in a course and turn editing on
- Create a new assignment activity, enter a title and just set the following option in the section Group submission settings: Students submit in groups: Yes.
- Save and return to course
- Switch role to...: Student
- Click on the newly added assignment
Result:
It opens a page with broken CSS with the error message: You can't add comments:
This also happens if you create a group and enrole yourself as a teacher in this group and also if setting Require group to make submission is set to yes.
- Cause:
In the function assignsubmission_comments_comment_validate() in mod/assign/submission/comments/lib.php we ran into this error:66 if (!$canview) {
67 throw new comment_exception('nopermissiontocomment');
68 }
The cause is that $canview will be false because the teacher will never be added as a submitting member for an assignment in the called line $canview = $assignment->can_view_submission($submission->userid);
Here's the corresponding code:
mod/assign/locallib.php:4367 public function can_view_group_submission($groupid) {
4368 global $USER;
4369
4370 $members = $this->get_submission_group_members($groupid, true);
4371 foreach ($members as $member) {
4372 if($member->id == 11964) {
4373 error_log($member->id);
4374 error_log("Can view submission: " . $this->can_view_submission($member->id));
4375 }
4376 // If we can view any members submission, we can view the submission for the group.
4377 if ($this->can_view_submission($member->id)) {
4378 return true;
4379 }
4380 }
4381 return false;
4382 }