From 6a1131e2c24c268898353a4e58c0692b7c269d91 Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Fri, 24 Jun 2016 13:33:42 +0100 Subject: [PATCH] MDL-55019 webservice: Course summary text should not be cleaned --- course/externallib.php | 4 +++- course/tests/externallib_test.php | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/course/externallib.php b/course/externallib.php index e868841af4c..c43f1cdf6bb 100644 --- a/course/externallib.php +++ b/course/externallib.php @@ -195,9 +195,11 @@ class core_course_external extends external_api { $sectionvalues['id'] = $section->id; $sectionvalues['name'] = get_section_name($course, $section); $sectionvalues['visible'] = $section->visible; + + $options = (object) array('noclean' => true); list($sectionvalues['summary'], $sectionvalues['summaryformat']) = external_format_text($section->summary, $section->summaryformat, - $context->id, 'course', 'section', $section->id); + $context->id, 'course', 'section', $section->id, $options); $sectionvalues['section'] = $section->section; $sectioncontents = array(); diff --git a/course/tests/externallib_test.php b/course/tests/externallib_test.php index 549b0545e6f..8ec184b630f 100644 --- a/course/tests/externallib_test.php +++ b/course/tests/externallib_test.php @@ -686,6 +686,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase { * @return array A list with the course object and course modules objects */ private function prepare_get_course_contents_test() { + global $DB; $course = self::getDataGenerator()->create_course(); $forumdescription = 'This is the forum description'; $forum = $this->getDataGenerator()->create_module('forum', @@ -710,6 +711,10 @@ class core_course_externallib_testcase extends externallib_advanced_testcase { $roleid = $this->assignUserCapability('moodle/course:view', $context->id); $this->assignUserCapability('moodle/course:update', $context->id, $roleid); + $conditions = array('course' => $course->id, 'section' => 2); + $DB->set_field('course_sections', 'summary', 'Text with iframe ', $conditions); + rebuild_course_cache($course->id, true); + return array($course, $forumcm, $datacm, $pagecm, $labelcm, $urlcm); } @@ -755,6 +760,8 @@ class core_course_externallib_testcase extends externallib_advanced_testcase { $this->assertCount(4, $firstsection['modules']); $this->assertCount(1, $lastsection['modules']); $this->assertEquals(2, $lastsection['section']); + $this->assertContains('assertContains('', $lastsection['summary']); try { $sections = core_course_external::get_course_contents($course->id,