Skip to content

Commit

Permalink
add onetopic format (at-tools#29)
Browse files Browse the repository at this point in the history
* add onetopic format
* bump postgres and plugin version
  • Loading branch information
Syxton authored Apr 17, 2023
1 parent 7456d64 commit 58a7cf9
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

services:
postgres:
image: postgres:12
image: postgres:13
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
Expand Down
5 changes: 5 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ function xmldb_block_massaction_upgrade($oldversion, $block): bool {
upgrade_block_savepoint(true, 2022000000, 'massaction', false);
}

if ($oldversion < 2023041700) { // Add onetopic support.
add_supported_format('onetopic');
upgrade_block_savepoint(true, 2023041700, 'massaction', false);
}

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, 'onetopic' => 1];

$settings->add(new admin_setting_configmulticheckbox(
'block_massaction/applicablecourseformats',
Expand Down
91 changes: 91 additions & 0 deletions tests/behat/onetopic.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
@block @block_massaction @block_massaction_onetopic
Feature: Check if block generates all necessary checkboxes in onetopic format and properly disables
the currently not active sections (or sections not containing any modules)

@javascript
Scenario: Check if checkboxes are created properly for onetopic format
Given I installed course format "onetopic"
And the following "courses" exist:
| fullname | shortname | numsections | format |
| Test course | TC | 5 | onetopic |
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
When I follow "General"
And I click on "Test Activity1 Checkbox" "checkbox"
Then the field "Test Activity1 Checkbox" matches value "1"
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 be set
Then the "disabled" attribute of "#block-massaction-control-section-list-select-option-2" "css_element" should 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 be set
When I follow "Topic 4"
And I click on "Test Activity4 Checkbox" "checkbox"
Then the field "Test Activity4 Checkbox" matches value "1"
When I follow "Topic 2"
And I click on "Label text Checkbox" "checkbox"
Then the field "Label text Checkbox" matches value "1"
Then the "disabled" attribute of "#block-massaction-control-section-list-select-option-0" "css_element" should be set
Then the "disabled" attribute of "#block-massaction-control-section-list-select-option-1" "css_element" should 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 be set
When I follow "Topic 3"
Then the "disabled" attribute of "#block-massaction-control-section-list-select-option-0" "css_element" should be set
Then the "disabled" attribute of "#block-massaction-control-section-list-select-option-1" "css_element" should be set
Then the "disabled" attribute of "#block-massaction-control-section-list-select-option-2" "css_element" should 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 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 "onetopic"
And the following "courses" exist:
| fullname | shortname | numsections | format |
| Test course | TC2 | 5 | onetopic |
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.
When I follow "Topic 2"
And I click on "Test Activity2 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
When I click on "Test Activity2 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
When I follow "Topic 5"
And I click on "Test Activity5 Checkbox" "checkbox"
And I click on "Indent (move right)" "link" in the "Mass Actions" "block"
Then "#section-4 li.modtype_assign div.indent-1" "css_element" should exist
And I click on "Test Activity5 Checkbox" "checkbox"
And I click on "Outdent (move left)" "link" in the "Mass Actions" "block"
Then "#section-4 li.modtype_assign div.indent-1" "css_element" should not exist
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2022102300;
$plugin->version = 2023041700;
$plugin->requires = 2022041900;
$plugin->component = 'block_massaction';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = 'v7.1.1';
$plugin->release = 'v7.1.2';

0 comments on commit 58a7cf9

Please sign in to comment.