Skip to content

Commit

Permalink
MDL-69577 forum: Add courseid, forumid on get_discussion_posts response
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Sep 1, 2020
1 parent 38abfb6 commit 150913d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mod/forum/externallib.php
Expand Up @@ -226,6 +226,8 @@ public static function get_discussion_posts(int $discussionid, ?string $sortby,

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(),
Expand Down Expand Up @@ -258,6 +260,8 @@ public static function get_discussion_posts_parameters() {
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()
]);
Expand Down
2 changes: 2 additions & 0 deletions mod/forum/tests/externallib_test.php
Expand Up @@ -660,6 +660,8 @@ public function test_mod_forum_get_discussion_posts() {
// 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',
Expand Down

0 comments on commit 150913d

Please sign in to comment.