Merge branch 'MDL-79786-main' of https://github.com/rmady/moodle

This commit is contained in:
Jun Pataleta
2023-12-18 13:08:54 +08:00
2 changed files with 34 additions and 1 deletions
+2
View File
@@ -266,6 +266,7 @@ class core_course_external extends external_api {
$module['modname'] = (string) $cm->modname;
$module['modplural'] = (string) $cm->modplural;
$module['modicon'] = $cm->get_icon_url()->out(false);
$module['purpose'] = plugin_supports('mod', $cm->modname, FEATURE_MOD_PURPOSE, MOD_PURPOSE_OTHER);
$module['indent'] = $cm->indent;
$module['onclick'] = $cm->onclick;
$module['afterlink'] = $cm->afterlink;
@@ -461,6 +462,7 @@ class core_course_external extends external_api {
VALUE_OPTIONAL),
'modicon' => new external_value(PARAM_URL, 'activity icon url'),
'modname' => new external_value(PARAM_PLUGIN, 'activity module type'),
'purpose' => new external_value(PARAM_ALPHA, 'the module purpose'),
'modplural' => new external_value(PARAM_TEXT, 'activity module plural name'),
'availability' => new external_value(PARAM_RAW, 'module availability settings', VALUE_OPTIONAL),
'indent' => new external_value(PARAM_INT, 'number of identation in the site'),
+32 -1
View File
@@ -1179,7 +1179,14 @@ class externallib_test extends externallib_advanced_testcase {
$this->assertEmpty($module['afterlink']);
$this->assertEquals('1 unread post', $module['activitybadge']['badgecontent']);
$this->assertEquals('badge-dark', $module['activitybadge']['badgestyle']);
$this->assertEquals(
plugin_supports(
'mod',
'forum',
FEATURE_MOD_PURPOSE,
MOD_PURPOSE_OTHER
), $module['purpose']
);
$testexecuted = $testexecuted + 2;
} else if ($module['id'] == $labelcm->id and $module['modname'] == 'label') {
$cm = $modinfo->cms[$labelcm->id];
@@ -1191,17 +1198,41 @@ class externallib_test extends externallib_advanced_testcase {
$this->assertTrue($module['noviewlink']);
$this->assertNotEmpty($module['description']); // Label always prints the description.
$testexecuted = $testexecuted + 1;
$this->assertEquals(
plugin_supports(
'mod',
'label',
FEATURE_MOD_PURPOSE,
MOD_PURPOSE_OTHER
), $module['purpose']
);
} else if ($module['id'] == $datacm->id and $module['modname'] == 'data') {
$this->assertStringContainsString('customcompletionrules', $module['customdata']);
$this->assertFalse($module['noviewlink']);
$this->assertArrayNotHasKey('description', $module);
$testexecuted = $testexecuted + 1;
$this->assertEquals(
plugin_supports(
'mod',
'data',
FEATURE_MOD_PURPOSE,
MOD_PURPOSE_OTHER
), $module['purpose']
);
} else if ($module['instance'] == $resource->id && $module['modname'] == 'resource') {
// Resources have both, afterlink for the size and the update date and activitybadge for the file type.
$this->assertStringContainsString('32 bytes', $module['afterlink']);
$this->assertEquals('TXT', $module['activitybadge']['badgecontent']);
$this->assertEquals('badge-none', $module['activitybadge']['badgestyle']);
$testexecuted = $testexecuted + 1;
$this->assertEquals(
plugin_supports(
'mod',
'resource',
FEATURE_MOD_PURPOSE,
MOD_PURPOSE_OTHER
), $module['purpose']
);
}
}
foreach ($sections[2]['modules'] as $module) {