Merge branch 'MDL-64656-master' of git://github.com/jleyva/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2019-04-11 20:12:13 +02:00
commit ff3c8c0e6c
28 changed files with 1091 additions and 18 deletions

View file

@ -421,6 +421,8 @@ class mod_forum_external extends external_api {
if (!empty($messageinlinefiles)) {
$post->messageinlinefiles = $messageinlinefiles;
}
// Post tags.
$post->tags = \core_tag\external\util::get_item_tags('mod_forum', 'forum_posts', $post->id);
$posts[] = $post;
}
@ -467,6 +469,9 @@ class mod_forum_external extends external_api {
'userpictureurl' => new external_value(PARAM_URL, 'Post author picture.', VALUE_OPTIONAL),
'deleted' => new external_value(PARAM_BOOL, 'This post has been removed.'),
'isprivatereply' => new external_value(PARAM_BOOL, 'The post is a private reply'),
'tags' => new external_multiple_structure(
\core_tag\external\tag_item_exporter::get_read_structure(), 'Tags', VALUE_OPTIONAL
),
), 'post'
)
),

View file

@ -260,6 +260,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
$record->parent = $discussion1reply1->id;
$record->userid = $user3->id;
$record->tags = array('Cats', 'Dogs');
$discussion1reply2 = self::getDataGenerator()->get_plugin_generator('mod_forum')->create_post($record);
// Enrol the user in the course.
@ -311,7 +312,12 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
'userpictureurl' => '',
'deleted' => false,
'isprivatereply' => false,
'tags' => \core_tag\external\util::get_item_tags('mod_forum', 'forum_posts', $discussion1reply2->id),
);
// Cast to expected.
$this->assertCount(2, $expectedposts['posts'][0]['tags']);
$expectedposts['posts'][0]['tags'][0]['isstandard'] = (bool) $expectedposts['posts'][0]['tags'][0]['isstandard'];
$expectedposts['posts'][0]['tags'][1]['isstandard'] = (bool) $expectedposts['posts'][0]['tags'][1]['isstandard'];
$expectedposts['posts'][] = array(
'id' => $discussion1reply1->id,
@ -348,6 +354,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
'userpictureurl' => '',
'deleted' => false,
'isprivatereply' => false,
'tags' => array(),
);
// Test a discussion with two additional posts (total 3 posts).

View file

@ -9,8 +9,8 @@ information provided here is intended especially for developers.
* The get_forum_discussion_posts web service has been deprecated in favour of get_discussion_posts.
* The forum_count_replies function has been deprecated in favour of get_reply_count_for_post_id_in_discussion_id in
the Post vault.
* External function get_forums_by_courses now returns two additional fields "duedate" and "cutoffdate" containing the due date and the cutoff date
for posting to the forums respectively.
* External function get_forums_by_courses now returns two additional fields "duedate" and "cutoffdate" containing the due date and the cutoff date for posting to the forums respectively.
* External function get_forum_discussion_posts now returns an additional field "tags" returning the post tags.
=== 3.6 ===