From 2d2aaf36f33ba95e03850b0450902fc2d36ee395 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Wed, 20 Jul 2016 13:47:00 +0800 Subject: [PATCH] MDL-55284 assign: Add missing webservice param 'onlyids' Mod assign list_participants webservice is supposed to accept a param to limit the returned data to only show user ids and not the full user details. It is missing and so the full user records are fetched every time. This has a major impact on the performance of the new assignment grading interface. --- mod/assign/externallib.php | 6 ++++-- mod/assign/tests/externallib_test.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mod/assign/externallib.php b/mod/assign/externallib.php index f901c307c8a..4c716f0b741 100644 --- a/mod/assign/externallib.php +++ b/mod/assign/externallib.php @@ -2603,11 +2603,12 @@ class mod_assign_external extends external_api { * @param string $filter search string to filter the results. * @param int $skip Number of records to skip * @param int $limit Maximum number of records to return + * @param bool $onlyids Only return user ids. * @return array of warnings and status result * @since Moodle 3.1 * @throws moodle_exception */ - public static function list_participants($assignid, $groupid, $filter, $skip, $limit) { + public static function list_participants($assignid, $groupid, $filter, $skip, $limit, $onlyids) { global $DB, $CFG; require_once($CFG->dirroot . "/mod/assign/locallib.php"); require_once($CFG->dirroot . "/user/lib.php"); @@ -2618,7 +2619,8 @@ class mod_assign_external extends external_api { 'groupid' => $groupid, 'filter' => $filter, 'skip' => $skip, - 'limit' => $limit + 'limit' => $limit, + 'onlyids' => $onlyids )); $warnings = array(); diff --git a/mod/assign/tests/externallib_test.php b/mod/assign/tests/externallib_test.php index ca1e96e4ffc..bac829360e3 100644 --- a/mod/assign/tests/externallib_test.php +++ b/mod/assign/tests/externallib_test.php @@ -2294,7 +2294,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase { $DB->update_record('user', $student); $this->setUser($teacher); - $participants = mod_assign_external::list_participants($assignment->id, 0, '', 0, 0); + $participants = mod_assign_external::list_participants($assignment->id, 0, '', 0, 0, false); $this->assertCount(1, $participants); // Asser that we have a valid response data.