MDL-53461 assign: Fix intro images to be shown in the mobile app

This commit is contained in:
Pau Ferrer Ocaña 2016-03-14 12:59:14 +01:00
parent aeccf4bd94
commit 988065c045
2 changed files with 14 additions and 4 deletions

View File

@ -447,7 +447,7 @@ class mod_assign_external extends external_api {
if ($assign->show_intro()) {
list($assignment['intro'], $assignment['introformat']) = external_format_text($module->intro,
$module->introformat, $context->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, 0);
$module->introformat, $context->id, 'mod_assign', 'intro', null);
$fs = get_file_storage();
if ($files = $fs->get_area_files($context->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA,

View File

@ -168,15 +168,23 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
'category' => $category->id
));
// Create the assignment module.
// Create the assignment module with links to a filerecord.
$assign1 = self::getDataGenerator()->create_module('assign', array(
'course' => $course1->id,
'name' => 'lightwork assignment',
'intro' => 'the assignment intro text here',
'intro' => 'the assignment intro text here <a href="@@PLUGINFILE@@/intro.txt">link</a>',
'introformat' => FORMAT_HTML,
'markingworkflow' => 1,
'markingallocation' => 1
));
// Add a file as assignment attachment.
$context = context_module::instance($assign1->cmid);
$filerecord = array('component' => 'mod_assign', 'filearea' => 'intro', 'contextid' => $context->id, 'itemid' => 0,
'filename' => 'intro.txt', 'filepath' => '/');
$fs = get_file_storage();
$fs->create_file_from_string($filerecord, 'Test intro file');
// Create manual enrolment record.
$enrolid = $DB->insert_record('enrol', (object)array(
'enrol' => 'manual',
@ -218,7 +226,9 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
$this->assertEquals($assign1->id, $assignment['id']);
$this->assertEquals($course1->id, $assignment['course']);
$this->assertEquals('lightwork assignment', $assignment['name']);
$this->assertEquals('the assignment intro text here', $assignment['intro']);
$this->assertContains('the assignment intro text here', $assignment['intro']);
// Check the url of the file attatched.
$this->assertRegExp('/.*mod_assign\/intro\/intro\.txt.*/', $assignment['intro']);
$this->assertEquals(1, $assignment['markingworkflow']);
$this->assertEquals(1, $assignment['markingallocation']);