From 98ffd731a86329e69a572c00dd3da3f715d3eb36 Mon Sep 17 00:00:00 2001 From: Matt Davidson Date: Thu, 21 Apr 2022 16:09:44 -0400 Subject: [PATCH 1/2] add buttons format --- db/upgrade.php | 5 +++ settings.php | 2 +- tests/behat/buttons.feature | 74 +++++++++++++++++++++++++++++++++++++ version.php | 2 +- 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 tests/behat/buttons.feature diff --git a/db/upgrade.php b/db/upgrade.php index de5d433..adcd9d4 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -38,6 +38,11 @@ function xmldb_block_massaction_upgrade($oldversion, $block): bool { upgrade_block_savepoint(true, 2022000000, 'massaction', false); } + if ($oldversion < 2022042001) { // Add buttons support. + add_supported_format('buttons'); + upgrade_block_savepoint(true, 2022042001, 'massaction', false); + } + return true; } diff --git a/settings.php b/settings.php index 5fbae4f..99a56a3 100644 --- a/settings.php +++ b/settings.php @@ -49,7 +49,7 @@ }); // These are the formats supported by the maintainer. - $supportedformatsbydefault = ['weeks' => 1, 'topics' => 1, 'topcoll' => 1]; + $supportedformatsbydefault = ['weeks' => 1, 'topics' => 1, 'topcoll' => 1, 'buttons' => 1]; $settings->add(new admin_setting_configmulticheckbox( 'block_massaction/applicablecourseformats', diff --git a/tests/behat/buttons.feature b/tests/behat/buttons.feature new file mode 100644 index 0000000..3aca75a --- /dev/null +++ b/tests/behat/buttons.feature @@ -0,0 +1,74 @@ +@block @block_massaction @block_massaction_buttons +Feature: Check if block generates all necessary checkboxes in buttons format and properly disables + the currently not active sections (or sections not containing any modules) + + @javascript + Scenario: Check if checkboxes are created properly for buttons format + Given I installed course format "buttons" + And the following "courses" exist: + | fullname | shortname | numsections | format | + | Test course | TC | 5 | buttons | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Mr | Teacher | teacher1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | TC | editingteacher | + And the following "activities" exist: + | activity | course | idnumber | name | intro | section | + | page | TC | 1 | Test Activity1 | Test page description | 0 | + | page | TC | 2 | Test Activity2 | Test page description | 1 | + | label | TC | 3 | Test Activity3 | Label text | 2 | + | page | TC | 4 | Test Activity4 | Test page description | 4 | + | page | TC | 5 | Test Activity5 | Test page description | 4 | + When I log in as "teacher1" + And I am on "Test course" course homepage with editing mode on + And I add the "Mass Actions" block + And I click on "Test Activity1 Checkbox" "checkbox" + And I click on "Test Activity4 Checkbox" "checkbox" + Then the field "Test Activity1 Checkbox" matches value "1" + Then the field "Test Activity2 Checkbox" matches value "" + Then the field "Label text Checkbox" matches value "" + Then the field "Test Activity4 Checkbox" matches value "1" + Then the field "Test Activity5 Checkbox" matches value "" + Then the "disabled" attribute of "#block-massaction-control-section-list-select-option-0" "css_element" should not be set + Then the "disabled" attribute of "#block-massaction-control-section-list-select-option-1" "css_element" should not be set + Then the "disabled" attribute of "#block-massaction-control-section-list-select-option-2" "css_element" should not be set + Then the "disabled" attribute of "#block-massaction-control-section-list-select-option-3" "css_element" should be set + Then the "disabled" attribute of "#block-massaction-control-section-list-select-option-4" "css_element" should not be set + + @javascript + Scenario: Check if mass actions 'indent' and 'outdent' work + # We need to use a different course format which supports indentation. + # From moodle 4.0 on this is a feature a course format has to explicitely support. + Given I installed course format "buttons" + And the following "courses" exist: + | fullname | shortname | numsections | format | + | Test course | TC2 | 5 | buttons | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Mr | Teacher | teacher1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | TC2 | editingteacher | + And the following "activities" exist: + | activity | course | idnumber | name | intro | section | + | page | TC2 | 1 | Test Activity1 | Test page description | 0 | + | page | TC2 | 2 | Test Activity2 | Test page description | 1 | + | label | TC2 | 3 | Test Activity3 | Label text | 2 | + | page | TC2 | 4 | Test Activity4 | Test page description | 4 | + | assign | TC2 | 5 | Test Activity5 | Test page description | 4 | + When I log in as "teacher1" + And I am on "Test course" course homepage with editing mode on + And I add the "Mass Actions" block + # Everything is setup now, let's do the real test. + And I click on "Test Activity2 Checkbox" "checkbox" + And I click on "Test Activity5 Checkbox" "checkbox" + And I click on "Indent (move right)" "link" in the "Mass Actions" "block" + Then "#section-1 li.modtype_page div.indent-1" "css_element" should exist + Then "#section-4 li.modtype_assign div.indent-1" "css_element" should exist + When I click on "Test Activity2 Checkbox" "checkbox" + And I click on "Test Activity5 Checkbox" "checkbox" + And I click on "Outdent (move left)" "link" in the "Mass Actions" "block" + Then "#section-1 li.modtype_page div.indent-1" "css_element" should not exist + Then "#section-4 li.modtype_assign div.indent-1" "css_element" should not exist diff --git a/version.php b/version.php index e170538..1f43fb4 100644 --- a/version.php +++ b/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2022042000; +$plugin->version = 2022042001; $plugin->requires = 2022041900; $plugin->component = 'block_massaction'; $plugin->maturity = MATURITY_STABLE; From af1033f7793e0ed97c72363d8074f304d9a03c42 Mon Sep 17 00:00:00 2001 From: Matt Davidson Date: Fri, 22 Apr 2022 08:28:34 -0400 Subject: [PATCH 2/2] Update upgrade.php --- db/upgrade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/upgrade.php b/db/upgrade.php index adcd9d4..95002bb 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -39,7 +39,7 @@ function xmldb_block_massaction_upgrade($oldversion, $block): bool { } if ($oldversion < 2022042001) { // Add buttons support. - add_supported_format('buttons'); + block_massaction_add_supported_format('buttons'); upgrade_block_savepoint(true, 2022042001, 'massaction', false); }