MDL-64761 assign: Return grader -1 when hidden in get_submission_status
authorDani Palou <dani@moodle.com>
Mon, 4 Feb 2019 11:28:34 +0000 (12:28 +0100)
committerDani Palou <dani@moodle.com>
Mon, 4 Feb 2019 14:29:47 +0000 (15:29 +0100)
mod/assign/externallib.php
mod/assign/locallib.php

index ad761dc..f567078 100644 (file)
@@ -211,7 +211,7 @@ class mod_assign_external extends external_api {
                 'attemptnumber'     => new external_value(PARAM_INT, 'attempt number'),
                 'timecreated'       => new external_value(PARAM_INT, 'grade creation time'),
                 'timemodified'      => new external_value(PARAM_INT, 'grade last modified time'),
-                'grader'            => new external_value(PARAM_INT, 'grader'),
+                'grader'            => new external_value(PARAM_INT, 'grader, -1 if grader is hidden'),
                 'grade'             => new external_value(PARAM_TEXT, 'grade'),
                 'gradefordisplay'   => new external_value(PARAM_RAW, 'grade rendered into a format suitable for display',
                                                             VALUE_OPTIONAL),
@@ -2383,7 +2383,7 @@ class mod_assign_external extends external_api {
             $result['gradingsummary'] = $gradingsummary;
         }
         // Show the grader's identity if 'Hide Grader' is disabled or has the 'Show Hidden Grader' capability.
-        $showgradername = (has_capability('mod/assign:showhiddengrader', $context, $user) or
+        $showgradername = (has_capability('mod/assign:showhiddengrader', $context) or
             !$assign->is_hidden_grader());
 
         // Did we submit anything?
@@ -2432,7 +2432,7 @@ class mod_assign_external extends external_api {
         if ($feedback) {
             if ($feedback->grade) {
                 if (!$showgradername) {
-                    $feedback->grade->grader = false;
+                    $feedback->grade->grader = -1;
                 }
                 $feedbackplugins = $assign->get_feedback_plugins();
                 $feedback->plugins = self::get_plugins_data($assign, $feedbackplugins, $feedback->grade);
@@ -2473,7 +2473,7 @@ class mod_assign_external extends external_api {
                 if ($grade) {
                     // From object to id.
                     if (!$showgradername) {
-                        $grade->grader = false;
+                        $grade->grader = -1;
                     } else {
                         $grade->grader = $grade->grader->id;
                     }
index 1be55b7..0d74c1e 100644 (file)
@@ -5215,7 +5215,7 @@ class assign {
 
             // 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, $user) or
+                    has_capability('mod/assign:showhiddengrader', $this->context) or
                     !$this->is_hidden_grader()
             );