if ($assignment->is_blind_marking() && !empty($comments)) {
// Blind marking is being used, may need to map unique anonymous ids to the comments.
$usermappings = array();
- $hiddenuserstr = trim(get_string('hiddenuser', 'assign'));
$guestuser = guest_user();
+ // Check group users first.
+ $userinteam = false;
+ if ($assignment->get_instance()->teamsubmission && has_capability('mod/assign:submit', $context)) {
+ $assignment->set_course(get_course($course));
+ $userinteam = $assignment->can_edit_group_submission($submission->groupid);
+ }
+
foreach ($comments as $comment) {
- // Anonymize the comments.
- if (empty($usermappings[$comment->userid])) {
- // The blind-marking information for this commenter has not been generated; do so now.
+
+ if (has_capability('mod/assign:viewblinddetails', $context) && $USER->id != $comment->userid) {
$anonid = $assignment->get_uniqueid_for_user($comment->userid);
- $commenter = new stdClass();
- $commenter->firstname = $hiddenuserstr;
- $commenter->lastname = $anonid;
- $commenter->picture = 0;
- $commenter->id = $guestuser->id;
- $commenter->email = $guestuser->email;
- $commenter->imagealt = $guestuser->imagealt;
-
- // Temporarily store blind-marking information for use in later comments if necessary.
- $usermappings[$comment->userid]->fullname = fullname($commenter);
- $usermappings[$comment->userid]->avatar = $assignment->get_renderer()->user_picture($commenter,
- array('size'=>18, 'link' => false));
+ // Show participant information and the user's full name to users with the view blind details capability.
+ $a = new stdClass();
+ $a->participantnumber = $anonid;
+ $a->participantfullname = $comment->fullname;
+ $comment->fullname = get_string('blindmarkingviewfullname', 'assignsubmission_comments', $a);
+ } else if ($USER->id == $comment->userid || $submission->userid == $USER->id || $userinteam) { //@codingStandardsIgnoreLine
+ // Do not anonymize the user details for this comment.
+ } else {
+ // Anonymize the comments.
+ if (empty($usermappings[$comment->userid])) {
+ $anonid = $assignment->get_uniqueid_for_user($comment->userid);
+ // The blind-marking information for this commenter has not been generated; do so now.
+ $commenter = new stdClass();
+ $commenter->firstname = get_string('blindmarkingname', 'assignsubmission_comments', $anonid);
+ $commenter->lastname = '';
+ $commenter->firstnamephonetic = '';
+ $commenter->lastnamephonetic = '';
+ $commenter->middlename = '';
+ $commenter->alternatename = '';
+ $commenter->picture = 0;
+ $commenter->id = $guestuser->id;
+ $commenter->email = $guestuser->email;
+ $commenter->imagealt = $guestuser->imagealt;
+
+ // Temporarily store blind-marking information for use in later comments if necessary.
+ $usermappings[$comment->userid] = new stdClass();
+ $usermappings[$comment->userid]->fullname = fullname($commenter);
+ $usermappings[$comment->userid]->avatar = $assignment->get_renderer()->user_picture($commenter,
+ array('size' => 18, 'link' => false));
+ }
+
+ // Set blind-marking information for this comment.
+ $comment->fullname = $usermappings[$comment->userid]->fullname;
+ $comment->avatar = $usermappings[$comment->userid]->avatar;
+ $comment->profileurl = null;
}
-
- // Set blind-marking information for this comment.
- $comment->fullname = $usermappings[$comment->userid]->fullname;
- $comment->avatar = $usermappings[$comment->userid]->avatar;
- $comment->profileurl = null;
}
}