MDL-69577 forum: Add courseid, forumid on get_discussion_posts response

This commit is contained in:
Pau Ferrer Ocaña 2020-08-31 11:21:56 +02:00
parent 38abfb6a01
commit 150913d3e1
2 changed files with 6 additions and 0 deletions

View 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()
]);

View 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',