$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();
//for each module of the section
'visible' => new external_value(PARAM_INT, 'is the section visible', VALUE_OPTIONAL),
'summary' => new external_value(PARAM_RAW, 'Section description'),
'summaryformat' => new external_format_value('summary'),
+ 'section' => new external_value(PARAM_INT, 'Section number inside the course', VALUE_OPTIONAL),
'modules' => new external_multiple_structure(
new external_single_structure(
array(
}
if (isset($value)) {
- $conditions[$key] = $crit['value'];
+ $conditions[$key] = $value;
$wheres[] = $key . " = :" . $key;
}
}
$this->assertEquals(1, count($categories));
+ // Same query, but forcing a parameters clean.
+ $categories = core_course_external::get_categories(array(
+ array('key' => 'id', 'value' => "$category1->id"),
+ array('key' => 'idnumber', 'value' => $category1->idnumber),
+ array('key' => 'name', 'value' => $category1->name . "<br/>"),
+ array('key' => 'visible', 'value' => '1')), 0);
+ $categories = external_api::clean_returnvalue(core_course_external::get_categories_returns(), $categories);
+
+ $this->assertEquals(1, count($categories));
+
// Retrieve categories from parent.
$categories = core_course_external::get_categories(array(
array('key' => 'parent', 'value' => $category3->id)), 1);
* @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',
$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 <iframe src="https://moodle.org"></iframe>', $conditions);
+ rebuild_course_cache($course->id, true);
+
return array($course, $forumcm, $datacm, $pagecm, $labelcm, $urlcm);
}
}
}
$this->assertEquals(2, $testexecuted);
+ $this->assertEquals(0, $firstsection['section']);
// Check that the only return section has the 5 created modules.
$this->assertCount(4, $firstsection['modules']);
$this->assertCount(1, $lastsection['modules']);
+ $this->assertEquals(2, $lastsection['section']);
+ $this->assertContains('<iframe', $lastsection['summary']);
+ $this->assertContains('</iframe>', $lastsection['summary']);
try {
$sections = core_course_external::get_course_contents($course->id,