MDL-57999 grades: Add itemname to gradereport_user_get_grade_items
authorZoe Bogner <zoe.bogner@flinders.edu.au>
Tue, 28 Feb 2017 07:12:52 +0000 (17:42 +1030)
committerZoe Bogner <zoe.bogner@flinders.edu.au>
Tue, 28 Feb 2017 10:59:59 +0000 (21:29 +1030)
grade/report/user/externallib.php
grade/report/user/lib.php
grade/report/user/tests/externallib_test.php

index d002d00..5d7bbb6 100644 (file)
@@ -483,6 +483,7 @@ class gradereport_user_external extends external_api {
                                 new external_single_structure(
                                     array(
                                         'id' => new external_value(PARAM_INT, 'Grade item id'),
+                                        'itemname' => new external_value(PARAM_TEXT, 'Grade item name'),
                                         'itemtype' => new external_value(PARAM_ALPHA, 'Grade item type'),
                                         'itemmodule' => new external_value(PARAM_PLUGIN, 'Grade item module'),
                                         'iteminstance' => new external_value(PARAM_INT, 'Grade item instance'),
index 9f751fa..ea40100 100644 (file)
@@ -512,6 +512,7 @@ class grade_report_user extends grade_report {
 
                 // Basic grade item information.
                 $gradeitemdata['id'] = $grade_object->id;
+                $gradeitemdata['itemname'] = $grade_object->itemname;
                 $gradeitemdata['itemtype'] = $grade_object->itemtype;
                 $gradeitemdata['itemmodule'] = $grade_object->itemmodule;
                 $gradeitemdata['iteminstance'] = $grade_object->iteminstance;
index 02c79e4..e751434 100644 (file)
@@ -251,6 +251,7 @@ class gradereport_user_externallib_testcase extends externallib_advanced_testcas
         $this->assertEquals($course->id, $studentgrades['usergrades'][0]['courseid']);
         $this->assertEquals($student1->id, $studentgrades['usergrades'][0]['userid']);
         // Module grades.
+        $this->assertEquals($assignment->name, $studentgrades['usergrades'][0]['gradeitems'][0]['itemname']);
         $this->assertEquals('mod', $studentgrades['usergrades'][0]['gradeitems'][0]['itemtype']);
         $this->assertEquals('assign', $studentgrades['usergrades'][0]['gradeitems'][0]['itemmodule']);
         $this->assertEquals($assignment->id, $studentgrades['usergrades'][0]['gradeitems'][0]['iteminstance']);
@@ -325,6 +326,7 @@ class gradereport_user_externallib_testcase extends externallib_advanced_testcas
 
         $this->assertEquals($course->id, $studentgrades['usergrades'][0]['courseid']);
         $this->assertEquals($student1->id, $studentgrades['usergrades'][0]['userid']);
+        $this->assertEquals($assignment->name, $studentgrades['usergrades'][0]['gradeitems'][0]['itemname']);
         $this->assertEquals('mod', $studentgrades['usergrades'][0]['gradeitems'][0]['itemtype']);
         $this->assertEquals('assign', $studentgrades['usergrades'][0]['gradeitems'][0]['itemmodule']);
         $this->assertEquals($assignment->id, $studentgrades['usergrades'][0]['gradeitems'][0]['iteminstance']);