diff --git a/admin/tool/admin_presets/tests/behat/apply_presets.feature b/admin/tool/admin_presets/tests/behat/apply_presets.feature index 122740b84e4..49746a75cf0 100644 --- a/admin/tool/admin_presets/tests/behat/apply_presets.feature +++ b/admin/tool/admin_presets/tests/behat/apply_presets.feature @@ -113,6 +113,18 @@ Feature: I can apply presets And I navigate to "Plugins > Question types > Manage question types" in site administration And "Enabled" "icon" should not exist in the "Calculated multichoice" "table_row" + Scenario: Re-applying Starter Moodle preset does not display setting changes +# Apply Starter preset. + Given I navigate to "Site admin presets" in site administration + And I open the action menu in "Starter" "table_row" + And I choose "Review settings and apply" in the open action menu + And I click on "Apply" "button" + And I click on "Continue" "button" +# When the Starter preset it's applied again, no changes should be displayed. + When I open the action menu in "Starter" "table_row" + And I choose "Review settings and apply" in the open action menu + Then I should not see "Setting changes" + Scenario: Applied exported settings Given I navigate to "Site admin presets" in site administration And I click on "Create preset" "button" diff --git a/lib/classes/plugininfo/repository.php b/lib/classes/plugininfo/repository.php index 8aa49879159..ce77bf2b0fd 100644 --- a/lib/classes/plugininfo/repository.php +++ b/lib/classes/plugininfo/repository.php @@ -51,6 +51,32 @@ class repository extends base { return $DB->get_records_menu('repository', null, 'type ASC', 'type, type AS val'); } + /** + * Returns current status for a pluginname. + * + * Repositories needs to be calculated in a different way than the default method in the base class because they need to take + * into account the value of the visible column too. + * + * @param string $pluginname The plugin name to check. + * @return int The current status (enabled, disabled...) of $pluginname. + */ + public static function get_enabled_plugin(string $pluginname): int { + global $DB; + + $repository = $DB->get_record('repository', ['type' => $pluginname]); + if ($repository) { + switch ($repository->visible) { + case 1: + $value = self::REPOSITORY_ON; + break; + default: + $value = self::REPOSITORY_OFF; + } + } else { + $value = self::REPOSITORY_DISABLED; + } + return $value; + } /** * Enable or disable a plugin.