Skip to content

Commit

Permalink
Merge branch 'MDL-73394-master' of https://github.com/sarjona/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies committed Dec 30, 2021
2 parents ef233d3 + bfa24ae commit 2eaab7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions admin/tool/admin_presets/classes/manager.php
Expand Up @@ -399,6 +399,11 @@ public function apply_preset(int $presetid, bool $simulate = false): array {
$applied = array_merge($settingsapplied, $pluginsapplied);
$skipped = array_merge($settingsskipped, $pluginsskipped);

if (!$simulate) {
// Store it in a config setting as the last preset applied.
set_config('lastpresetapplied', $presetid, 'tool_admin_presets');
}

return [$applied, $skipped];
}

Expand Down
8 changes: 8 additions & 0 deletions admin/tool/admin_presets/tests/manager_test.php
Expand Up @@ -236,6 +236,14 @@ public function test_apply_preset(): void {
$this->assertArrayHasKey('assign', $enabledplugins);
$enabledplugins = \core\plugininfo\qtype::get_enabled_plugins();
$this->assertArrayHasKey('truefalse', $enabledplugins);

// Check the presetid has been also stored in the lastpresetapplied config setting.
$this->assertEquals($presetid, get_config('tool_admin_presets', 'lastpresetapplied'));

// Call apply_preset as a simulation, so it shouldn't be applied and lastpresetapplied should still be $presetid.
$presetid2 = $generator->create_preset();
$manager->apply_preset($presetid2, true);
$this->assertEquals($presetid, get_config('tool_admin_presets', 'lastpresetapplied'));
}


Expand Down

0 comments on commit 2eaab7e

Please sign in to comment.