mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Merge branch 'MDL-55728-master' of git://github.com/jleyva/moodle
This commit is contained in:
commit
917a59a1a0
6 changed files with 71 additions and 0 deletions
|
@ -90,6 +90,7 @@ class mod_glossary_external extends external_api {
|
|||
'definition' => new external_value(PARAM_RAW, 'The definition'),
|
||||
'definitionformat' => new external_format_value('definition'),
|
||||
'definitiontrust' => new external_value(PARAM_BOOL, 'The definition trust flag'),
|
||||
'definitioninlinefiles' => new external_files('entry definition inline files', VALUE_OPTIONAL),
|
||||
'attachment' => new external_value(PARAM_BOOL, 'Whether or not the entry has attachments'),
|
||||
'attachments' => new external_files('attachments', VALUE_OPTIONAL),
|
||||
'timecreated' => new external_value(PARAM_INT, 'Time created'),
|
||||
|
@ -144,6 +145,10 @@ class mod_glossary_external extends external_api {
|
|||
if ($entry->attachment) {
|
||||
$entry->attachments = external_util::get_area_files($context->id, 'mod_glossary', 'attachment', $entry->id);
|
||||
}
|
||||
$definitioninlinefiles = external_util::get_area_files($context->id, 'mod_glossary', 'entry', $entry->id);
|
||||
if (!empty($definitioninlinefiles)) {
|
||||
$entry->definitioninlinefiles = $definitioninlinefiles;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1064,6 +1064,19 @@ class mod_glossary_external_testcase extends externallib_advanced_testcase {
|
|||
$this->getDataGenerator()->enrol_user($u1->id, $c1->id);
|
||||
|
||||
$e1 = $gg->create_content($g1, array('approved' => 1, 'userid' => $u1->id));
|
||||
// Add a fake inline image to the entry.
|
||||
$filename = 'shouldbeanimage.jpg';
|
||||
$filerecordinline = array(
|
||||
'contextid' => $ctx->id,
|
||||
'component' => 'mod_glossary',
|
||||
'filearea' => 'entry',
|
||||
'itemid' => $e1->id,
|
||||
'filepath' => '/',
|
||||
'filename' => $filename,
|
||||
);
|
||||
$fs = get_file_storage();
|
||||
$fs->create_file_from_string($filerecordinline, 'image contents (not really)');
|
||||
|
||||
$e2 = $gg->create_content($g1, array('approved' => 0, 'userid' => $u1->id));
|
||||
$e3 = $gg->create_content($g1, array('approved' => 0, 'userid' => $u2->id));
|
||||
$e4 = $gg->create_content($g2, array('approved' => 1));
|
||||
|
@ -1072,6 +1085,7 @@ class mod_glossary_external_testcase extends externallib_advanced_testcase {
|
|||
$return = mod_glossary_external::get_entry_by_id($e1->id);
|
||||
$return = external_api::clean_returnvalue(mod_glossary_external::get_entry_by_id_returns(), $return);
|
||||
$this->assertEquals($e1->id, $return['entry']['id']);
|
||||
$this->assertEquals($filename, $return['entry']['definitioninlinefiles'][0]['filename']);
|
||||
|
||||
$return = mod_glossary_external::get_entry_by_id($e2->id);
|
||||
$return = external_api::clean_returnvalue(mod_glossary_external::get_entry_by_id_returns(), $return);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue