MDL-62554 tool_dataprivacy: Fix display of activity options

This commit is contained in:
Jun Pataleta 2018-09-04 16:52:08 +08:00
parent 40e4e99186
commit e547ba1de5
2 changed files with 9 additions and 2 deletions

View File

@ -1367,12 +1367,16 @@ class external extends external_api {
$pluginmanager = \core_plugin_manager::instance();
$modplugins = $pluginmanager->get_plugins_of_type('mod');
$modoptions = [];
// Get the module-level defaults. data_registry::get_defaults falls back to this when there are no activity defaults.
list($levelpurpose, $levelcategory) = data_registry::get_defaults(CONTEXT_MODULE);
foreach ($modplugins as $plugin) {
// Check if we have default purpose and category for this module if we want don't want to fetch everything.
if ($nodefaults) {
list($purpose, $category) = data_registry::get_defaults(CONTEXT_MODULE, $plugin->name);
if ($purpose !== false || $category !== false) {
// If so, skip it.
// Compare this with the module-level defaults.
if ($purpose !== $levelpurpose || $category !== $levelcategory) {
// If the defaults for this activity has been already set, there's no need to add this in the list of options.
continue;
}
}

View File

@ -544,6 +544,9 @@ class tool_dataprivacy_external_testcase extends externallib_advanced_testcase {
$return = (object) external_api::clean_returnvalue(external::get_activity_options_returns(), $result);
$options = $return->options;
// Make sure the options list is not empty.
$this->assertNotEmpty($options);
$pluginwithdefaults = [
'name' => 'assign',
'displayname' => get_string('pluginname', 'assign')