From b0487262ec39b460feaeb2b72fad6f1f9ebd84b3 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Fri, 15 Mar 2019 09:44:51 +0800 Subject: [PATCH] MDL-65078 competencies: fix webservice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The webservice list_course_module_competencies calls a function that does not exist. Thanks to Marie-Eve Lévesque for reporting this issue. --- competency/classes/api.php | 2 +- competency/tests/api_test.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/competency/classes/api.php b/competency/classes/api.php index a2051130f7c..4bd9b6d789f 100644 --- a/competency/classes/api.php +++ b/competency/classes/api.php @@ -1205,7 +1205,7 @@ class api { $result = array(); // TODO We could improve the performance of this into one single query. - $coursemodulecompetencies = course_competency::list_course_module_competencies($cm->id); + $coursemodulecompetencies = course_module_competency::list_course_module_competencies($cm->id); $competencies = course_module_competency::list_competencies($cm->id); // Build the return values. diff --git a/competency/tests/api_test.php b/competency/tests/api_test.php index 705a32a65fa..15a8e4af6dc 100644 --- a/competency/tests/api_test.php +++ b/competency/tests/api_test.php @@ -2757,6 +2757,16 @@ class core_competency_api_testcase extends advanced_testcase { $result = api::list_course_module_competencies_in_course_module($cm->id); $this->assertEquals($result[0]->get('competencyid'), $c->get('id')); $this->assertEquals($result[1]->get('competencyid'), $c2->get('id')); + + // Now get the course competency and coursemodule competency together. + $result = api::list_course_module_competencies($cm->id); + // Now we should have an array and each element of the array should have a competency and + // a coursemodulecompetency. + foreach ($result as $instance) { + $cmc = $instance['coursemodulecompetency']; + $c = $instance['competency']; + $this->assertEquals($cmc->get('competencyid'), $c->get('id')); + } } /**