MDL-69577 forum: Add courseid, forumid on get_discussion_posts response
authorPau Ferrer Ocaña <crazyserver@gmail.com>
Mon, 31 Aug 2020 09:21:56 +0000 (11:21 +0200)
committerPau Ferrer Ocaña <crazyserver@gmail.com>
Tue, 1 Sep 2020 12:25:10 +0000 (14:25 +0200)
mod/forum/externallib.php
mod/forum/tests/externallib_test.php

index 23788fd..0b84fb3 100644 (file)
@@ -226,6 +226,8 @@ class mod_forum_external extends external_api {
 
         return [
             'posts' => $postbuilder->build($USER, [$forum], [$discussion], $posts),
+            'forumid' => $discussion->get_forum_id(),
+            'courseid' => $discussion->get_course_id(),
             'ratinginfo' => \core_rating\external\util::get_rating_info(
                 $legacydatamapper->get_forum_data_mapper()->to_legacy_object($forum),
                 $forum->get_context(),
@@ -258,6 +260,8 @@ class mod_forum_external extends external_api {
     public static function get_discussion_posts_returns() {
         return new external_single_structure([
             'posts' => new external_multiple_structure(\mod_forum\local\exporters\post::get_read_structure()),
+            'forumid' => new external_value(PARAM_INT, 'The forum id'),
+            'courseid' => new external_value(PARAM_INT, 'The forum course id'),
             'ratinginfo' => \core_rating\external\util::external_ratings_structure(),
             'warnings' => new external_warnings()
         ]);
index 3ba370a..0ce852f 100644 (file)
@@ -660,6 +660,8 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
         // Create what we expect to be returned when querying the discussion.
         $expectedposts = array(
             'posts' => array(),
+            'courseid' => $course1->id,
+            'forumid' => $forum1->id,
             'ratinginfo' => array(
                 'contextid' => $forum1context->id,
                 'component' => 'mod_forum',