MDL-64507 mod_assign: check grader visibility for previous submissions.
authorDan Marsden <dan@danmarsden.com>
Sun, 13 Jan 2019 21:06:29 +0000 (10:06 +1300)
committerDan Marsden <dan@danmarsden.com>
Wed, 6 Feb 2019 23:14:56 +0000 (12:14 +1300)
mod/assign/locallib.php

index c2c9e18..cd9f4c1 100644 (file)
@@ -5422,6 +5422,12 @@ class assign {
         $gradercache = array();
         $cangrade = has_capability('mod/assign:grade', $this->get_context());
 
+        // Show the grader's identity if 'Hide Grader' is disabled or has the 'Show Hidden Grader' capability.
+        $showgradername = (
+            has_capability('mod/assign:showhiddengrader', $this->context, $userid) or
+            !$this->is_hidden_grader()
+        );
+
         // Need gradingitem and gradingmanager.
         $gradingmanager = get_grading_manager($this->get_context(), 'mod_assign', 'submissions');
         $controller = $gradingmanager->get_active_controller();
@@ -5439,7 +5445,9 @@ class assign {
 
         foreach ($grades as $grade) {
             // First lookup the grader info.
-            if (isset($gradercache[$grade->grader])) {
+            if (!$showgradername) {
+                $grade->grader = null;
+            } else if (isset($gradercache[$grade->grader])) {
                 $grade->grader = $gradercache[$grade->grader];
             } else if ($grade->grader > 0) {
                 // Not in cache - need to load the grader record.