diff --git a/classes/local/outagelib.php b/classes/local/outagelib.php index 4af58a9..62d57fe 100644 --- a/classes/local/outagelib.php +++ b/classes/local/outagelib.php @@ -108,8 +108,8 @@ class outagelib { return [ 'default_autostart' => false, - 'default_duration' => 60, - 'default_warning_duration' => 60, + 'default_duration' => (60*60), + 'default_warning_duration' => (60*60), 'default_title' => get_string('defaulttitlevalue', 'auth_outage'), 'default_description' => get_string('defaultdescriptionvalue', 'auth_outage'), 'css' => file_get_contents($CFG->dirroot.'/auth/outage/views/warningbar/warningbar.css'), diff --git a/new.php b/new.php index 02cfac6..fa3c5f3 100644 --- a/new.php +++ b/new.php @@ -46,8 +46,8 @@ $config = outagelib::get_config(); $defaults = new outage([ 'autostart' => $config->default_autostart, 'starttime' => time(), - 'stoptime' => time() + ($config->default_duration * 60), - 'warntime' => time() - ($config->default_warning_duration * 60), + 'stoptime' => time() + $config->default_duration, + 'warntime' => time() - $config->default_warning_duration, 'title' => $config->default_title, 'description' => $config->default_description, ]); diff --git a/settings.php b/settings.php index e454dca..b9872d5 100644 --- a/settings.php +++ b/settings.php @@ -36,19 +36,19 @@ if ($hassiteconfig && is_enabled_auth('outage')) { get_string('defaultoutageautostartdescription', 'auth_outage'), $defaults['default_autostart'] )); - $settings->add(new admin_setting_configtext( + $settings->add(new admin_setting_configduration( 'auth_outage/default_warning_duration', get_string('defaultwarningduration', 'auth_outage'), get_string('defaultwarningdurationdescription', 'auth_outage'), $defaults['default_warning_duration'], - PARAM_INT + 60 )); - $settings->add(new admin_setting_configtext( + $settings->add(new admin_setting_configduration( 'auth_outage/default_duration', get_string('defaultoutageduration', 'auth_outage'), get_string('defaultoutagedurationdescription', 'auth_outage'), $defaults['default_duration'], - PARAM_INT + 60 )); $settings->add(new admin_setting_configtext( 'auth_outage/default_title', diff --git a/tests/behat/default_settings.feature b/tests/behat/default_settings.feature index 440f29c..ef8fa49 100644 --- a/tests/behat/default_settings.feature +++ b/tests/behat/default_settings.feature @@ -1,14 +1,11 @@ -@dev @auth @auth_outage @javascript +@auth @auth_outage @javascript Feature: Test changing the default settings. In order to easily create outages As an admin I need to configure the outage defaults - Rules: - - Times should be expressed in minutes. - Reminder: - - If one setting is not valid, but another setting is valid and modified, Moodle will display 'Settings Saved'. + - Event if one setting is not valid Moodle will display 'Changes Saved' if another setting was saved. Background: Given the authentication plugin "outage" is enabled @@ -18,12 +15,14 @@ Feature: Test changing the default settings. Scenario Outline: Check if I can save the default settings. When I navigate to "Default Settings" node in "Site administration > Plugins > Authentication > Outage manager" And I set the following fields to these values: - | s_auth_outage_default_autostart | | - | s_auth_outage_default_warning_duration | | - | s_auth_outage_default_duration | | - | s_auth_outage_default_title | | - | s_auth_outage_default_description | <description> | - | s_auth_outage_css | <css> | + | s_auth_outage_default_autostart | <autostart> | + | s_auth_outage_default_warning_duration[v] | <warning> | + | s_auth_outage_default_warning_duration[u] | 60 | + | s_auth_outage_default_duration[v] | <duration> | + | s_auth_outage_default_duration[u] | 60 | + | s_auth_outage_default_title | <title> | + | s_auth_outage_default_description | <description> | + | s_auth_outage_css | <css> | And I press "Save changes" Then I should see "Changes saved" When I visit the Create Outage Page @@ -40,25 +39,3 @@ Feature: Test changing the default settings. | autostart | warning | duration | title | description | css | | 1 | 15 | 30 | An Outage | My outage until {stop}. | /* Some CSS. */ | | 0 | 30 | 45 | My Behat Outage {start} | My outage with <b>HTML</b>. | /* More CSS. */ | - - -## Scenario Outline: Check if I can save invalid values for default settings. -## When I navigate to "Default Settings" node in "Site administration > Plugins > Authentication > Outage manager" -## And I set the following fields to these values: -## | s_auth_outage_default_autostart | 1 | -## | s_auth_outage_default_warning_duration | <warning> | -## | s_auth_outage_default_duration | <duration> | -## | s_auth_outage_default_title | <title> | -## | s_auth_outage_default_description | <description> | -## | s_auth_outage_css | /* Some CSS. */ | -## And I press "Save changes" -## Then I should <seeornot> "Changes saved" -## -## Examples: -## | warning | duration | title | description | seeornot | -## | 15 | 30 | My Title | My Description | see | -## | -1 | 30 | My Title | My Description | not see | -## | 15 | -1 | My Title | My Description | not see | -## | 15 | 30 | | My Description | not see | -## | 15 | 30 | My Title | | not see | -#