diff --git a/mod/assign/submission/comments/lang/en/assignsubmission_comments.php b/mod/assign/submission/comments/lang/en/assignsubmission_comments.php index fcff40adaaa..d63312b126b 100644 --- a/mod/assign/submission/comments/lang/en/assignsubmission_comments.php +++ b/mod/assign/submission/comments/lang/en/assignsubmission_comments.php @@ -22,6 +22,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +$string['blindmarkingname'] = 'Participant {$a}'; +$string['blindmarkingviewfullname'] = 'Participant {$a->participantnumber} ({$a->participantfullname})'; $string['default'] = 'Enabled by default'; $string['default_help'] = 'If set, this submission method will be enabled by default for all new assignments.'; $string['enabled'] = 'Submission comments'; diff --git a/mod/assign/submission/comments/lib.php b/mod/assign/submission/comments/lib.php index 353204ebf5f..09666b0ca16 100644 --- a/mod/assign/submission/comments/lib.php +++ b/mod/assign/submission/comments/lib.php @@ -131,32 +131,55 @@ function assignsubmission_comments_comment_display($comments, $options) { 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; + // 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]->fullname = fullname($commenter); - $usermappings[$comment->userid]->avatar = $assignment->get_renderer()->user_picture($commenter, - array('size'=>18, 'link' => false)); + // 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; } }