diff --git a/comment/lib.php b/comment/lib.php
index 9ca0a41..3622234 100644
--- a/comment/lib.php
+++ b/comment/lib.php
@@ -532,6 +532,7 @@ class comment {
             $c->fullname = fullname($u);
             $c->content = format_text($c->content, $c->format, $formatoptions);
             $c->avatar = $OUTPUT->user_picture($u, array('size'=>18));
+            $c->userid = $u->id;
 
             $candelete = $this->can_delete($c->id);
             if (($USER->id == $u->id) || !empty($candelete)) {
diff --git a/mod/assign/submission/comments/lib.php b/mod/assign/submission/comments/lib.php
index 5509350..9a2e97c 100644
--- a/mod/assign/submission/comments/lib.php
+++ b/mod/assign/submission/comments/lib.php
@@ -107,6 +107,72 @@ function assignsubmission_comments_comment_permissions(stdClass $options) {
 }
 
 /**
+ * Callback called by comment::get_comments() and comment::add(). Gives an opportunity to enforce blind-marking.
+ *
+ * @param array $comments
+ * @param stdClass $options
+ * @return array
+ * @throws comment_exception
+ */
+function assignsubmission_comments_comment_display($comments, $options) {
+    global $CFG, $DB, $USER, $OUTPUT;
+
+    if ($options->commentarea != 'submission_comments' &&
+        $options->commentarea != 'submission_comments_upgrade') {
+        throw new comment_exception('invalidcommentarea');
+    }
+    if (!$submission = $DB->get_record('assign_submission', array('id'=>$options->itemid))) {
+        throw new comment_exception('invalidcommentitemid');
+    }
+    $context = $options->context;
+    $cm = $options->cm;
+    $course = $options->courseid;
+
+    require_once($CFG->dirroot . '/mod/assign/locallib.php');
+    $assignment = new assign($context, $cm, $course);
+
+    if ($assignment->get_instance()->id != $submission->assignment) {
+        throw new comment_exception('invalidcontext');
+    }
+
+    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();
+
+        foreach ($comments as $comment) {
+            if (($USER->id != $comment->userid) && !has_capability('mod/assign:grade', $assignment->get_context(), $comment->userid)) {
+                // Anonymize if the logged in user is not the commenter and the commenter does not have the grading capability.
+                if (empty($usermappings[$comment->userid])) {
+                    // The blind-marking information for this commenter has not been generated; do so now.
+                    $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 = $OUTPUT->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;
+            }
+        }
+    }
+
+    return $comments;
+}
+
+/**
  * Callback to force the userid for all comments to be the userid of the submission and NOT the global $USER->id. This
  * is required by the upgrade code. Note the comment area is used to identify upgrades.
  *
diff --git a/mod/assign/submission/comments/locallib.php b/mod/assign/submission/comments/locallib.php
index 4c4b0c7..fe09853 100644
--- a/mod/assign/submission/comments/locallib.php
+++ b/mod/assign/submission/comments/locallib.php
@@ -169,17 +169,4 @@ class assign_submission_comments extends assign_submission_plugin {
     public function allow_submissions() {
         return false;
     }
-
-    /**
-     * If blind marking is enabled then disable this plugin (it shows names)
-     *
-     * @return bool
-     */
-    public function is_enabled() {
-        if ($this->assignment->has_instance() && $this->assignment->is_blind_marking()) {
-            return false;
-        }
-        return parent::is_enabled();
-    }
-
 }
