diff --git a/mod/assign/externallib.php b/mod/assign/externallib.php index f2eb881b884..5c7115694e2 100644 --- a/mod/assign/externallib.php +++ b/mod/assign/externallib.php @@ -451,6 +451,8 @@ class mod_assign_external extends external_api { list($assignment['intro'], $assignment['introformat']) = external_format_text($module->intro, $module->introformat, $context->id, 'mod_assign', 'intro', null); + $assignment['introfiles'] = external_util::get_area_files($context->id, 'mod_assign', 'intro', false, + false); $fs = get_file_storage(); if ($files = $fs->get_area_files($context->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, @@ -528,6 +530,7 @@ class mod_assign_external extends external_api { 'intro' => new external_value(PARAM_RAW, 'assignment intro, not allways returned because it deppends on the activity configuration', VALUE_OPTIONAL), 'introformat' => new external_format_value('intro', VALUE_OPTIONAL), + 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'introattachments' => new external_multiple_structure( new external_single_structure( array ( diff --git a/mod/book/classes/external.php b/mod/book/classes/external.php index 34d1493d515..3fde48d4caf 100644 --- a/mod/book/classes/external.php +++ b/mod/book/classes/external.php @@ -207,6 +207,7 @@ class mod_book_external extends external_api { // Format intro. list($bookdetails['intro'], $bookdetails['introformat']) = external_format_text($book->intro, $book->introformat, $context->id, 'mod_book', 'intro', null); + $bookdetails['introfiles'] = external_util::get_area_files($context->id, 'mod_book', 'intro', false, false); $bookdetails['numbering'] = $book->numbering; $bookdetails['navstyle'] = $book->navstyle; $bookdetails['customtitles'] = $book->customtitles; @@ -247,6 +248,7 @@ class mod_book_external extends external_api { 'name' => new external_value(PARAM_RAW, 'Book name'), 'intro' => new external_value(PARAM_RAW, 'The Book intro'), 'introformat' => new external_format_value('intro'), + 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'numbering' => new external_value(PARAM_INT, 'Book numbering configuration'), 'navstyle' => new external_value(PARAM_INT, 'Book navigation style configuration'), 'customtitles' => new external_value(PARAM_INT, 'Book custom titles type'), diff --git a/mod/book/tests/externallib_test.php b/mod/book/tests/externallib_test.php index 74dfec876f2..e363ec7a010 100644 --- a/mod/book/tests/externallib_test.php +++ b/mod/book/tests/externallib_test.php @@ -164,8 +164,8 @@ class mod_book_external_testcase extends externallib_advanced_testcase { $books = external_api::clean_returnvalue(mod_book_external::get_books_by_courses_returns(), $books); $this->assertCount(1, $books['books']); $this->assertEquals('First Book', $books['books'][0]['name']); - // We see 9 fields. - $this->assertCount(9, $books['books'][0]); + // We see 10 fields. + $this->assertCount(10, $books['books'][0]); // As Student you cannot see some book properties like 'section'. $this->assertFalse(isset($books['books'][0]['section'])); @@ -186,8 +186,8 @@ class mod_book_external_testcase extends externallib_advanced_testcase { $this->assertCount(1, $books['books']); $this->assertEquals('Second Book', $books['books'][0]['name']); - // We see 16 fields. - $this->assertCount(16, $books['books'][0]); + // We see 17 fields. + $this->assertCount(17, $books['books'][0]); // As an Admin you can see some book properties like 'section'. $this->assertEquals(0, $books['books'][0]['section']); diff --git a/mod/chat/classes/external.php b/mod/chat/classes/external.php index 8405efbd203..cd08786bfd3 100644 --- a/mod/chat/classes/external.php +++ b/mod/chat/classes/external.php @@ -549,6 +549,7 @@ class mod_chat_external extends external_api { // Format intro. list($chatdetails['intro'], $chatdetails['introformat']) = external_format_text($chat->intro, $chat->introformat, $chatcontext->id, 'mod_chat', 'intro', null); + $chatdetails['introfiles'] = external_util::get_area_files($chatcontext->id, 'mod_chat', 'intro', false, false); if (has_capability('mod/chat:chat', $chatcontext)) { $chatdetails['chatmethod'] = $CFG->chat_method; @@ -592,6 +593,7 @@ class mod_chat_external extends external_api { 'name' => new external_value(PARAM_RAW, 'Chat name'), 'intro' => new external_value(PARAM_RAW, 'The Chat intro'), 'introformat' => new external_format_value('intro'), + 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'chatmethod' => new external_value(PARAM_ALPHA, 'chat method (sockets, daemon)', VALUE_OPTIONAL), 'keepdays' => new external_value(PARAM_INT, 'keep days', VALUE_OPTIONAL), 'studentlogs' => new external_value(PARAM_INT, 'student logs visible to everyone', VALUE_OPTIONAL), diff --git a/mod/chat/tests/externallib_test.php b/mod/chat/tests/externallib_test.php index cbd335f99f3..e9698d29fa2 100644 --- a/mod/chat/tests/externallib_test.php +++ b/mod/chat/tests/externallib_test.php @@ -250,8 +250,8 @@ class mod_chat_external_testcase extends externallib_advanced_testcase { $chats = external_api::clean_returnvalue(mod_chat_external::get_chats_by_courses_returns(), $chats); $this->assertCount(1, $chats['chats']); $this->assertEquals('First Chat', $chats['chats'][0]['name']); - // We see 11 fields. - $this->assertCount(11, $chats['chats'][0]); + // We see 12 fields. + $this->assertCount(12, $chats['chats'][0]); // As Student you cannot see some chat properties like 'section'. $this->assertFalse(isset($chats['chats'][0]['section'])); @@ -272,8 +272,8 @@ class mod_chat_external_testcase extends externallib_advanced_testcase { $this->assertCount(1, $chats['chats']); $this->assertEquals('Second Chat', $chats['chats'][0]['name']); - // We see 16 fields. - $this->assertCount(16, $chats['chats'][0]); + // We see 17 fields. + $this->assertCount(17, $chats['chats'][0]); // As an Admin you can see some chat properties like 'section'. $this->assertEquals(0, $chats['chats'][0]['section']); diff --git a/mod/choice/classes/external.php b/mod/choice/classes/external.php index 7eb5a168f01..6732b9494ce 100644 --- a/mod/choice/classes/external.php +++ b/mod/choice/classes/external.php @@ -507,6 +507,8 @@ class mod_choice_external extends external_api { list($choicedetails['intro'], $choicedetails['introformat']) = external_format_text($choice->intro, $choice->introformat, $context->id, 'mod_choice', 'intro', null); + $choicedetails['introfiles'] = external_util::get_area_files($context->id, 'mod_choice', 'intro', false, + false); if (has_capability('mod/choice:choose', $context)) { $choicedetails['publish'] = $choice->publish; @@ -557,6 +559,7 @@ class mod_choice_external extends external_api { 'name' => new external_value(PARAM_RAW, 'Choice name'), 'intro' => new external_value(PARAM_RAW, 'The choice intro'), 'introformat' => new external_format_value('intro'), + 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'publish' => new external_value(PARAM_BOOL, 'If choice is published', VALUE_OPTIONAL), 'showresults' => new external_value(PARAM_INT, '0 never, 1 after answer, 2 after close, 3 always', VALUE_OPTIONAL), diff --git a/mod/data/classes/external.php b/mod/data/classes/external.php index 3ac5e826926..8a53280509d 100644 --- a/mod/data/classes/external.php +++ b/mod/data/classes/external.php @@ -104,6 +104,7 @@ class mod_data_external extends external_api { list($newdb['intro'], $newdb['introformat']) = external_format_text($database->intro, $database->introformat, $datacontext->id, 'mod_data', 'intro', null); + $newdb['introfiles'] = external_util::get_area_files($datacontext->id, 'mod_data', 'intro', false, false); // This information should be only available if the user can see the database entries. if (has_capability('mod/data:viewentry', $datacontext)) { @@ -167,6 +168,7 @@ class mod_data_external extends external_api { 'name' => new external_value(PARAM_RAW, 'Database name'), 'intro' => new external_value(PARAM_RAW, 'The Database intro'), 'introformat' => new external_format_value('intro'), + 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'comments' => new external_value(PARAM_BOOL, 'comments enabled', VALUE_OPTIONAL), 'timeavailablefrom' => new external_value(PARAM_INT, 'timeavailablefrom field', VALUE_OPTIONAL), 'timeavailableto' => new external_value(PARAM_INT, 'timeavailableto field', VALUE_OPTIONAL), diff --git a/mod/data/tests/externallib_test.php b/mod/data/tests/externallib_test.php index 831f0c9983c..b569105e220 100644 --- a/mod/data/tests/externallib_test.php +++ b/mod/data/tests/externallib_test.php @@ -94,11 +94,13 @@ class mod_data_external_testcase extends externallib_advanced_testcase { // First for the student user. $expectedfields = array('id', 'coursemodule', 'course', 'name', 'comments', 'timeavailablefrom', 'timeavailableto', 'timeviewfrom', 'timeviewto', 'requiredentries', 'requiredentriestoview', - 'intro', 'introformat'); + 'intro', 'introformat', 'introfiles'); // Add expected coursemodule. $database1->coursemodule = $database1->cmid; + $database1->introfiles = []; $database2->coursemodule = $database2->cmid; + $database2->introfiles = []; $expected1 = array(); $expected2 = array(); diff --git a/mod/forum/externallib.php b/mod/forum/externallib.php index 1b393ec21f3..8df99138bb2 100644 --- a/mod/forum/externallib.php +++ b/mod/forum/externallib.php @@ -92,6 +92,7 @@ class mod_forum_external extends external_api { // Format the intro before being returning using the format setting. list($forum->intro, $forum->introformat) = external_format_text($forum->intro, $forum->introformat, $context->id, 'mod_forum', 'intro', 0); + $forum->introfiles = external_util::get_area_files($context->id, 'mod_forum', 'intro', false, false); // Discussions count. This function does static request cache. $forum->numdiscussions = forum_count_discussions($forum, $cm, $course); $forum->cmid = $forum->coursemodule; @@ -121,6 +122,7 @@ class mod_forum_external extends external_api { 'name' => new external_value(PARAM_RAW, 'Forum name'), 'intro' => new external_value(PARAM_RAW, 'The forum intro'), 'introformat' => new external_format_value('intro'), + 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'assessed' => new external_value(PARAM_INT, 'Aggregate type'), 'assesstimestart' => new external_value(PARAM_INT, 'Assess start time'), 'assesstimefinish' => new external_value(PARAM_INT, 'Assess finish time'), diff --git a/mod/forum/tests/externallib_test.php b/mod/forum/tests/externallib_test.php index 455abcaa5ee..f9f08ca3e8a 100644 --- a/mod/forum/tests/externallib_test.php +++ b/mod/forum/tests/externallib_test.php @@ -79,6 +79,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase { $record->introformat = FORMAT_HTML; $record->course = $course2->id; $forum2 = self::getDataGenerator()->create_module('forum', $record); + $forum2->introfiles = []; // Add discussions to the forums. $record = new stdClass(); @@ -89,6 +90,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase { // Expect one discussion. $forum1->numdiscussions = 1; $forum1->cancreatediscussions = true; + $forum1->introfiles = []; $record = new stdClass(); $record->course = $course2->id; diff --git a/mod/glossary/classes/external.php b/mod/glossary/classes/external.php index ee61c3ffb01..a8b7fc62279 100644 --- a/mod/glossary/classes/external.php +++ b/mod/glossary/classes/external.php @@ -232,6 +232,7 @@ class mod_glossary_external extends external_api { $glossary->name = external_format_string($glossary->name, $context->id); list($glossary->intro, $glossary->introformat) = external_format_text($glossary->intro, $glossary->introformat, $context->id, 'mod_glossary', 'intro', null); + $glossary->introfiles = external_util::get_area_files($context->id, 'mod_glossary', 'intro', false, false); // Make sure we have a number of entries per page. if (!$glossary->entbypage) { @@ -268,6 +269,7 @@ class mod_glossary_external extends external_api { 'name' => new external_value(PARAM_RAW, 'Glossary name'), 'intro' => new external_value(PARAM_RAW, 'The Glossary intro'), 'introformat' => new external_format_value('intro'), + 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'allowduplicatedentries' => new external_value(PARAM_INT, 'If enabled, multiple entries can have the' . ' same concept name'), 'displayformat' => new external_value(PARAM_TEXT, 'Display format type'), diff --git a/mod/imscp/classes/external.php b/mod/imscp/classes/external.php index 4ae2fdda8c3..a5f0b37f550 100644 --- a/mod/imscp/classes/external.php +++ b/mod/imscp/classes/external.php @@ -165,6 +165,7 @@ class mod_imscp_external extends external_api { // Format intro. list($imscpdetails['intro'], $imscpdetails['introformat']) = external_format_text($imscp->intro, $imscp->introformat, $context->id, 'mod_imscp', 'intro', null); + $imscpdetails['introfiles'] = external_util::get_area_files($context->id, 'mod_imscp', 'intro', false, false); } if (has_capability('moodle/course:manageactivities', $context)) { @@ -204,6 +205,7 @@ class mod_imscp_external extends external_api { 'name' => new external_value(PARAM_RAW, 'Activity name'), 'intro' => new external_value(PARAM_RAW, 'The IMSCP intro', VALUE_OPTIONAL), 'introformat' => new external_format_value('intro', VALUE_OPTIONAL), + 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'revision' => new external_value(PARAM_INT, 'Revision', VALUE_OPTIONAL), 'keepold' => new external_value(PARAM_INT, 'Number of old IMSCP to keep', VALUE_OPTIONAL), 'structure' => new external_value(PARAM_RAW, 'IMSCP structure', VALUE_OPTIONAL), diff --git a/mod/lti/classes/external.php b/mod/lti/classes/external.php index e6d5181daa3..9f3c178fadb 100644 --- a/mod/lti/classes/external.php +++ b/mod/lti/classes/external.php @@ -309,6 +309,7 @@ class mod_lti_external extends external_api { list($module['intro'], $module['introformat']) = external_format_text($lti->intro, $lti->introformat, $context->id, 'mod_lti', 'intro', $lti->id); + $module['introfiles'] = external_util::get_area_files($context->id, 'mod_lti', 'intro', false, false); $viewablefields = array('launchcontainer', 'showtitlelaunch', 'showdescriptionlaunch', 'icon', 'secureicon'); } @@ -356,6 +357,7 @@ class mod_lti_external extends external_api { 'name' => new external_value(PARAM_RAW, 'LTI name'), 'intro' => new external_value(PARAM_RAW, 'The LTI intro', VALUE_OPTIONAL), 'introformat' => new external_format_value('intro', VALUE_OPTIONAL), + 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'timecreated' => new external_value(PARAM_INT, 'Time of creation', VALUE_OPTIONAL), 'timemodified' => new external_value(PARAM_INT, 'Time of last modification', VALUE_OPTIONAL), 'typeid' => new external_value(PARAM_INT, 'Type id', VALUE_OPTIONAL), diff --git a/mod/lti/tests/externallib_test.php b/mod/lti/tests/externallib_test.php index a7f03237a0e..07fc5b47ce4 100644 --- a/mod/lti/tests/externallib_test.php +++ b/mod/lti/tests/externallib_test.php @@ -129,7 +129,7 @@ class mod_lti_external_testcase extends externallib_advanced_testcase { // Create what we expect to be returned when querying the two courses. // First for the student user. - $expectedfields = array('id', 'coursemodule', 'course', 'name', 'intro', 'introformat', 'launchcontainer', + $expectedfields = array('id', 'coursemodule', 'course', 'name', 'intro', 'introformat', 'introfiles', 'launchcontainer', 'showtitlelaunch', 'showdescriptionlaunch', 'icon', 'secureicon'); // Add expected coursemodule and data. @@ -140,6 +140,7 @@ class mod_lti_external_testcase extends externallib_advanced_testcase { $lti1->visible = true; $lti1->groupmode = 0; $lti1->groupingid = 0; + $lti1->introfiles = []; $lti2->coursemodule = $lti2->cmid; $lti2->introformat = 1; @@ -147,6 +148,7 @@ class mod_lti_external_testcase extends externallib_advanced_testcase { $lti2->visible = true; $lti2->groupmode = 0; $lti2->groupingid = 0; + $lti2->introfiles = []; foreach ($expectedfields as $field) { $expected1[$field] = $lti1->{$field}; diff --git a/mod/quiz/classes/external.php b/mod/quiz/classes/external.php index d38a9070701..235957805d3 100644 --- a/mod/quiz/classes/external.php +++ b/mod/quiz/classes/external.php @@ -108,6 +108,7 @@ class mod_quiz_external extends external_api { list($quizdetails['intro'], $quizdetails['introformat']) = external_format_text($quiz->intro, $quiz->introformat, $context->id, 'mod_quiz', 'intro', null); + $quizdetails['introfiles'] = external_util::get_area_files($context->id, 'mod_quiz', 'intro', false, false); $viewablefields = array('timeopen', 'timeclose', 'grademethod', 'section', 'visible', 'groupmode', 'groupingid'); @@ -171,6 +172,7 @@ class mod_quiz_external extends external_api { 'name' => new external_value(PARAM_RAW, 'Quiz name.'), 'intro' => new external_value(PARAM_RAW, 'Quiz introduction text.', VALUE_OPTIONAL), 'introformat' => new external_format_value('intro', VALUE_OPTIONAL), + 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'timeopen' => new external_value(PARAM_INT, 'The time when this quiz opens. (0 = no restriction.)', VALUE_OPTIONAL), 'timeclose' => new external_value(PARAM_INT, 'The time when this quiz closes. (0 = no restriction.)', diff --git a/mod/quiz/tests/external_test.php b/mod/quiz/tests/external_test.php index a62bb95ce65..c106acae088 100644 --- a/mod/quiz/tests/external_test.php +++ b/mod/quiz/tests/external_test.php @@ -189,8 +189,8 @@ class mod_quiz_external_testcase extends externallib_advanced_testcase { // Create what we expect to be returned when querying the two courses. // First for the student user. - $allusersfields = array('id', 'coursemodule', 'course', 'name', 'intro', 'introformat', 'timeopen', 'timeclose', - 'grademethod', 'section', 'visible', 'groupmode', 'groupingid'); + $allusersfields = array('id', 'coursemodule', 'course', 'name', 'intro', 'introformat', 'introfiles', 'timeopen', + 'timeclose', 'grademethod', 'section', 'visible', 'groupmode', 'groupingid'); $userswithaccessfields = array('timelimit', 'attempts', 'attemptonlast', 'grademethod', 'decimalpoints', 'questiondecimalpoints', 'reviewattempt', 'reviewcorrectness', 'reviewmarks', 'reviewspecificfeedback', 'reviewgeneralfeedback', 'reviewrightanswer', @@ -211,6 +211,7 @@ class mod_quiz_external_testcase extends externallib_advanced_testcase { $quiz1->hasquestions = 0; $quiz1->hasfeedback = 0; $quiz1->autosaveperiod = get_config('quiz', 'autosaveperiod'); + $quiz1->introfiles = []; $quiz2->coursemodule = $quiz2->cmid; $quiz2->introformat = 1; @@ -221,6 +222,7 @@ class mod_quiz_external_testcase extends externallib_advanced_testcase { $quiz2->hasquestions = 0; $quiz2->hasfeedback = 0; $quiz2->autosaveperiod = get_config('quiz', 'autosaveperiod'); + $quiz2->introfiles = []; foreach (array_merge($allusersfields, $userswithaccessfields) as $field) { $expected1[$field] = $quiz1->{$field}; diff --git a/mod/scorm/classes/external.php b/mod/scorm/classes/external.php index ab8e166643f..d41122fccd4 100644 --- a/mod/scorm/classes/external.php +++ b/mod/scorm/classes/external.php @@ -693,6 +693,7 @@ class mod_scorm_external extends external_api { $module['name'] = external_format_string($scorm->name, $context->id); list($module['intro'], $module['introformat']) = external_format_text($scorm->intro, $scorm->introformat, $context->id, 'mod_scorm', 'intro', $scorm->id); + $module['introfiles'] = external_util::get_area_files($context->id, 'mod_scorm', 'intro', false, false); // Check if the SCORM open and return warnings if so. list($open, $openwarnings) = scorm_get_availability_status($scorm, true, $context); @@ -769,6 +770,7 @@ class mod_scorm_external extends external_api { 'name' => new external_value(PARAM_RAW, 'SCORM name'), 'intro' => new external_value(PARAM_RAW, 'The SCORM intro'), 'introformat' => new external_format_value('intro'), + 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'packagesize' => new external_value(PARAM_INT, 'SCORM zip package size', VALUE_OPTIONAL), 'packageurl' => new external_value(PARAM_URL, 'SCORM zip package URL', VALUE_OPTIONAL), 'version' => new external_value(PARAM_NOTAGS, 'SCORM version (SCORM_12, SCORM_13, SCORM_AICC)', diff --git a/mod/scorm/tests/externallib_test.php b/mod/scorm/tests/externallib_test.php index 5a71a6a5f13..53aaeea1c33 100644 --- a/mod/scorm/tests/externallib_test.php +++ b/mod/scorm/tests/externallib_test.php @@ -649,8 +649,8 @@ class mod_scorm_external_testcase extends externallib_advanced_testcase { $result = mod_scorm_external::get_scorms_by_courses(array($course1->id)); $result = external_api::clean_returnvalue($returndescription, $result); $this->assertCount(1, $result['warnings']); - // Only 'id', 'coursemodule', 'course', 'name', 'intro', 'introformat'. - $this->assertCount(6, $result['scorms'][0]); + // Only 'id', 'coursemodule', 'course', 'name', 'intro', 'introformat', 'introfiles'. + $this->assertCount(7, $result['scorms'][0]); $this->assertEquals('expired', $result['warnings'][0]['warningcode']); $scorm1->timeopen = $timenow + DAYSECS; @@ -660,8 +660,8 @@ class mod_scorm_external_testcase extends externallib_advanced_testcase { $result = mod_scorm_external::get_scorms_by_courses(array($course1->id)); $result = external_api::clean_returnvalue($returndescription, $result); $this->assertCount(1, $result['warnings']); - // Only 'id', 'coursemodule', 'course', 'name', 'intro', 'introformat'. - $this->assertCount(6, $result['scorms'][0]); + // Only 'id', 'coursemodule', 'course', 'name', 'intro', 'introformat', 'introfiles'. + $this->assertCount(7, $result['scorms'][0]); $this->assertEquals('notopenyet', $result['warnings'][0]['warningcode']); // Reset times. @@ -716,6 +716,9 @@ class mod_scorm_external_testcase extends externallib_advanced_testcase { // Since we return the fields used as boolean as PARAM_BOOL instead PARAM_INT we need to force casting here. // From the returned fields definition we obtain the type expected for the field. + if (empty($returndescription->keys['scorms']->content->keys[$field]->type)) { + continue; + } $fieldtype = $returndescription->keys['scorms']->content->keys[$field]->type; if ($fieldtype == PARAM_BOOL) { $expected1[$field] = (bool) $scorm1->{$field}; @@ -725,6 +728,8 @@ class mod_scorm_external_testcase extends externallib_advanced_testcase { $expected2[$field] = $scorm2->{$field}; } } + $expected1['introfiles'] = []; + $expected2['introfiles'] = []; $expectedscorms = array(); $expectedscorms[] = $expected2; diff --git a/mod/survey/classes/external.php b/mod/survey/classes/external.php index 762f4d5f398..d232b90201f 100644 --- a/mod/survey/classes/external.php +++ b/mod/survey/classes/external.php @@ -106,6 +106,8 @@ class mod_survey_external extends external_api { // Format intro. list($surveydetails['intro'], $surveydetails['introformat']) = external_format_text($survey->intro, $survey->introformat, $context->id, 'mod_survey', 'intro', null); + $surveydetails['introfiles'] = external_util::get_area_files($context->id, 'mod_survey', 'intro', false, + false); $surveydetails['template'] = $survey->template; $surveydetails['days'] = $survey->days; @@ -149,6 +151,7 @@ class mod_survey_external extends external_api { 'name' => new external_value(PARAM_RAW, 'Survey name'), 'intro' => new external_value(PARAM_RAW, 'The Survey intro', VALUE_OPTIONAL), 'introformat' => new external_format_value('intro', VALUE_OPTIONAL), + 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'template' => new external_value(PARAM_INT, 'Survey type', VALUE_OPTIONAL), 'days' => new external_value(PARAM_INT, 'Days', VALUE_OPTIONAL), 'questions' => new external_value(PARAM_RAW, 'Question ids', VALUE_OPTIONAL), diff --git a/mod/survey/tests/externallib_test.php b/mod/survey/tests/externallib_test.php index 5b9976d3c76..30de66b68ec 100644 --- a/mod/survey/tests/externallib_test.php +++ b/mod/survey/tests/externallib_test.php @@ -101,8 +101,8 @@ class mod_survey_external_testcase extends externallib_advanced_testcase { // Create what we expect to be returned when querying the two courses. // First for the student user. - $expectedfields = array('id', 'coursemodule', 'course', 'name', 'intro', 'introformat', 'template', 'days', 'questions', - 'surveydone'); + $expectedfields = array('id', 'coursemodule', 'course', 'name', 'intro', 'introformat', 'introfiles', 'template', 'days', + 'questions', 'surveydone'); // Add expected coursemodule and data. $survey1 = $this->survey; @@ -113,6 +113,7 @@ class mod_survey_external_testcase extends externallib_advanced_testcase { $survey1->visible = true; $survey1->groupmode = 0; $survey1->groupingid = 0; + $survey1->introfiles = []; $survey2->coursemodule = $survey2->cmid; $survey2->introformat = 1; @@ -123,6 +124,7 @@ class mod_survey_external_testcase extends externallib_advanced_testcase { $survey2->groupingid = 0; $tempo = $DB->get_field("survey", "intro", array("id" => $survey2->template)); $survey2->intro = nl2br(get_string($tempo, "survey")); + $survey2->introfiles = []; foreach ($expectedfields as $field) { $expected1[$field] = $survey1->{$field}; diff --git a/mod/wiki/classes/external.php b/mod/wiki/classes/external.php index 4d8f00b533d..c79f54482a2 100644 --- a/mod/wiki/classes/external.php +++ b/mod/wiki/classes/external.php @@ -104,6 +104,7 @@ class mod_wiki_external extends external_api { if (has_capability('mod/wiki:viewpage', $context)) { list($module['intro'], $module['introformat']) = external_format_text($wiki->intro, $wiki->introformat, $context->id, 'mod_wiki', 'intro', $wiki->id); + $module['introfiles'] = external_util::get_area_files($context->id, 'mod_wiki', 'intro', false, false); $viewablefields = array('firstpagetitle', 'wikimode', 'defaultformat', 'forceformat', 'editbegin', 'editend', 'section', 'visible', 'groupmode', 'groupingid'); @@ -151,6 +152,7 @@ class mod_wiki_external extends external_api { 'name' => new external_value(PARAM_RAW, 'Wiki name.'), 'intro' => new external_value(PARAM_RAW, 'Wiki intro.', VALUE_OPTIONAL), 'introformat' => new external_format_value('Wiki intro format.', VALUE_OPTIONAL), + 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'timecreated' => new external_value(PARAM_INT, 'Time of creation.', VALUE_OPTIONAL), 'timemodified' => new external_value(PARAM_INT, 'Time of last modification.', VALUE_OPTIONAL), 'firstpagetitle' => new external_value(PARAM_RAW, 'First page title.', VALUE_OPTIONAL), diff --git a/mod/wiki/tests/externallib_test.php b/mod/wiki/tests/externallib_test.php index 3cb4e83965d..f1ff9e829c6 100644 --- a/mod/wiki/tests/externallib_test.php +++ b/mod/wiki/tests/externallib_test.php @@ -172,9 +172,9 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { // Create what we expect to be returned when querying the two courses. // First for the student user. - $expectedfields = array('id', 'coursemodule', 'course', 'name', 'intro', 'introformat', 'firstpagetitle', 'wikimode', - 'defaultformat', 'forceformat', 'editbegin', 'editend', 'section', 'visible', 'groupmode', - 'groupingid'); + $expectedfields = array('id', 'coursemodule', 'course', 'name', 'intro', 'introformat', 'introfiles', 'firstpagetitle', + 'wikimode', 'defaultformat', 'forceformat', 'editbegin', 'editend', 'section', 'visible', + 'groupmode', 'groupingid'); // Add expected coursemodule and data. $wiki1 = $this->wiki; @@ -184,6 +184,7 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { $wiki1->visible = true; $wiki1->groupmode = 0; $wiki1->groupingid = 0; + $wiki1->introfiles = []; $wiki2->coursemodule = $wiki2->cmid; $wiki2->introformat = 1; @@ -191,6 +192,7 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase { $wiki2->visible = true; $wiki2->groupmode = 0; $wiki2->groupingid = 0; + $wiki2->introfiles = []; foreach ($expectedfields as $field) { $expected1[$field] = $wiki1->{$field};