mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-16 21:41:31 +02:00
Issue #48 and Issue #49 - Changed durations text field to duration, eliminating the problem of negative values. Invalid values will become blank and therefore use our hardcoded defaults.
This commit is contained in:
@@ -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'),
|
||||
|
||||
4
new.php
4
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,
|
||||
]);
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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 | <autostart> |
|
||||
| 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 | <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 |
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user