MDL-54104 webservice: Return section number in WS get_course_contents
authorJuan Leyva <juanleyvadelgado@gmail.com>
Fri, 24 Jun 2016 12:55:04 +0000 (13:55 +0100)
committerJuan Leyva <juanleyvadelgado@gmail.com>
Fri, 24 Jun 2016 12:55:04 +0000 (13:55 +0100)
course/externallib.php
course/tests/externallib_test.php
course/upgrade.txt [new file with mode: 0644]

index b348aa1..e868841 100644 (file)
@@ -198,6 +198,7 @@ class core_course_external extends external_api {
                 list($sectionvalues['summary'], $sectionvalues['summaryformat']) =
                         external_format_text($section->summary, $section->summaryformat,
                                 $context->id, 'course', 'section', $section->id);
+                $sectionvalues['section'] = $section->section;
                 $sectioncontents = array();
 
                 //for each module of the section
@@ -325,6 +326,7 @@ class core_course_external extends external_api {
                     'visible' => new external_value(PARAM_INT, 'is the section visible', VALUE_OPTIONAL),
                     'summary' => new external_value(PARAM_RAW, 'Section description'),
                     'summaryformat' => new external_format_value('summary'),
+                    'section' => new external_value(PARAM_INT, 'Section number inside the course', VALUE_OPTIONAL),
                     'modules' => new external_multiple_structure(
                             new external_single_structure(
                                 array(
index 9ad5d73..549b054 100644 (file)
@@ -749,10 +749,12 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
             }
         }
         $this->assertEquals(2, $testexecuted);
+        $this->assertEquals(0, $firstsection['section']);
 
         // Check that the only return section has the 5 created modules.
         $this->assertCount(4, $firstsection['modules']);
         $this->assertCount(1, $lastsection['modules']);
+        $this->assertEquals(2, $lastsection['section']);
 
         try {
             $sections = core_course_external::get_course_contents($course->id,
diff --git a/course/upgrade.txt b/course/upgrade.txt
new file mode 100644 (file)
index 0000000..8e73dd9
--- /dev/null
@@ -0,0 +1,7 @@
+This files describes API changes in /course/*,
+information provided here is intended especially for developers.
+
+=== 3.2 ===
+
+ * External function core_course_external::get_course_contents now returns the section's number in the course (new section field).
+