public static function get_activity_options($nodefaults) {
        $warnings = [];

        $params = self::validate_parameters(self::get_activity_options_parameters(), [
            'nodefaults' => $nodefaults,
        ]);
        $nodefaults = $params['nodefaults'];

        $context = context_system::instance();
        self::validate_context($context);

        // Get activity module plugin info.
        $pluginmanager = \core_plugin_manager::instance();
        $modplugins = $pluginmanager->get_enabled_plugins('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 $name) {
            // 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, $name);
                // 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;
                }
            }

            $displayname = $pluginmanager->plugin_name('mod_' . $name);
            $modoptions[] = (object)[
                'name' => $name,
                'displayname' => $displayname
            ];
        }

        return [
            'options' => $modoptions,
            'warnings' => $warnings
        ];
    }