diff --git a/admin/roles/tests/behat/override_roles_highlighting.feature b/admin/roles/tests/behat/override_roles_highlighting.feature index 8fa6f0fd191..a536b197d46 100644 --- a/admin/roles/tests/behat/override_roles_highlighting.feature +++ b/admin/roles/tests/behat/override_roles_highlighting.feature @@ -12,8 +12,7 @@ Feature: Highlight non-inherited permissions @javascript Scenario: Override a permission - Given I am on "Course fullname" course homepage - And I navigate to "Users > Permissions" in current page administration + Given I am on the "Course fullname" "permissions" page And I select "Manager (0)" from the "roleid" singleselect And I click on "Prohibit" "radio" in the "View added and updated modules in recent activity block" "table_row" And I press "Save changes" diff --git a/admin/tests/behat/check.feature b/admin/tests/behat/check.feature index a88167017bf..4e3050c1da5 100644 --- a/admin/tests/behat/check.feature +++ b/admin/tests/behat/check.feature @@ -27,8 +27,8 @@ Feature: Staff can check user permissions @javascript Scenario: Search for a user (enrolled on the course) by custom field and select them to see permissions - When I am on the "C1" "Course" page logged in as "admin" - And I navigate to "Users > Permissions > Check permissions" in current page administration + When I am on the "C1" "permissions" page logged in as "admin" + And I select "Check permissions" from the "jump" singleselect And I set the field "Search" to "Kermit" # The Behat 'I should see' step doesn't work for optgroup labels. Then "optgroup[label='Matching enrolled users (1)']" "css_element" should exist @@ -41,8 +41,8 @@ Feature: Staff can check user permissions @javascript Scenario: Search for a user (not enrolled on the course) by custom field and select them to see permissions - When I am on the "C1" "Course" page logged in as "admin" - And I navigate to "Users > Permissions > Check permissions" in current page administration + When I am on the "C1" "permissions" page logged in as "admin" + And I select "Check permissions" from the "jump" singleselect And I set the field "Search" to "Kermit" # The Behat 'I should see' step doesn't work for optgroup labels. Then "optgroup[label*='Potential users matching'][label*=' (1)']" "css_element" should exist diff --git a/admin/tool/behat/tests/behat/data_generators.feature b/admin/tool/behat/tests/behat/data_generators.feature index 134a2415131..c3467475e3f 100644 --- a/admin/tool/behat/tests/behat/data_generators.feature +++ b/admin/tool/behat/tests/behat/data_generators.feature @@ -57,8 +57,7 @@ Feature: Set up contextual data for tests | Grouping 1 | C1 | GG1 | | Grouping 2 | C1 | GG2 | When I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page Then I should see "Group 1" And I should see "Group 2" And I select "Groupings" from the "jump" singleselect @@ -86,8 +85,7 @@ Feature: Set up contextual data for tests | mod/forum:editanypost | Allow | student | Course | C1 | | mod/forum:replynews | Prevent | editingteacher | Course | C1 | When I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 1" "permissions" page And I set the field "Advanced role override" to "Student (1)" Then "mod/forum:editanypost" capability has "Allow" permission And I press "Cancel" @@ -254,8 +252,7 @@ Feature: Set up contextual data for tests | grouping | group | | GG1 | G1 | When I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page Then the "groups" select box should contain "Group 1 (1)" And the "groups" select box should contain "Group 2 (1)" And I set the field "groups" to "Group 1 (1)" diff --git a/admin/tool/behat/tests/behat/edit_permissions.feature b/admin/tool/behat/tests/behat/edit_permissions.feature index 2e755b68c79..0cd2d30dd03 100644 --- a/admin/tool/behat/tests/behat/edit_permissions.feature +++ b/admin/tool/behat/tests/behat/edit_permissions.feature @@ -35,14 +35,14 @@ Feature: Edit capabilities Scenario: Course capabilities overrides Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 1" "permissions" page And I override the system permissions of "Student" role with: | mod/forum:deleteanypost | Prohibit | | mod/forum:editanypost | Prevent | | mod/forum:addquestion | Allow | When I set the field "Advanced role override" to "Student (3)" - And I click on "Go" "button" in the "div.advancedoverride" "css_element" + # There are two select elements and go buttons and we want to press the second one. + And I click on "//div[@class='advancedoverride']/div/form/noscript/input" "xpath_element" Then "mod/forum:deleteanypost" capability has "Prohibit" permission And "mod/forum:editanypost" capability has "Prevent" permission And "mod/forum:addquestion" capability has "Allow" permission @@ -64,7 +64,7 @@ Feature: Edit capabilities | mod/forum:editanypost | Prevent | | mod/forum:addquestion | Allow | When I set the field "Advanced role override" to "Student (3)" - And I click on "Go" "button" in the "region-main" "region" + And I click on "//div[@class='advancedoverride']/div/form/noscript/input" "xpath_element" Then "mod/forum:deleteanypost" capability has "Prohibit" permission And "mod/forum:editanypost" capability has "Prevent" permission And "mod/forum:addquestion" capability has "Allow" permission @@ -82,7 +82,7 @@ Feature: Edit capabilities Then I should see "Teacher >= editing (Teacher)" in the "Teacher 1" "table_row" And I should see "Teacher < \"editing\" (Non-editing teacher)" in the "Teaching Assistant" "table_row" And I should see "Studier & 'learner' (Student)" in the "Student One" "table_row" - And I navigate to "Users > Permissions" in current page administration + And I am on the "C1" "permissions" page And I should see "Teacher >= editing" in the "mod/forum:replypost" "table_row" And I should see "Teacher < \"editing\"" in the "mod/forum:replypost" "table_row" And I should see "Studier & 'learner'" in the "mod/forum:replypost" "table_row" diff --git a/admin/tool/behat/tests/behat/get_and_set_fields.feature b/admin/tool/behat/tests/behat/get_and_set_fields.feature index 784470facf2..63b237b81e8 100644 --- a/admin/tool/behat/tests/behat/get_and_set_fields.feature +++ b/admin/tool/behat/tests/behat/get_and_set_fields.feature @@ -33,8 +33,7 @@ Feature: Verify that all form fields values can be get and set | activity | course | idnumber | name | intro | firstpagetitle | wikimode | visible | | wiki | C1 | wiki1 | Test this one | Test this one | Test this one | collaborative | 0 | And I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Reset" in current page administration + And I am on the "Course 1" "reset" page # Select (multi-select) - Checking "the select box should contain". And I expand all fieldsets And the "Unenrol users" select box should contain "No roles" @@ -147,8 +146,7 @@ Feature: Verify that all form fields values can be get and set @javascript Scenario: with JS enabled all form fields getters and setters works as expected - Then I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + Then I am on the "Course 1" "groups" page # Select (multi-select & AJAX) - Checking "I set the field" and "select box should contain". And I set the field "groups" to "Group 2" And the "members" select box should contain "Student 2 (s2@example.com)" diff --git a/admin/tool/recyclebin/tests/behat/basic_functionality.feature b/admin/tool/recyclebin/tests/behat/basic_functionality.feature index 8acb7cd3ccf..bddc912874b 100644 --- a/admin/tool/recyclebin/tests/behat/basic_functionality.feature +++ b/admin/tool/recyclebin/tests/behat/basic_functionality.feature @@ -77,8 +77,7 @@ Feature: Basic recycle bin functionality And I wait to be redirected And I go to the courses management page And I should see "Course 2" in the "#course-listing" "css_element" - And I am on "Course 2" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 2" "groups" page And I select "Overview" from the "jump" singleselect And "Student 1" "text" should exist in the "Group A" "table_row" And "Student 2" "text" should exist in the "Group A" "table_row" diff --git a/admin/tool/uploadcourse/tests/behat/enrolments.feature b/admin/tool/uploadcourse/tests/behat/enrolments.feature index c8ee54d5108..90f3060bfc5 100644 --- a/admin/tool/uploadcourse/tests/behat/enrolments.feature +++ b/admin/tool/uploadcourse/tests/behat/enrolments.feature @@ -12,8 +12,7 @@ Feature: An admin can update courses enrolments using a CSV file @javascript Scenario: Creating enrolment method by enable it - Given I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + Given I am on the "Course 1" "enrolment methods" page And I click on "Delete" "link" in the "Guest access" "table_row" And I click on "Continue" "button" And I should not see "Guest access" in the "generaltable" "table" @@ -25,14 +24,12 @@ Feature: An admin can update courses enrolments using a CSV file And I click on "Preview" "button" When I click on "Upload courses" "button" Then I should see "Course updated" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "enrolment methods" page And "Disable" "icon" should exist in the "Guest access" "table_row" @javascript Scenario: Creating enrolment method by disabling it - Given I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + Given I am on the "Course 1" "enrolment methods" page And I click on "Delete" "link" in the "Guest access" "table_row" And I click on "Continue" "button" And I should not see "Guest access" in the "generaltable" "table" @@ -44,8 +41,7 @@ Feature: An admin can update courses enrolments using a CSV file And I click on "Preview" "button" When I click on "Upload courses" "button" Then I should see "Course updated" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "enrolment methods" page And "Enable" "icon" should exist in the "Guest access" "table_row" @javascript @@ -58,14 +54,12 @@ Feature: An admin can update courses enrolments using a CSV file And I click on "Preview" "button" When I click on "Upload courses" "button" Then I should see "Course updated" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "enrolment methods" page And "Disable" "icon" should exist in the "Guest access" "table_row" @javascript Scenario: Disable an enrolment method - Given I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + Given I am on the "Course 1" "enrolment methods" page And I click on "Enable" "link" in the "Guest access" "table_row" And "Disable" "icon" should exist in the "Guest access" "table_row" And I navigate to "Courses > Upload courses" in site administration @@ -76,8 +70,7 @@ Feature: An admin can update courses enrolments using a CSV file And I click on "Preview" "button" When I click on "Upload courses" "button" Then I should see "Course updated" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "enrolment methods" page And "Enable" "icon" should exist in the "Guest access" "table_row" @javascript @@ -90,14 +83,12 @@ Feature: An admin can update courses enrolments using a CSV file And I click on "Preview" "button" When I click on "Upload courses" "button" Then I should see "Course updated" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "enrolment methods" page And I should not see "Guest access" in the "generaltable" "table" @javascript Scenario: Delete an unexistent enrolment method (nothing should change) - Given I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + Given I am on the "Course 1" "enrolment methods" page And I click on "Delete" "link" in the "Guest access" "table_row" And I click on "Continue" "button" And I should not see "Guest access" in the "generaltable" "table" @@ -109,6 +100,5 @@ Feature: An admin can update courses enrolments using a CSV file And I click on "Preview" "button" When I click on "Upload courses" "button" Then I should see "Course updated" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "enrolment methods" page And I should not see "Guest access" in the "generaltable" "table" diff --git a/admin/tool/uploaduser/tests/behat/upload_users.feature b/admin/tool/uploaduser/tests/behat/upload_users.feature index c6cdbce7cc9..ffe2e48b435 100644 --- a/admin/tool/uploaduser/tests/behat/upload_users.feature +++ b/admin/tool/uploaduser/tests/behat/upload_users.feature @@ -33,8 +33,7 @@ Feature: Upload users And I should see "Tom Jones" And I should see "Trent Reznor" And I should see "reznor@example.com" - And I am on "Maths" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Maths" "groups" page And I set the field "groups" to "Section 1 (1)" And the "members" select box should contain "Tom Jones (jonest@example.com)" diff --git a/backup/util/ui/tests/behat/behat_backup.php b/backup/util/ui/tests/behat/behat_backup.php index 6f80bc764d2..2f263f82905 100644 --- a/backup/util/ui/tests/behat/behat_backup.php +++ b/backup/util/ui/tests/behat/behat_backup.php @@ -28,6 +28,7 @@ require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php'); require_once(__DIR__ . '/../../../../../lib/behat/behat_field_manager.php'); require_once(__DIR__ . '/../../../../../lib/tests/behat/behat_navigation.php'); +require_once(__DIR__ . '/../../../../../lib/behat/form_field/behat_form_field.php'); use Behat\Gherkin\Node\TableNode as TableNode, Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException, @@ -55,15 +56,8 @@ class behat_backup extends behat_base { // We can not use other steps here as we don't know where the provided data // table elements are used, and we need to catch exceptions contantly. - // Go to homepage. - $this->execute('behat_general::i_visit', ['/?redirect=0']); - $this->execute("behat_general::wait_until_the_page_is_ready"); - - // Click the course link. - $this->execute("behat_general::click_link", $backupcourse); - - // Click the backup link. - $this->execute("behat_navigation::i_navigate_to_in_current_page_administration", get_string('backup')); + // Navigate to the course backup page. + $this->execute("behat_navigation::i_am_on_page_instance", [$backupcourse, 'backup']); // Initial settings. $this->fill_backup_restore_form($this->get_step_options($options, "Initial")); @@ -97,14 +91,8 @@ class behat_backup extends behat_base { // We can not use other steps here as we don't know where the provided data // table elements are used, and we need to catch exceptions contantly. - // Go to homepage. - $this->execute('behat_general::i_visit', ['/?redirect=0']); - - // Click the course link. - $this->execute("behat_general::click_link", $backupcourse); - - // Click the backup link. - $this->execute("behat_navigation::i_navigate_to_in_current_page_administration", get_string('backup')); + // Navigate to the course backup page. + $this->execute("behat_navigation::i_am_on_page_instance", [$backupcourse, 'backup']); // Initial settings. $this->execute("behat_forms::press_button", get_string('jumptofinalstep', 'backup')); @@ -133,15 +121,8 @@ class behat_backup extends behat_base { // We can not use other steps here as we don't know where the provided data // table elements are used, and we need to catch exceptions contantly. - // Go to homepage. - $this->execute('behat_general::i_visit', ['/?redirect=0']); - $this->execute("behat_general::wait_until_the_page_is_ready"); - - // Click the course link. - $this->execute("behat_general::click_link", $tocourse); - - // Click the import link. - $this->execute("behat_navigation::i_navigate_to_in_current_page_administration", get_string('import')); + // Navigate to the course import page. + $this->execute("behat_navigation::i_am_on_page_instance", [$tocourse, 'import']); // Select the course. $fromcourse = behat_context_helper::escape($fromcourse); diff --git a/backup/util/ui/tests/behat/import_course.feature b/backup/util/ui/tests/behat/import_course.feature index 76e1d0c195a..964001cbea0 100644 --- a/backup/util/ui/tests/behat/import_course.feature +++ b/backup/util/ui/tests/behat/import_course.feature @@ -40,10 +40,10 @@ Feature: Import course's contents into another course And I log in as "teacher1" When I import "Course 1" course into "Course 2" course using this options: | Initial | Include permission overrides | 1 | - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 1" "permissions" page Then I should see "Non-editing teacher (1)" And I set the field "Advanced role override" to "Non-editing teacher (1)" - And I click on "Go" "button" in the "div.advancedoverride" "css_element" + And I click on "//div[@class='advancedoverride']/div/form/noscript/input" "xpath_element" And "enrol/manual:enrol" capability has "Allow" permission Scenario: Import process without permission option @@ -53,5 +53,5 @@ Feature: Import course's contents into another course And I log in as "teacher1" When I import "Course 1" course into "Course 2" course using this options: | Initial | Include permission overrides | 0 | - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 2" "permissions" page Then I should see "Non-editing teacher (0)" diff --git a/backup/util/ui/tests/behat/import_groups.feature b/backup/util/ui/tests/behat/import_groups.feature index f14e300e4e0..722931ffa3d 100644 --- a/backup/util/ui/tests/behat/import_groups.feature +++ b/backup/util/ui/tests/behat/import_groups.feature @@ -30,7 +30,7 @@ Feature: Option to include groups and groupings when importing a course to anoth Scenario: Include groups and groupings when importing a course to another course Given I import "Course 1" course into "Course 2" course using this options: | Initial | Include groups and groupings | 1 | - When I navigate to "Users > Groups" in current page administration + When I am on the "Course 2" "groups" page Then I should see "Group 1" And I should see "Group 2" And I select "Groupings" from the "jump" singleselect @@ -40,7 +40,7 @@ Feature: Option to include groups and groupings when importing a course to anoth Scenario: Do not include groups and groupings when importing a course to another course Given I import "Course 1" course into "Course 2" course using this options: | Initial | Include groups and groupings | 0 | - When I navigate to "Users > Groups" in current page administration + When I am on the "Course 2" "groups" page Then I should not see "Group 1" And I should not see "Group 2" And I select "Groupings" from the "jump" singleselect diff --git a/backup/util/ui/tests/behat/restore_moodle2_courses.feature b/backup/util/ui/tests/behat/restore_moodle2_courses.feature index fdb6c236b99..949192f6c6e 100644 --- a/backup/util/ui/tests/behat/restore_moodle2_courses.feature +++ b/backup/util/ui/tests/behat/restore_moodle2_courses.feature @@ -66,7 +66,7 @@ Feature: Restore Moodle 2 course backups And I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum post backup name | | Description | Test forum post backup description | - And I navigate to "Restore" in current page administration + And I am on the "Course 1" "restore" page And I merge "test_backup.mbz" backup into the current course after deleting it's contents using this options: | Schema | Section 3 | 0 | Then I should see "Course 1" @@ -169,8 +169,7 @@ Feature: Restore Moodle 2 course backups When I backup "Course 1" course using this options: | Initial | Include enrolled users | 0 | | Confirmation | Filename | test_backup.mbz | - And I am on "Course 2" course homepage - And I navigate to "Restore" in current page administration + And I am on the "Course 2" "restore" page And I merge "test_backup.mbz" backup into the current course after deleting it's contents using this options: | Schema | Overwrite course configuration | Yes | And I navigate to "Settings" in current page administration @@ -198,8 +197,7 @@ Feature: Restore Moodle 2 course backups When I backup "Course 1" course using this options: | Initial | Include enrolled users | 0 | | Confirmation | Filename | test_backup.mbz | - And I am on "Course 2" course homepage - And I navigate to "Restore" in current page administration + And I am on the "Course 2" "restore" page And I merge "test_backup.mbz" backup into the current course after deleting it's contents using this options: | Schema | Overwrite course configuration | No | And I navigate to "Settings" in current page administration @@ -227,8 +225,7 @@ Feature: Restore Moodle 2 course backups When I backup "Course 1" course using this options: | Initial | Include enrolled users | 0 | | Confirmation | Filename | test_backup.mbz | - And I am on "Course 4" course homepage - And I navigate to "Restore" in current page administration + And I am on the "Course 4" "restore" page And I merge "test_backup.mbz" backup into the current course after deleting it's contents using this options: | Schema | Overwrite course configuration | No | And I navigate to "Settings" in current page administration @@ -254,7 +251,7 @@ Feature: Restore Moodle 2 course backups | Confirmation | Filename | test_backup.mbz | When I restore "test_backup.mbz" backup into a new course using this options: | Settings | Include permission overrides | 1 | - Then I navigate to "Users > Permissions" in current page administration + Then I am on the "Course 1 copy 1" "permissions" page And I should see "Non-editing teacher (1)" And I set the field "Advanced role override" to "Non-editing teacher (1)" And "enrol/manual:enrol" capability has "Allow" permission @@ -268,5 +265,5 @@ Feature: Restore Moodle 2 course backups | Confirmation | Filename | test_backup.mbz | When I restore "test_backup.mbz" backup into a new course using this options: | Settings | Include permission overrides | 0 | - Then I navigate to "Users > Permissions" in current page administration + Then I am on the "Course 1 copy 1" "permissions" page And I should see "Non-editing teacher (0)" diff --git a/backup/util/ui/tests/behat/restore_moodle2_courses_settings.feature b/backup/util/ui/tests/behat/restore_moodle2_courses_settings.feature index 5ca57f6302b..fabadbac987 100644 --- a/backup/util/ui/tests/behat/restore_moodle2_courses_settings.feature +++ b/backup/util/ui/tests/behat/restore_moodle2_courses_settings.feature @@ -99,8 +99,7 @@ Feature: Restore Moodle 2 course backups with different user data settings Given I navigate to "Courses > Backups > General restore defaults" in site administration And I set the field "s_restore_restore_general_users" to "" And I press "Save changes" - And I am on "Course 1" course homepage - And I navigate to "Restore" in current page administration + And I am on the "Course 1" "restore" page # "User data" marks the user data field for the section # "-" marks the user data field for the data activity And I restore "test_backup.mbz" backup into a new course using this options: @@ -116,8 +115,7 @@ Feature: Restore Moodle 2 course backups with different user data settings Given I navigate to "Courses > Backups > General restore defaults" in site administration And I set the field "s_restore_restore_general_users" to "" And I press "Save changes" - And I am on "Course 1" course homepage - And I navigate to "Restore" in current page administration + And I am on the "Course 1" "restore" page When I restore "test_backup.mbz" backup into a new course using this options: | Settings | Include enrolled users | 0 | Then I should see "Test database name" diff --git a/badges/tests/behat/award_badge_groups.feature b/badges/tests/behat/award_badge_groups.feature index a8db60274f7..906dc5031d2 100644 --- a/badges/tests/behat/award_badge_groups.feature +++ b/badges/tests/behat/award_badge_groups.feature @@ -82,8 +82,7 @@ Feature: Award badges with separate groups @javascript Scenario: Award course badge as non-editing teacher with more than one group Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I set the field "groups" to "Class B (2)" And I press "Add/remove users" And I set the field "addselect" to "Teacher 2 (teacher2@example.com)" @@ -107,8 +106,7 @@ Feature: Award badges with separate groups @javascript Scenario: Award course badge as non-editing teacher without any group Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I set the field "groups" to "Class A (2)" And I press "Add/remove users" And I set the field "removeselect" to "Teacher 2 (teacher2@example.com)" diff --git a/blocks/navigation/tests/behat/expand_courses_node.feature b/blocks/navigation/tests/behat/expand_courses_node.feature index b63a587a188..e12b4bf3f44 100644 --- a/blocks/navigation/tests/behat/expand_courses_node.feature +++ b/blocks/navigation/tests/behat/expand_courses_node.feature @@ -45,8 +45,7 @@ Feature: Expand the courses nodes within the navigation block | Page contexts | Display throughout the entire site | And I press "Save changes" And I turn editing mode off - And I am on "Course 2" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 2" "enrolment methods" page And I click on "Edit" "link" in the "Guest access" "table_row" And I set the following fields to these values: | Allow guest access | Yes | diff --git a/blocks/tests/behat/restrict_available_blocks.feature b/blocks/tests/behat/restrict_available_blocks.feature index 581d0f84f77..6ec366113e1 100644 --- a/blocks/tests/behat/restrict_available_blocks.feature +++ b/blocks/tests/behat/restrict_available_blocks.feature @@ -27,8 +27,7 @@ Feature: Allowed blocks controls Given I log in as "admin" And I set the following system permissions of "Teacher" role: | block/activity_modules:addinstance | Prohibit | - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 1" "permissions" page And I override the system permissions of "Teacher" role with: | block/completionstatus:addinstance | Prohibit | And I log out diff --git a/cohort/tests/behat/access_visible_cohorts.feature b/cohort/tests/behat/access_visible_cohorts.feature index 7f6282bd6a6..ec4473a66be 100644 --- a/cohort/tests/behat/access_visible_cohorts.feature +++ b/cohort/tests/behat/access_visible_cohorts.feature @@ -47,8 +47,7 @@ Feature: Access visible and hidden cohorts @javascript @skip_chrome_zerosize Scenario: Teacher can see visible cohorts defined in the above contexts When I log in as "teacher" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "enrolment methods" page And I select "Cohort sync" from the "Add method" singleselect And I open the autocomplete suggestions list Then "Cohort in category 1" "autocomplete_suggestions" should exist @@ -60,11 +59,9 @@ Feature: Access visible and hidden cohorts And "System empty cohort" "autocomplete_suggestions" should exist And I set the field "Cohort" to "System cohort" And I press "Add method" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 1" "enrolled users" page And I should see "student@example.com" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Auto-create groups" And the "Select members from cohort" select box should contain "Cohort in category 1" And the "Select members from cohort" select box should contain "System cohort" @@ -77,8 +74,7 @@ Feature: Access visible and hidden cohorts @javascript @skip_chrome_zerosize Scenario: System manager can see all cohorts defined in the above contexts When I log in as "user1" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "enrolment methods" page And I select "Cohort sync" from the "Add method" singleselect And I open the autocomplete suggestions list Then "Cohort in category 1" "autocomplete_suggestions" should exist @@ -90,10 +86,9 @@ Feature: Access visible and hidden cohorts And "System empty cohort" "autocomplete_suggestions" should exist And I set the field "Cohort" to "System cohort" And I press "Add method" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 1" "enrolled users" page And I should see "student@example.com" - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Auto-create groups" And the "Select members from cohort" select box should contain "Cohort in category 1" And the "Select members from cohort" select box should contain "System cohort" @@ -106,8 +101,7 @@ Feature: Access visible and hidden cohorts @javascript @skip_chrome_zerosize Scenario: Category manager can see all cohorts defined in his category and visible cohorts defined above When I log in as "user2" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "enrolment methods" page And I select "Cohort sync" from the "Add method" singleselect And I open the autocomplete suggestions list Then "Cohort in category 1" "autocomplete_suggestions" should exist @@ -119,10 +113,9 @@ Feature: Access visible and hidden cohorts And "System empty cohort" "autocomplete_suggestions" should exist And I set the field "Cohort" to "System cohort" And I press "Add method" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 1" "enrolled users" page And I should see "student@example.com" - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Auto-create groups" And the "Select members from cohort" select box should contain "Cohort in category 1" And the "Select members from cohort" select box should contain "System cohort" diff --git a/cohort/tests/behat/upload_cohort_users.feature b/cohort/tests/behat/upload_cohort_users.feature index a62ca76cf0a..3d60ddfa876 100644 --- a/cohort/tests/behat/upload_cohort_users.feature +++ b/cohort/tests/behat/upload_cohort_users.feature @@ -15,12 +15,10 @@ Feature: Upload users to a cohort | Course 1 | C1 | 0 | | Course 2 | C2 | 0 | And I log in as "admin" - And I am on "Course 1" course homepage - And I add "Cohort sync" enrolment method with: + And I add "Cohort sync" enrolment method in "Course 1" with: | Cohort | Cohort 1 | And I should see "Cohort sync (Cohort 1 - Student)" - And I am on "Course 2" course homepage - And I add "Cohort sync" enrolment method with: + And I add "Cohort sync" enrolment method in "Course 2" with: | Cohort | Cohort 2 | And I should see "Cohort sync (Cohort 2 - Student)" When I navigate to "Users > Accounts > Upload users" in site administration @@ -36,13 +34,11 @@ Feature: Upload users to a cohort And I click on "Assign" "link" in the "Cohort 2" "table_row" And the "Current users" select box should contain "Mary Smith (marysmith@example.com)" And the "Current users" select box should contain "Alice Smith (alicesmith@example.com)" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 1" "enrolled users" page And I should see "Tom Jones" And I should see "Bob Jones" And I should not see "Mary Smith" - And I am on "Course 2" course homepage - And I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 2" "enrolled users" page And I should see "Mary Smith" And I should see "Alice Smith" And I should not see "Tom Jones" diff --git a/completion/tests/behat/completion_no_calendar_capabilities.feature b/completion/tests/behat/completion_no_calendar_capabilities.feature index 6f990d47642..3693bc6a142 100644 --- a/completion/tests/behat/completion_no_calendar_capabilities.feature +++ b/completion/tests/behat/completion_no_calendar_capabilities.feature @@ -32,8 +32,7 @@ Feature: Completion with no calendar capabilites | id_completionexpected_month | 1 | | id_completionexpected_year | 2017 | And I press "Save and return to course" - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 1" "permissions" page And I override the system permissions of "Teacher" role with: | capability | permission | | moodle/calendar:manageentries | Prohibit | diff --git a/contentbank/tests/behat/edit_content.feature b/contentbank/tests/behat/edit_content.feature index 85eaaa2e934..8e59c8f1109 100644 --- a/contentbank/tests/behat/edit_content.feature +++ b/contentbank/tests/behat/edit_content.feature @@ -179,8 +179,7 @@ Feature: Content bank use editor feature | contextlevel | reference | contenttype | user | contentname | filepath | | Course | C1 | contenttype_h5p | admin | filltheblanks.h5p | /h5p/tests/fixtures/filltheblanks.h5p | | Course | C1 | contenttype_h5p | teacher1 | ipsums.h5p | /h5p/tests/fixtures/ipsums.h5p | - And I am on "Course 1" course homepage - And I navigate to "Copy course" in current page administration + And I am on the "Course 1" "course copy" page And I set the following fields to these values: | Course full name | Copy | | Course short name | Copy | diff --git a/course/tests/behat/category_management.feature b/course/tests/behat/category_management.feature index 94772c03b23..b224a9812a7 100644 --- a/course/tests/behat/category_management.feature +++ b/course/tests/behat/category_management.feature @@ -250,7 +250,7 @@ Feature: Test category management actions # Redirect And I should see "Assign roles in Category: Cat 1" And I should see "Please choose a role to assign" - And I click on "Back" "button" + And I follow "Manage this category" # Redirect And I should see the "Course categories and courses" management page And "Cat 1" "link" should exist in the "#category-listing" "css_element" diff --git a/course/tests/behat/keyholder.feature b/course/tests/behat/keyholder.feature index 604f8940479..db2f6e31ad5 100644 --- a/course/tests/behat/keyholder.feature +++ b/course/tests/behat/keyholder.feature @@ -29,8 +29,7 @@ Feature: Keyholder role is listed as course contact And the following "courses" exist: | fullname | shortname | format | coursedisplay | numsections | category | | Course 1 | C1 | topics | 0 | 5 | CAT1 | - And I am on "Course 1" course homepage - And I add "Self enrolment" enrolment method with: + And I add "Self enrolment" enrolment method in "Course 1" with: | Custom instance name | Test student enrolment | | Enrolment key | letmein | And I log out diff --git a/course/tests/behat/restrict_available_activities.feature b/course/tests/behat/restrict_available_activities.feature index f3b6126cd37..25087936fee 100644 --- a/course/tests/behat/restrict_available_activities.feature +++ b/course/tests/behat/restrict_available_activities.feature @@ -33,8 +33,7 @@ Feature: Restrict activities availability Given I log in as "admin" And I set the following system permissions of "Teacher" role: | mod/chat:addinstance | Prohibit | - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 1" "permissions" page And I override the system permissions of "Teacher" role with: | mod/glossary:addinstance | Prohibit | And I log out diff --git a/enrol/cohort/tests/behat/enrolcohorts.feature b/enrol/cohort/tests/behat/enrolcohorts.feature index 45f41aae9ec..d87a8572834 100644 --- a/enrol/cohort/tests/behat/enrolcohorts.feature +++ b/enrol/cohort/tests/behat/enrolcohorts.feature @@ -19,9 +19,7 @@ Feature: Enrol multiple cohorts @javascript Scenario: Add multiple cohorts to the course When I log in as "teacher001" - And I am on "Course 001" course homepage - And I navigate to course participants - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 001" "enrolment methods" page And I select "Cohort sync" from the "Add method" singleselect And I open the autocomplete suggestions list And I click on "Alpha1" item in the autocomplete list diff --git a/enrol/cohort/tests/behat/unenrolactionsuspendonly.feature b/enrol/cohort/tests/behat/unenrolactionsuspendonly.feature index 5da92a7b261..aab2806987a 100644 --- a/enrol/cohort/tests/behat/unenrolactionsuspendonly.feature +++ b/enrol/cohort/tests/behat/unenrolactionsuspendonly.feature @@ -28,16 +28,13 @@ Feature: Unenrol action to disable course enrolment @javascript @skip_chrome_zerosize Scenario: Removing the user from the cohort will suspend the enrolment but keep the role When I log in as "teacher001" - And I am on "Course 001" course homepage - And I navigate to course participants - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 001" "enrolment methods" page And I select "Cohort sync" from the "Add method" singleselect And I open the autocomplete suggestions list Then "System cohort" "autocomplete_suggestions" should exist And I set the field "Cohort" to "System cohort" And I press "Add method" - And I am on "Course 001" course homepage - And I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 001" "enrolled users" page And I should see "student001@example.com" And I should see "student002@example.com" And I should see "student003@example.com" @@ -63,16 +60,13 @@ Feature: Unenrol action to disable course enrolment @javascript @skip_chrome_zerosize Scenario: Deleting non-empty cohort will suspend the enrolment but keep the role When I log in as "teacher001" - And I am on "Course 001" course homepage - And I navigate to course participants - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 001" "enrolment methods" page And I select "Cohort sync" from the "Add method" singleselect And I open the autocomplete suggestions list Then "System cohort" "autocomplete_suggestions" should exist And I set the field "Cohort" to "System cohort" And I press "Add method" - And I am on "Course 001" course homepage - And I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 001" "enrolled users" page And I should see "student001@example.com" And I should see "student002@example.com" And I should see "student003@example.com" diff --git a/enrol/fee/tests/behat/fee.feature b/enrol/fee/tests/behat/fee.feature index eabc61e739d..397d83ff027 100644 --- a/enrol/fee/tests/behat/fee.feature +++ b/enrol/fee/tests/behat/fee.feature @@ -25,8 +25,7 @@ Feature: Signing up for a course with a fee enrolment method @javascript Scenario: Student can see the payment prompt on the course enrolment page When I log in as "manager1" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "enrolment methods" page And I select "Enrolment on payment" from the "Add method" singleselect And I set the following fields to these values: | Payment account | Account1 | diff --git a/enrol/guest/tests/behat/guest_access.feature b/enrol/guest/tests/behat/guest_access.feature index 859d5bc71f5..d8f1cc37fc4 100644 --- a/enrol/guest/tests/behat/guest_access.feature +++ b/enrol/guest/tests/behat/guest_access.feature @@ -23,11 +23,12 @@ Feature: Guest users can auto-enrol themself in courses where guest access is al | intro | Test forum description | | section | 1 | And I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on + And I am on "Course 1" course homepage + And I turn editing mode on + And I am on the "Course 1" "enrolment methods" page Scenario: Allow guest access without password - Given I navigate to "Users > Enrolment methods" in current page administration - And I click on "Edit" "link" in the "Guest access" "table_row" + Given I click on "Edit" "link" in the "Guest access" "table_row" And I set the following fields to these values: | Allow guest access | Yes | And I press "Save changes" @@ -38,8 +39,7 @@ Feature: Guest users can auto-enrol themself in courses where guest access is al Then I should not see "Subscribe to this forum" Scenario: Allow guest access with password - Given I navigate to "Users > Enrolment methods" in current page administration - And I click on "Edit" "link" in the "Guest access" "table_row" + Given I click on "Edit" "link" in the "Guest access" "table_row" And I set the following fields to these values: | Allow guest access | Yes | | Password | moodle_rules | diff --git a/enrol/lti/tests/behat/basic_settings.feature b/enrol/lti/tests/behat/basic_settings.feature index 40cfc3ef730..c01b0115c42 100644 --- a/enrol/lti/tests/behat/basic_settings.feature +++ b/enrol/lti/tests/behat/basic_settings.feature @@ -30,8 +30,7 @@ Feature: Check that settings are adhered to when creating an enrolment plugin Scenario: As an admin set site-wide settings for the enrolment plugin and ensure they are used Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "enrolment methods" page And I select "Publish as LTI tool" from the "Add method" singleselect When I expand all fieldsets Then the field "Email display" matches value "Allow everyone to see my email address" diff --git a/enrol/lti/tests/behat/index_page.feature b/enrol/lti/tests/behat/index_page.feature index 28fb2108bc3..7ed06f9f3a7 100644 --- a/enrol/lti/tests/behat/index_page.feature +++ b/enrol/lti/tests/behat/index_page.feature @@ -24,8 +24,8 @@ Feature: Check that the page listing the shared external tools is functioning as Scenario: I want to edit an external tool Given I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I navigate to "Users > Enrolment methods" in current page administration + And I turn editing mode on + And I am on the "Course 1" "enrolment methods" page And I select "Publish as LTI tool" from the "Add method" singleselect And I set the following fields to these values: | Custom instance name | Assignment - LTI | diff --git a/enrol/manual/tests/behat/manage.feature b/enrol/manual/tests/behat/manage.feature index b092d050478..df55125f182 100644 --- a/enrol/manual/tests/behat/manage.feature +++ b/enrol/manual/tests/behat/manage.feature @@ -25,8 +25,7 @@ Feature: A teacher can manage manually enrolled users in their course | capability | permission | role | contextlevel | reference | | moodle/site:viewfullnames | | editingteacher | Course | C1 | When I log in as "teacher" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "enrolment methods" page And I click on "Enrol users" "link" in the "Manual enrolments" "table_row" And I set the field "addselect_searchtext" to "First" And I wait "1" seconds @@ -50,8 +49,7 @@ Feature: A teacher can manage manually enrolled users in their course | user1 | C1 | student | | user2 | C1 | student | When I log in as "teacher" - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "enrolment methods" page And I click on "Enrol users" "link" in the "Manual enrolments" "table_row" And I set the field "removeselect_searchtext" to "First" And I wait "1" seconds diff --git a/enrol/meta/tests/behat/enrol_meta.feature b/enrol/meta/tests/behat/enrol_meta.feature index 6ed84e4462f..f42549a3522 100644 --- a/enrol/meta/tests/behat/enrol_meta.feature +++ b/enrol/meta/tests/behat/enrol_meta.feature @@ -37,25 +37,20 @@ Feature: Enrolments are synchronised with meta courses And I am on course index Scenario: Add meta enrolment instance without groups - When I am on "Course 3" course homepage - And I add "Course meta link" enrolment method with: + When I add "Course meta link" enrolment method in "Course 3" with: | Link course | C1C1 | - And I am on "Course 3" course homepage - And I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 3" "enrolled users" page Then I should see "No groups" in the "Student 1" "table_row" And I should see "No groups" in the "Student 4" "table_row" Scenario: Add meta enrolment instance with groups - When I am on "Course 3" course homepage - And I add "Course meta link" enrolment method with: + When I add "Course meta link" enrolment method in "Course 3" with: | Link course | C1C1 | | Add to group | Groupcourse 1 | - And I am on "Course 3" course homepage - And I add "Course meta link" enrolment method with: + And I add "Course meta link" enrolment method in "Course 3" with: | Link course | C2C2 | | Add to group | Groupcourse 2 | - And I am on "Course 3" course homepage - And I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 3" "enrolled users" page Then I should see "Groupcourse 1" in the "Student 1" "table_row" And I should see "Groupcourse 1" in the "Student 2" "table_row" And I should see "Groupcourse 1" in the "Student 3" "table_row" @@ -66,26 +61,22 @@ Feature: Enrolments are synchronised with meta courses And I should not see "Groupcourse 2" in the "Student 4" "table_row" Scenario: Add meta enrolment instance with auto-created groups - When I am on "Course 3" course homepage - And I add "Course meta link" enrolment method with: + When I add "Course meta link" enrolment method in "Course 3" with: | Link course | C1C1 | | Add to group | Create new group | - And I am on "Course 3" course homepage - And I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 3" "enrolled users" page Then I should see "Course 1 course" in the "Student 1" "table_row" And I should see "Course 1 course" in the "Student 2" "table_row" And I should see "Course 1 course" in the "Student 3" "table_row" And I should see "Course 1 course" in the "Student 4" "table_row" - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 3" "groups" page And the "Groups" select box should contain "Course 1 course (4)" Scenario: Backup and restore of meta enrolment instance - When I am on "Course 3" course homepage - And I add "Course meta link" enrolment method with: + When I add "Course meta link" enrolment method in "Course 3" with: | Link course | C1C1 | | Add to group | Groupcourse 1 | - And I am on "Course 3" course homepage - And I add "Course meta link" enrolment method with: + And I add "Course meta link" enrolment method in "Course 3" with: | Link course | C2C2 | When I backup "Course 3" course using this options: | Confirmation | Filename | test_backup.mbz | @@ -98,12 +89,10 @@ Feature: Enrolments are synchronised with meta courses And I press "Next" And I press "Perform restore" And I trigger cron - And I am on "Course 5 copy 1" course homepage - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 5 copy 1" "enrolment methods" page Then I should see "Course meta link (Course 1)" And I should see "Course meta link (Course 2)" - And I am on "Course 5 copy 1" course homepage - And I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 5 copy 1" "enrolled users" page And I should see "Groupcourse 1" in the "Student 1" "table_row" And I should see "Groupcourse 1" in the "Student 2" "table_row" And I should see "Groupcourse 1" in the "Student 3" "table_row" @@ -112,8 +101,7 @@ Feature: Enrolments are synchronised with meta courses And I should see "Course meta link (Course 2)" in the "Enrolment method" "table_row" Scenario: Unenrol a user from the course participants page that was enrolled via course meta link. - Given I am on "Course 3" course homepage - And I add "Course meta link" enrolment method with: + Given I add "Course meta link" enrolment method in "Course 3" with: | Link course | C4C4 | And I navigate to course participants # Suspended users can be unenrolled. diff --git a/enrol/self/tests/behat/key_holder.feature b/enrol/self/tests/behat/key_holder.feature index eae9dd415f7..46b1efb0702 100644 --- a/enrol/self/tests/behat/key_holder.feature +++ b/enrol/self/tests/behat/key_holder.feature @@ -34,8 +34,7 @@ Feature: Users can be defined as key holders in courses where self enrolment is @javascript Scenario: The key holder name is displayed on site home page Given I log in as "admin" - And I am on "Course 1" course homepage - When I add "Self enrolment" enrolment method with: + When I add "Self enrolment" enrolment method in "Course 1" with: | Custom instance name | Test student enrolment | | Enrolment key | moodle_rules | And I log out diff --git a/enrol/self/tests/behat/self_enrolment.feature b/enrol/self/tests/behat/self_enrolment.feature index 0c6704756d2..bf71cae807f 100644 --- a/enrol/self/tests/behat/self_enrolment.feature +++ b/enrol/self/tests/behat/self_enrolment.feature @@ -21,8 +21,7 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe @javascript Scenario: Self-enrolment enabled as guest Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I add "Self enrolment" enrolment method with: + And I add "Self enrolment" enrolment method in "Course 1" with: | Custom instance name | Test student enrolment | And I log out When I am on "Course 1" course homepage @@ -33,8 +32,7 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe Scenario: Self-enrolment enabled Given I log in as "teacher1" - And I am on "Course 1" course homepage - When I add "Self enrolment" enrolment method with: + When I add "Self enrolment" enrolment method in "Course 1" with: | Custom instance name | Test student enrolment | And I log out And I log in as "student1" @@ -45,8 +43,7 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe Scenario: Self-enrolment enabled requiring an enrolment key Given I log in as "teacher1" - And I am on "Course 1" course homepage - When I add "Self enrolment" enrolment method with: + When I add "Self enrolment" enrolment method in "Course 1" with: | Custom instance name | Test student enrolment | | Enrolment key | moodle_rules | And I log out @@ -66,13 +63,11 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe Scenario: Self-enrolment enabled requiring a group enrolment key Given I log in as "teacher1" - And I am on "Course 1" course homepage - When I add "Self enrolment" enrolment method with: + When I add "Self enrolment" enrolment method in "Course 1" with: | Custom instance name | Test student enrolment | | Enrolment key | moodle_rules | | Use group enrolment keys | Yes | - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Create group" And I set the following fields to these values: | Group name | Group 1 | @@ -91,8 +86,7 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe @javascript Scenario: Edit a self-enrolled user's enrolment from the course participants page Given I log in as "teacher1" - And I am on "Course 1" course homepage - When I add "Self enrolment" enrolment method with: + When I add "Self enrolment" enrolment method in "Course 1" with: | Custom instance name | Test student enrolment | And I log out And I log in as "student1" @@ -112,8 +106,7 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe @javascript Scenario: Unenrol a self-enrolled student from the course participants page Given I log in as "teacher1" - And I am on "Course 1" course homepage - When I add "Self enrolment" enrolment method with: + When I add "Self enrolment" enrolment method in "Course 1" with: | Custom instance name | Test student enrolment | And I log out And I log in as "student1" @@ -133,7 +126,7 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe Given the "multilang" filter is "on" And the "multilang" filter applies to "content and headings" And I am on the "C1" "Course" page logged in as "teacher1" - When I add "Self enrolment" enrolment method with: + When I add "Self enrolment" enrolment method in "Course 1" with: | Custom instance name | Test student enrolment | And I am on "Course 1" course homepage And I navigate to "Settings" in current page administration diff --git a/enrol/tests/behat/behat_enrol.php b/enrol/tests/behat/behat_enrol.php index 872a8aabf0f..fee9adc03f6 100644 --- a/enrol/tests/behat/behat_enrol.php +++ b/enrol/tests/behat/behat_enrol.php @@ -40,18 +40,15 @@ use Behat\Gherkin\Node\TableNode as TableNode; class behat_enrol extends behat_base { /** - * Adds the specified enrolment method to the current course filling the form with the provided data. + * Add the specified enrolment method to the specified course filling the form with the provided data. * - * @Given /^I add "(?P(?:[^"]|\\")*)" enrolment method with:$/ - * @param string $enrolmethod - * @param TableNode $table + * @Given /^I add "(?P(?:[^"]|\\")*)" enrolment method in "(?P(?:[^"]|\\")*)" with:$/ + * @param string $enrolmethod The enrolment method being used + * @param string $courseidentifier The courseidentifier such as short name + * @param TableNode $table Enrolment details */ - public function i_add_enrolment_method_with($enrolmethod, TableNode $table) { - // Navigate to enrolment method page. - $parentnodes = get_string('users', 'admin'); - $this->execute("behat_navigation::i_navigate_to_in_current_page_administration", - array($parentnodes .' > '. get_string('type_enrol_plural', 'plugin')) - ); + public function i_add_enrolment_method_for_with(string $enrolmethod, string $courseidentifier, TableNode $table): void { + $this->execute("behat_navigation::i_am_on_page_instance", [$courseidentifier, 'enrolment methods']); // Select enrolment method. $this->execute('behat_forms::i_select_from_the_singleselect', @@ -71,7 +68,6 @@ class behat_enrol extends behat_base { // Save changes. $this->execute("behat_forms::press_button", get_string('addinstance', 'enrol')); - } /** @@ -87,10 +83,14 @@ class behat_enrol extends behat_base { public function i_enrol_user_as($userfullname, $rolename) { // Navigate to enrolment page. - $parentnodes = get_string('users', 'admin'); - $this->execute("behat_navigation::i_navigate_to_in_current_page_administration", - array($parentnodes . ' > '. get_string('enrolledusers', 'enrol')) - ); + try { + $parentnodes = get_string('users', 'admin'); + $this->execute("behat_navigation::i_navigate_to_in_current_page_administration", + array($parentnodes . ' > '. get_string('enrolledusers', 'enrol')) + ); + } catch (Exception $e) { + $this->execute("behat_general::i_click_on", [get_string('participants'), 'link']); + } $this->execute("behat_forms::press_button", get_string('enrolusers', 'enrol')); diff --git a/enrol/tests/behat/enrol_user.feature b/enrol/tests/behat/enrol_user.feature index 9cf5313cfbb..c7d82f8339b 100644 --- a/enrol/tests/behat/enrol_user.feature +++ b/enrol/tests/behat/enrol_user.feature @@ -16,12 +16,11 @@ Feature: User can be enrolled into a course Scenario: User can be enrolled without javascript When I enrol "Studie One" user as "Student" - And I am on "Course 001" course homepage - And I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 001" "Enrolled users" page Then I should see "Studie One" @javascript Scenario: User can be enrolled with javascript enrol element When I enrol "Studie One" user as "Student" - And I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 001" "Enrolled users" page Then I should see "Studie One" diff --git a/enrol/tests/behat/role_visibility.feature b/enrol/tests/behat/role_visibility.feature index 794c17d36d1..2436984ea7b 100644 --- a/enrol/tests/behat/role_visibility.feature +++ b/enrol/tests/behat/role_visibility.feature @@ -21,8 +21,7 @@ Feature: Test role visibility for the participants page Scenario: Check the default roles are visible Given I log in as "manager1" - And I am on "Course 1" course homepage - When I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 1" "enrolled users" page Then "Learner 1" row "Roles" column of "participants" table should contain "Student" And "Teacher 1" row "Roles" column of "participants" table should contain "Teacher" And "Manager 1" row "Roles" column of "participants" table should contain "Manager" @@ -30,8 +29,7 @@ Feature: Test role visibility for the participants page Scenario: Do not allow managers to view any roles but manager and check they are hidden Given I log in as "teacher1" - And I am on "Course 1" course homepage - When I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 1" "enrolled users" page Then "Learner 1" row "Roles" column of "participants" table should contain "Student" And "Teacher 1" row "Roles" column of "participants" table should contain "Teacher" And "Manager 1" row "Roles" column of "participants" table should not contain "Manager" diff --git a/enrol/upgrade.txt b/enrol/upgrade.txt index 7f915ccf196..cc7d5eb806a 100644 --- a/enrol/upgrade.txt +++ b/enrol/upgrade.txt @@ -6,6 +6,7 @@ information provided here is intended especially for developers. * Final deprecation of the following webservice: * core_enrol_edit_user_enrolment * External function core_enrol_external::get_users_courses now returns the last time a course was modified (timemodified field) +* The behat step i_add_enrolment_method_with() has been deprecated. Please use the new method i_add_enrolment_method_for_with() === 3.11 === diff --git a/grade/lib.php b/grade/lib.php index 491d92e2a5c..d2dfff27b64 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -2854,7 +2854,8 @@ function grade_button($type, $courseid, $object) { function grade_extend_settings($plugininfo, $courseid) { global $PAGE; - $gradenode = $PAGE->settingsnav->prepend(get_string('gradeadministration', 'grades'), null, navigation_node::TYPE_CONTAINER); + $gradenode = $PAGE->settingsnav->prepend(get_string('gradeadministration', 'grades'), null, navigation_node::TYPE_CONTAINER, + null, 'gradeadmin'); $strings = array_shift($plugininfo); diff --git a/grade/tests/behat/grade_average.feature b/grade/tests/behat/grade_average.feature index b9da0a4554c..53f04f129cd 100644 --- a/grade/tests/behat/grade_average.feature +++ b/grade/tests/behat/grade_average.feature @@ -42,8 +42,7 @@ Feature: Average grades are displayed in the gradebook And I press "Save changes" And I turn editing mode off # Suspend a user - And I am on "Course 1" course homepage - And I navigate to "Users > Enrolled users" in current page administration + And I am on the "Course 1" "enrolled users" page And I click on "Edit enrolment" "link" in the "Student 2" "table_row" And I set the following fields to these values: | Status | Suspended | diff --git a/group/tests/behat/auto_creation.feature b/group/tests/behat/auto_creation.feature index 4add86d6c83..ab49a212e74 100644 --- a/group/tests/behat/auto_creation.feature +++ b/group/tests/behat/auto_creation.feature @@ -37,8 +37,7 @@ Feature: Automatic creation of groups | student10 | C1 | student | 0 | | suspendedstudent11 | C1 | student | 1 | And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page When I press "Auto-create groups" And I expand all fieldsets @@ -171,8 +170,7 @@ Feature: Automatic creation of groups | moodle/course:viewsuspendedusers | Prevent | And I log out And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page When I press "Auto-create groups" Then I should not see "Include only active enrolments" And I set the field "Group/member count" to "11" diff --git a/group/tests/behat/create_groups.feature b/group/tests/behat/create_groups.feature index 19d12b7ec2a..359d502c341 100644 --- a/group/tests/behat/create_groups.feature +++ b/group/tests/behat/create_groups.feature @@ -24,8 +24,7 @@ Feature: Organize students into groups | student2 | C1 | student | | student3 | C1 | student | And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Create group" And I set the following fields to these values: | Group name | Group 1 | @@ -77,8 +76,7 @@ Feature: Organize students into groups And the following config values are set as admin: | showuseridentity | email,country | And I log in as "teacher" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Create group" And I set the following fields to these values: | Group name | Group 1 | @@ -106,8 +104,7 @@ Feature: Organize students into groups | moodle/course:changeidnumber | Prevent | And I log out And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page When I press "Create group" Then the "idnumber" "field" should be readonly And I set the following fields to these values: @@ -128,8 +125,7 @@ Feature: Organize students into groups | Course 1 | C1 | 0 | 1 | | Course 2 | C2 | 0 | 1 | And I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page When I press "Create group" And I set the following fields to these values: | Group name | Group A | @@ -150,8 +146,7 @@ Feature: Organize students into groups | Enrolment key | Abcdef-2 | And I press "Save changes" And the "groups" select box should contain "Group B (0)" - And I am on "Course 2" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 2" "groups" page And I press "Create group" And I set the following fields to these values: | Group name | Group A | diff --git a/group/tests/behat/custom_fields.feature b/group/tests/behat/custom_fields.feature index 04770b4ef79..25c8e407f61 100644 --- a/group/tests/behat/custom_fields.feature +++ b/group/tests/behat/custom_fields.feature @@ -30,8 +30,8 @@ Feature: Custom profile fields in groups @javascript Scenario: Check the custom profile fields show up and can be searched on - When I am on the "C1" "Course" page logged in as "admin" - And I navigate to "Users > Groups" in current page administration + When I am logged in as "admin" + And I am on the "Course 1" "groups" page # Check the Overview page. And I select "Overview" from the "jump" singleselect diff --git a/group/tests/behat/delete_groups.feature b/group/tests/behat/delete_groups.feature index 5ea03280e5b..d1684d1973d 100644 --- a/group/tests/behat/delete_groups.feature +++ b/group/tests/behat/delete_groups.feature @@ -15,8 +15,7 @@ Feature: Automatic deletion of groups and groupings | user | course | role | | teacher1 | C1 | editingteacher | And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Create group" And I set the following fields to these values: | Group name | Group (without ID) | @@ -64,8 +63,7 @@ Feature: Automatic deletion of groups and groupings | moodle/course:changeidnumber | Prevent | And I log out And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page When I set the field "groups" to "Group (with ID) (0)" Then the "Delete selected group" "button" should be disabled And I set the field "groups" to "Group (without ID) (0)" diff --git a/group/tests/behat/group_description.feature b/group/tests/behat/group_description.feature index c4589fda461..94ebc4b6789 100644 --- a/group/tests/behat/group_description.feature +++ b/group/tests/behat/group_description.feature @@ -27,7 +27,7 @@ Feature: The description of a group can be viewed by students and teachers And I set the following fields to these values: | Group mode | Visible groups | And I press "Save and display" - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Create group" And I set the following fields to these values: | Group name | Group A | @@ -76,7 +76,7 @@ Feature: The description of a group can be viewed by students and teachers And I set the following fields to these values: | Group mode | Separate groups | And I press "Save and display" - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Create group" And I set the following fields to these values: | Group name | Group A | diff --git a/group/tests/behat/groups_import.feature b/group/tests/behat/groups_import.feature index a9567da2c05..0c738ae850e 100644 --- a/group/tests/behat/groups_import.feature +++ b/group/tests/behat/groups_import.feature @@ -20,8 +20,7 @@ Feature: Importing of groups and groupings @javascript Scenario: Import groups and groupings as teacher Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Import groups" When I upload "group/tests/fixtures/groups_import.csv" file to "Import" filemanager And I press "Import groups" @@ -55,8 +54,7 @@ Feature: Importing of groups and groupings @javascript Scenario: Import groups with idnumber when the user has proper permissions for the idnumber field Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Import groups" When I upload "group/tests/fixtures/groups_import.csv" file to "Import" filemanager And I press "Import groups" @@ -91,14 +89,12 @@ Feature: Importing of groups and groupings @javascript Scenario: Import groups with idnumber when the user does not have proper permissions for the idnumber field Given I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 1" "permissions" page And I override the system permissions of "Teacher" role with: | moodle/course:changeidnumber | Prevent | And I log out And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Import groups" When I upload "group/tests/fixtures/groups_import.csv" file to "Import" filemanager And I press "Import groups" @@ -127,8 +123,7 @@ Feature: Importing of groups and groupings @javascript Scenario: Import groups into multiple courses as a teacher Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Import groups" When I upload "group/tests/fixtures/groups_import_multicourse.csv" file to "Import" filemanager And I press "Import groups" @@ -144,8 +139,7 @@ Feature: Importing of groups and groupings And I should see "group8" And I should not see "group9" And I should not see "group-will-not-be-created" - And I am on "Course 2" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 2" "groups" page And I should see "group9" And I should not see "group-will-not-be-created" And I should not see "group7" diff --git a/group/tests/behat/id_uniqueness.feature b/group/tests/behat/id_uniqueness.feature index f203f269c2d..53583b03cf3 100644 --- a/group/tests/behat/id_uniqueness.feature +++ b/group/tests/behat/id_uniqueness.feature @@ -15,8 +15,7 @@ Feature: Uniqueness of Group ID number | user | course | role | | teacher1 | C1 | editingteacher | And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page Scenario: Group ID number uniqueness Given I press "Create group" diff --git a/group/tests/behat/overview.feature b/group/tests/behat/overview.feature index 53bbc17de49..388a3e0a1bd 100644 --- a/group/tests/behat/overview.feature +++ b/group/tests/behat/overview.feature @@ -57,8 +57,7 @@ Feature: Group overview Scenario: Filter the overview in various different ways Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I select "Overview" from the "jump" singleselect # Grouping All and Group All filter diff --git a/group/tests/behat/role_visibility.feature b/group/tests/behat/role_visibility.feature index b160511d1df..ab466c2827c 100644 --- a/group/tests/behat/role_visibility.feature +++ b/group/tests/behat/role_visibility.feature @@ -29,8 +29,7 @@ Feature: Test role visibility for the groups management page Scenario: Check the default roles are visible Given I log in as "manager1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page When I set the field "groups" to "Group 1 (3)" And I press "Show members for group" Then "optgroup[label='No roles']" "css_element" should not exist in the "#members" "css_element" @@ -41,8 +40,7 @@ Feature: Test role visibility for the groups management page Scenario: Do not allow managers to view any roles and check they are hidden Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page When I set the field "groups" to "Group 1 (3)" And I press "Show members for group" Then "optgroup[label='No roles']" "css_element" should exist in the "#members" "css_element" diff --git a/group/tests/behat/update_groups.feature b/group/tests/behat/update_groups.feature index 92440ef1219..b3b6bfb4d1a 100644 --- a/group/tests/behat/update_groups.feature +++ b/group/tests/behat/update_groups.feature @@ -15,8 +15,7 @@ Feature: Automatic updating of groups and groupings | user | course | role | | teacher1 | C1 | editingteacher | And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Create group" And I set the following fields to these values: | Group name | Group (without ID) | @@ -71,8 +70,7 @@ Feature: Automatic updating of groups and groupings | moodle/course:changeidnumber | Prevent | And I log out And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I set the field "groups" to "Group (with ID)" When I press "Edit group settings" Then the "idnumber" "field" should be readonly @@ -108,8 +106,7 @@ Feature: Automatic updating of groups and groupings | teacher1 | C2 | editingteacher | And I log out And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I set the field "groups" to "Group (with ID)" And I press "Edit group settings" And I set the following fields to these values: @@ -133,8 +130,7 @@ Feature: Automatic updating of groups and groupings | Enrolment key | Abcdef-2 | And I press "Save changes" And I should not see "This enrolment key is already used for another group." - And I am on "Course 2" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 2" "groups" page And I press "Create group" And I set the following fields to these values: | Group name | Group A | diff --git a/lang/en/course.php b/lang/en/course.php index 6ee211138a9..bc6624b2d21 100644 --- a/lang/en/course.php +++ b/lang/en/course.php @@ -46,6 +46,8 @@ $string['aria:favourite'] = 'Course is starred'; $string['aria:favouritestab'] = 'Starred activities'; $string['aria:recommendedtab'] = 'Recommended activities'; $string['aria:modulefavourite'] = 'Star {$a} activity'; +$string['browsecourseadminindex'] = 'Browse the course administration with this index.'; +$string['browsesettingindex'] = 'Browse settings with this index.'; $string['completion_automatic:done'] = 'Done:'; $string['completion_automatic:failed'] = 'Failed:'; $string['completion_automatic:todo'] = 'To do:'; diff --git a/lib/classes/navigation/views/secondary.php b/lib/classes/navigation/views/secondary.php index 48f885d7f13..2ff59feedc5 100644 --- a/lib/classes/navigation/views/secondary.php +++ b/lib/classes/navigation/views/secondary.php @@ -17,6 +17,7 @@ namespace core\navigation\views; use navigation_node; +use url_select; /** * Class secondary_navigation_view. @@ -36,6 +37,9 @@ class secondary extends view { /** @var int The maximum limit of navigation nodes displayed in the secondary navigation */ const MAX_DISPLAYED_NAV_NODES = 5; + /** @var navigation_node The course overflow node. */ + protected $courseoverflownode = null; + /** * Defines the default structure for the secondary nav in a course context. * @@ -252,13 +256,15 @@ class secondary extends view { if ($child->has_children()) { $additionalchildren = true; - $urldata[][$child->text] = $additionalnode + $this->get_additional_child_nodes($child); + $text = (is_a($child->text, 'lang_string')) ? $child->text->out() : $child->text; + $urldata[][$text] = $additionalnode + $this->get_additional_child_nodes($child); } else { $initialchildren += $additionalnode; } } if ($additionalchildren) { - $urldata[][$node->text] = $initialchildren; + $text = (is_a($node->text, 'lang_string')) ? $node->text->out() : $node->text; + $urldata[][$text] = $initialchildren; } else { $urldata = $initialchildren; } @@ -326,6 +332,30 @@ class secondary extends view { return $newnode; } + /** + * Returns a list of all expected nodes in the course administration. + * + * @return array An array of keys for navigation nodes in the course administration. + */ + protected function get_expected_course_admin_nodes(): array { + $expectednodes = []; + foreach ($this->get_default_course_mapping()['settings'] as $value) { + foreach ($value as $nodekey => $notused) { + $expectednodes[] = $nodekey; + } + } + foreach ($this->get_default_course_mapping()['navigation'] as $value) { + foreach ($value as $nodekey => $notused) { + $expectednodes[] = $nodekey; + } + } + $othernodes = ['users', 'gradeadmin', 'coursereports', 'coursebadges']; + $leftovercourseadminnodes = ['backup', 'restore', 'import', 'copy', 'reset']; + $expectednodes = array_merge($expectednodes, $othernodes); + $expectednodes = array_merge($expectednodes, $leftovercourseadminnodes); + return $expectednodes; + } + /** * Load the course secondary navigation. Since we are sourcing all the info from existing objects that already do * the relevant checks, we don't do it again here. @@ -345,17 +375,9 @@ class secondary extends view { $nodesordered += $this->get_leaf_nodes($navigation, $nodes['navigation'] ?? []); $this->add_ordered_nodes($nodesordered); - $coursecontext = \context_course::instance($course->id); - if (has_capability('moodle/course:update', $coursecontext)) { - // All additional nodes will be available under the 'Course admin' page. - $text = get_string('courseadministration'); - $url = new \moodle_url('/course/admin.php', array('courseid' => $this->page->course->id)); - $this->add($text, $url, null, null, 'courseadmin', new \pix_icon('t/edit', $text)); - } - // Try to get any custom nodes defined by a user which may include containers. - $expectedcourseadmin = ['editsettings', 'coursecompletion', 'users', 'coursereports', 'gradebooksetup', 'coursebadges', - 'backup', 'restore', 'import', 'copy', 'reset', 'questionbank']; + $expectedcourseadmin = $this->get_expected_course_admin_nodes(); + foreach ($settingsnav->children as $value) { if ($value->key == 'courseadmin') { foreach ($value->children as $other) { @@ -363,12 +385,76 @@ class secondary extends view { $othernode = $this->get_first_action_for_node($other); // Get the first node and check whether it's been added already. if ($othernode && !$this->get($othernode->key)) { - $this->add_node(clone $othernode); + $this->add_node($othernode); + } else { + $this->add_node($other); } } } } } + + $coursecontext = \context_course::instance($course->id); + if (has_capability('moodle/course:update', $coursecontext)) { + $overflownode = $this->get_course_overflow_nodes(); + if (is_null($overflownode)) { + return; + } + $actionnode = $this->get_first_action_for_node($overflownode); + // All additional nodes will be available under the 'Course admin' page. + $text = get_string('courseadministration'); + $this->add($text, $actionnode->action, null, null, 'courseadmin', new \pix_icon('t/edit', $text)); + } + } + + /** + * Gets the overflow navigation nodes for the course administration category. + * + * @return navigation_node The course overflow nodes. + */ + protected function get_course_overflow_nodes(): ?navigation_node { + global $SITE; + + // This gets called twice on some pages, and so trying to create this navigation node twice results in no children being + // present the second time this is called. + if (isset($this->courseoverflownode)) { + return $this->courseoverflownode; + } + + // Start with getting the base node for the front page or the course. + $node = null; + if ($this->page->course == $SITE->id) { + $node = $this->page->settingsnav->find('frontpage', navigation_node::TYPE_SETTING); + } else { + $node = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE); + } + $coursesettings = $node->get_children_key_list(); + $thissettings = $this->get_children_key_list(); + $diff = array_diff($coursesettings, $thissettings); + + // Remove our specific created elements (user - participants, badges - coursebadges, grades - gradebooksetup). + $shortdiff = array_filter($diff, function($value) { + return !($value == 'users' || $value == 'coursebadges' || $value == 'gradebooksetup'); + }); + + // Permissions may be in play here that ultimately will show no overflow. + if (empty($shortdiff)) { + return null; + } + + $firstitem = array_shift($shortdiff); + $navnode = $node->get($firstitem); + foreach ($shortdiff as $key) { + $courseadminnodes = $node->get($key); + if ($courseadminnodes) { + if ($courseadminnodes->parent->key == $node->key) { + $navnode->add_node($courseadminnodes); + } + } + } + $this->courseoverflownode = $navnode; + return $navnode; + } /** @@ -398,28 +484,100 @@ class secondary extends view { /** * Returns a url_select object with overflow navigation nodes. + * This looks to see if the current page is within the course administration, or some other page that requires an overflow + * select object. * - * @return \url_select|null The overflow menu data. + * @return url_select|null The overflow menu data. */ - public function get_overflow_menu_data(): ?\url_select { + public function get_overflow_menu_data(): ?url_select { $activenode = $this->find_active_node(); - if ($activenode && $activenode->has_action() && $activenode->has_children() && $activenode->key != 'coursehome') { - // This needs to be expanded to does the active node have children and does the page url match any of the children. - $menunode = $this->page->settingsnav->find($activenode->key, null); - if ($menunode instanceof navigation_node) { - // Loop through all children and try and find a match to the current url. - $matchednode = $this->nodes_match_current_url($menunode); - if (is_null($matchednode)) { - return null; - } - if (!isset($menunode) || !$menunode->has_children()) { - return null; - } - $selectdata = $this->get_menu_array($menunode); - return new \url_select($selectdata, $matchednode->action->out(), null); + $incourseadmin = false; + + if (!$activenode) { + // Could be in the course admin section. + $courseadmin = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE); + if (!$courseadmin) { + return null; } + + $activenode = $courseadmin->find_active_node(); + if (!$activenode) { + return null; + } + $incourseadmin = true; } - return null; + + if ($activenode->key == 'courseadmin' || $incourseadmin) { + $courseoverflownode = $this->get_course_overflow_nodes(); + if (is_null($courseoverflownode)) { + return null; + } + $menuarray = $this->get_menu_array($courseoverflownode); + if ($activenode->key != 'courseadmin') { + $inmenu = false; + foreach ($menuarray as $key => $value) { + if ($this->page->url->out(false) == $key) { + $inmenu = true; + } + } + if (!$inmenu) { + return null; + } + } + $menuselect = new url_select($menuarray, $this->page->url, null); + $menuselect->set_label(get_string('browsecourseadminindex', 'course'), ['class' => 'sr-only']); + return $menuselect; + } else { + return $this->get_other_overflow_menu_data($activenode); + } + } + + /** + * Gets overflow menu data for third party plugin settings. + * + * @param navigation_node $activenode The node to gather the children for to put into the overflow menu. + * @return url_select|null The overflow menu in a url_select object. + */ + protected function get_other_overflow_menu_data(navigation_node $activenode): ?url_select { + if (!$activenode->has_action()) { + return null; + } + + if (!$activenode->has_children()) { + return null; + } + + // If the setting is extending the course navigation then the page being redirected to should be in the course context. + // It was decided on the issue that put this code here that plugins that extend the course navigation should have the pages + // that are redirected to, be in the course context or module context depending on which callback was used. + // Third part plugins were checked to see if any existing plugins had settings in a system context and none were found. + // The request of third party developers is to keep their settings within the specified context. + if ($this->page->context->contextlevel != CONTEXT_COURSE && $this->page->context->contextlevel != CONTEXT_MODULE) { + return null; + } + + // These areas have their own code to retrieve added plugin navigation nodes. + if ($activenode->key == 'coursehome' || $activenode->key == 'questionbank' || $activenode->key == 'coursereports') { + return null; + } + + $menunode = $this->page->settingsnav->find($activenode->key, null); + + if (!$menunode instanceof navigation_node) { + return null; + } + // Loop through all children and try and find a match to the current url. + $matchednode = $this->nodes_match_current_url($menunode); + if (is_null($matchednode)) { + return null; + } + if (!isset($menunode) || !$menunode->has_children()) { + return null; + } + $selectdata = $this->get_menu_array($menunode); + $urlselect = new url_select($selectdata, $matchednode->action->out(), null); + $urlselect->set_label(get_string('browsesettingindex', 'course'), ['class' => 'sr_only']); + return $urlselect; } /** diff --git a/lib/classes/navigation/views/view.php b/lib/classes/navigation/views/view.php index 13a4fc68040..968d8ec18c0 100644 --- a/lib/classes/navigation/views/view.php +++ b/lib/classes/navigation/views/view.php @@ -131,7 +131,6 @@ abstract class view extends navigation_node { // If node is one of the new views then set the active node to the child. if (!$node instanceof view) { $node->make_active(); - $child->make_inactive(); $result = $node; } else { $child->make_active(); diff --git a/lib/navigationlib.php b/lib/navigationlib.php index d73b83d5708..6b0170f5ae3 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -4561,6 +4561,12 @@ class settings_navigation extends navigation_node { badges_add_course_navigation($coursenode, $course); } + // Import data from other courses. + if ($adminoptions->import) { + $url = new moodle_url('/backup/import.php', array('id' => $course->id)); + $coursenode->add(get_string('import'), $url, self::TYPE_SETTING, null, 'import', new pix_icon('i/import', '')); + } + // Backup this course if ($adminoptions->backup) { $url = new moodle_url('/backup/backup.php', array('id'=>$course->id)); @@ -4573,12 +4579,6 @@ class settings_navigation extends navigation_node { $coursenode->add(get_string('restore'), $url, self::TYPE_SETTING, null, 'restore', new pix_icon('i/restore', '')); } - // Import data from other courses - if ($adminoptions->import) { - $url = new moodle_url('/backup/import.php', array('id'=>$course->id)); - $coursenode->add(get_string('import'), $url, self::TYPE_SETTING, null, 'import', new pix_icon('i/import', '')); - } - // Copy this course. if ($adminoptions->copy) { $url = new moodle_url('/backup/copy.php', array('id' => $course->id)); diff --git a/lib/tests/behat/behat_deprecated.php b/lib/tests/behat/behat_deprecated.php index c54e5f70457..49009d0e482 100644 --- a/lib/tests/behat/behat_deprecated.php +++ b/lib/tests/behat/behat_deprecated.php @@ -148,4 +148,43 @@ class behat_deprecated extends behat_base { $this->execute("behat_general::i_click_on", array($xpath, "xpath_element")); $this->execute("behat_general::wait_until_the_page_is_ready"); } + + /** + * Adds the specified enrolment method to the current course filling the form with the provided data. + * + * @Given /^I add "(?P(?:[^"]|\\")*)" enrolment method with:$/ + * @param string $enrolmethod + * @param TableNode $table + * + * @deprecated since 4.0 MDL-72090. We now need the course to enrol in. Please use i_add_enrolment_method_for_with() + * @todo MDL-71733 This will be deleted in Moodle 4.4. + */ + public function i_add_enrolment_method_with($enrolmethod, TableNode $table) { + $this->deprecated_message(['i_add_enrolment_method_for_with']); + + // Navigate to enrolment method page. + $parentnodes = get_string('users', 'admin'); + $this->execute("behat_navigation::i_navigate_to_in_current_page_administration", + array($parentnodes .' > '. get_string('type_enrol_plural', 'plugin')) + ); + + // Select enrolment method. + $this->execute('behat_forms::i_select_from_the_singleselect', + array($this->escape($enrolmethod), get_string('addinstance', 'enrol')) + ); + + // Wait again, for page to reloaded. + $this->execute('behat_general::i_wait_to_be_redirected'); + + // Set form fields. + $this->execute("behat_forms::i_set_the_following_fields_to_these_values", $table); + + // Ensure we get button in focus, before pressing button. + if ($this->running_javascript()) { + $this->execute('behat_general::i_press_named_key', ['', 'tab']); + } + + // Save changes. + $this->execute("behat_forms::press_button", get_string('addinstance', 'enrol')); + } } diff --git a/lib/tests/behat/behat_navigation.php b/lib/tests/behat/behat_navigation.php index a0e405310ac..f66492b1d08 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -736,11 +736,20 @@ class behat_navigation extends behat_base { * Recognised page names are: * | Page type | Identifier meaning | description | * | Category | category idnumber | List of courses in that category. | - * | Course | course shortname | Main course home pag | + * | Course | course shortname | Main course home page | * | Activity | activity idnumber | Start page for that activity | * | Activity editing | activity idnumber | Edit settings page for that activity | * | [modname] Activity | activity name or idnumber | Start page for that activity | * | [modname] Activity editing | activity name or idnumber | Edit settings page for that activity | + * | Backup | course shortname | Course to backup | + * | Import | course shortname | Course import from | + * | Restore | course shortname | Course to restore from | + * | Reset | course shortname | Course to reset | + * | Course copy | course shortname | Course to copy | + * | Groups | course shortname | Groups page for the course | + * | Permissions | course shortname | Permissions page for the course | + * | Enrolment methods | course shortname | Enrolment methods for the course | + * | Enrolled users | course shortname | The main participants page | * * Examples: * @@ -787,6 +796,71 @@ class behat_navigation extends behat_base { return new moodle_url('/course/modedit.php', [ 'update' => $cm->id, ]); + case 'backup': + $courseid = $this->get_course_id($identifier); + if (!$courseid) { + throw new Exception('The specified course with shortname, fullname, or idnumber "' . + $identifier . '" does not exist'); + } + return new moodle_url('/backup/backup.php', ['id' => $courseid]); + case 'import': + $courseid = $this->get_course_id($identifier); + if (!$courseid) { + throw new Exception('The specified course with shortname, fullname, or idnumber "' . + $identifier . '" does not exist'); + } + return new moodle_url('/backup/import.php', ['id' => $courseid]); + case 'restore': + $courseid = $this->get_course_id($identifier); + if (!$courseid) { + throw new Exception('The specified course with shortname, fullname, or idnumber "' . + $identifier . '" does not exist'); + } + $context = context_course::instance($courseid); + return new moodle_url('/backup/restorefile.php', ['contextid' => $context->id]); + case 'reset': + $courseid = $this->get_course_id($identifier); + if (!$courseid) { + throw new Exception('The specified course with shortname, fullname, or idnumber "' . + $identifier . '" does not exist'); + } + return new moodle_url('/course/reset.php', ['id' => $courseid]); + case 'course copy': + $courseid = $this->get_course_id($identifier); + if (!$courseid) { + throw new Exception('The specified course with shortname, fullname, or idnumber "' . + $identifier . '" does not exist'); + } + return new moodle_url('/backup/copy.php', ['id' => $courseid]); + case 'groups': + $courseid = $this->get_course_id($identifier); + if (!$courseid) { + throw new Exception('The specified course with shortname, fullname, or idnumber "' . + $identifier . '" does not exist'); + } + return new moodle_url('/group/index.php', ['id' => $courseid]); + case 'permissions': + $courseid = $this->get_course_id($identifier); + if (!$courseid) { + throw new Exception('The specified course with shortname, fullname, or idnumber "' . + $identifier . '" does not exist'); + } + $context = context_course::instance($courseid); + return new moodle_url('/admin/roles/permissions.php', ['contextid' => $context->id]); + case 'enrolment methods': + $courseid = $this->get_course_id($identifier); + if (!$courseid) { + throw new Exception('The specified course with shortname, fullname, or idnumber "' . + $identifier . '" does not exist'); + } + return new moodle_url('/enrol/instances.php', ['id' => $courseid]); + case 'enrolled users': + $courseid = $this->get_course_id($identifier); + if (!$courseid) { + throw new Exception('The specified course with shortname, fullname, or idnumber "' . + $identifier . '" does not exist'); + } + return new moodle_url('/user/index.php', ['id' => $courseid]); } $parts = explode(' ', $type); diff --git a/lib/tests/behat/behat_permissions.php b/lib/tests/behat/behat_permissions.php index 6dc2e873e1a..ec41faeb4a0 100644 --- a/lib/tests/behat/behat_permissions.php +++ b/lib/tests/behat/behat_permissions.php @@ -81,7 +81,12 @@ class behat_permissions extends behat_base { ); if (!$this->running_javascript()) { - $this->execute("behat_general::i_click_on_in_the", [get_string('go'), 'button', "div.advancedoverride", 'css_element']); + $xpath = "//div[@class='advancedoverride']/div/form/noscript"; + $this->execute("behat_general::i_click_on_in_the", [ + get_string('go'), 'button', + $this->escape($xpath), + 'xpath_element'] + ); } $this->execute("behat_permissions::i_fill_the_capabilities_form_with_the_following_permissions", $table); diff --git a/lib/tests/behat/permissionmanager.feature b/lib/tests/behat/permissionmanager.feature index 060a267ac57..77841030f38 100644 --- a/lib/tests/behat/permissionmanager.feature +++ b/lib/tests/behat/permissionmanager.feature @@ -16,8 +16,7 @@ Feature: Override permissions on a context | teacher1 | C1 | editingteacher | Scenario: Default system capabilities modification - Given I am on the "C1" "Course" page logged in as "admin" - And I navigate to "Users > Permissions" in current page administration + Given I am on the "C1" "permissions" page logged in as "admin" When I click on "Allow" "icon" in the "mod/forum:addnews" "table_row" And I press "Student" Then "Add announcementsmod/forum:addnews" row "Roles with permission" column of "permissions" table should contain "Student" diff --git a/lib/tests/navigation/views/secondary_test.php b/lib/tests/navigation/views/secondary_test.php index 981ea79847c..a2d5d34288a 100644 --- a/lib/tests/navigation/views/secondary_test.php +++ b/lib/tests/navigation/views/secondary_test.php @@ -18,6 +18,7 @@ namespace core\navigation\views; use navigation_node; use ReflectionMethod; +use moodle_url; /** * Class core_secondary_testcase @@ -738,6 +739,8 @@ class secondary_test extends \advanced_testcase { */ public function test_get_overflow_menu_data(string $selectedurl, bool $expectednull, bool $emptynode = false) { global $PAGE; + + $this->resetAfterTest(); // Custom nodes - mimicing nodes added via 3rd party plugins. $structure = [ 'parentnode1' => [ @@ -752,6 +755,11 @@ class secondary_test extends \advanced_testcase { ], 'parentnode2' => "/view/module.php" ]; + + $course = $this->getDataGenerator()->create_course(); + $context = \context_course::instance($course->id); + $PAGE->set_context($context); + $PAGE->set_url($selectedurl); navigation_node::override_active_url(new \moodle_url($selectedurl)); $node = $this->generate_node_tree_construct($structure, 'primarynode'); @@ -815,4 +823,95 @@ class secondary_test extends \advanced_testcase { ], ]; } + + /** + * Test the course administration settings return an overflow menu. + * + * @dataProvider test_get_overflow_menu_data_course_admin_provider + * @param string $url Url of the page we are testing. + * @param string $contextidentifier id or contextid or something similar. + * @param bool $expected The expected return. True to return the overflow menu otherwise false for nothing. + */ + public function test_get_overflow_menu_data_course_admin(string $url, string $contextidentifier, bool $expected): void { + global $PAGE; + $this->resetAfterTest(); + $this->setAdminUser(); + + $pagecourse = $this->getDataGenerator()->create_course(); + $contextrecord = \context_course::instance($pagecourse->id, MUST_EXIST); + + $id = ($contextidentifier == 'contextid') ? $contextrecord->id : $pagecourse->id; + + $pageurl = new \moodle_url($url, [$contextidentifier => $id]); + $PAGE->set_url($pageurl); + navigation_node::override_active_url($pageurl); + $PAGE->set_course($pagecourse); + $PAGE->set_context($contextrecord); + + $node = new secondary($PAGE); + $node->initialise(); + $result = $node->get_overflow_menu_data(); + if ($expected) { + $this->assertInstanceOf('url_select', $result); + $this->assertTrue($pageurl->compare($result->selected)); + } else { + $this->assertNull($result); + } + } + + /** + * Data provider for the other half of the method thing + * + * @return array Provider information. + */ + public function test_get_overflow_menu_data_course_admin_provider(): array { + return [ + "Backup page returns overflow" => [ + '/backup/backup.php', + 'id', + true + ], + "Restore course page returns overflow" => [ + '/backup/restorefile.php', + 'contextid', + true + ], + "Import course page returns overflow" => [ + '/backup/import.php', + 'id', + true + ], + "Course copy page returns overflow" => [ + '/backup/copy.php', + 'id', + true + ], + "Course reset page returns overflow" => [ + '/course/reset.php', + 'id', + true + ], + // The following pages should not return the overflow menu. + "Course page returns nothing" => [ + '/course/view.php', + 'id', + false + ], + "Question bank should return nothing" => [ + '/question/edit.php', + 'courseid', + false + ], + "Reports should return nothing" => [ + '/report/log/index.php', + 'id', + false + ], + "Participants page should return nothing" => [ + '/user/index.php', + 'id', + false + ] + ]; + } } diff --git a/message/tests/behat/group_conversation.feature b/message/tests/behat/group_conversation.feature index bde9a02d87d..7974763a8f5 100644 --- a/message/tests/behat/group_conversation.feature +++ b/message/tests/behat/group_conversation.feature @@ -92,8 +92,7 @@ Feature: Create conversations for course's groups Scenario: Check group conversation members are synced when a new group member is added Given I log in as "teacher1" - Then I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + Then I am on the "Course 1" "groups" page And I add "Student 4 (student4@example.com)" user to "Group 1" group members And I add "Student 4 (student4@example.com)" user to "Group 2" group members And I open messaging diff --git a/mod/assign/tests/behat/assign_course_reset.feature b/mod/assign/tests/behat/assign_course_reset.feature index 61fe1708e6e..56aa029f3f9 100644 --- a/mod/assign/tests/behat/assign_course_reset.feature +++ b/mod/assign/tests/behat/assign_course_reset.feature @@ -46,8 +46,7 @@ Feature: Assign reset And I am on the "Test assignment name" Activity page logged in as teacher1 And I follow "View all submissions" And I should see "Submitted for grading" - And I am on "Course 1" course homepage - When I navigate to "Reset" in current page administration + When I am on the "Course 1" "reset" page And I set the following fields to these values: | Delete all submissions | 1 | And I press "Reset course" @@ -72,8 +71,7 @@ Feature: Assign reset | duedate[minute] | 00 | And I press "Save" And I should see "Sam1 Student1" - And I am on "Course 1" course homepage - And I navigate to "Reset" in current page administration + When I am on the "Course 1" "reset" page And I set the following fields to these values: | Delete all user overrides | 1 | And I press "Reset course" @@ -98,8 +96,7 @@ Feature: Assign reset | duedate[minute] | 00 | And I press "Save" And I should see "Group 1" - And I am on "Course 1" course homepage - And I navigate to "Reset" in current page administration + And I am on the "Course 1" "reset" page And I set the following fields to these values: | Delete all group overrides | 1 | And I press "Reset course" @@ -120,8 +117,7 @@ Feature: Assign reset And I select "Reveal student identities" from the "Grading action" singleselect And I press "Continue" And I should see "Sam1 Student1" - And I am on "Course 1" course homepage - When I navigate to "Reset" in current page administration + When I am on the "Course 1" "reset" page And I set the following fields to these values: | Delete all submissions | 1 | And I press "Reset course" diff --git a/mod/assign/tests/behat/assign_no_calendar_capabilities.feature b/mod/assign/tests/behat/assign_no_calendar_capabilities.feature index b8c119d6d41..0dd623b4a1c 100644 --- a/mod/assign/tests/behat/assign_no_calendar_capabilities.feature +++ b/mod/assign/tests/behat/assign_no_calendar_capabilities.feature @@ -14,8 +14,7 @@ Feature: Assignment with no calendar capabilites And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | - And I am on the "C1" Course page logged in as admin - And I navigate to "Users > Permissions" in current page administration + And I am on the "C1" "permissions" page logged in as admin And I override the system permissions of "Teacher" role with: | capability | permission | | moodle/calendar:manageentries | Prohibit | diff --git a/mod/chat/tests/behat/chat_course_reset.feature b/mod/chat/tests/behat/chat_course_reset.feature index a47591a96c5..1d0807e8655 100644 --- a/mod/chat/tests/behat/chat_course_reset.feature +++ b/mod/chat/tests/behat/chat_course_reset.feature @@ -38,8 +38,7 @@ Feature: Chat reset | chattime[hour] | 12 | | chattime[minute] | 00 | And I press "Save and display" - And I am on "Course 1" course homepage - When I navigate to "Reset" in current page administration + And I am on the "Course 1" "reset" page And I set the following fields to these values: | reset_start_date[enabled] | 1 | | reset_start_date[day] | 1 | diff --git a/mod/chat/tests/behat/chat_no_calendar_capabilities.feature b/mod/chat/tests/behat/chat_no_calendar_capabilities.feature index 3feec4b7e06..28d243234a7 100644 --- a/mod/chat/tests/behat/chat_no_calendar_capabilities.feature +++ b/mod/chat/tests/behat/chat_no_calendar_capabilities.feature @@ -22,8 +22,7 @@ Feature: Chat with no calendar capabilites | intro | Test chat description | | section | 1 | And I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 1" "permissions" page And I override the system permissions of "Teacher" role with: | capability | permission | | moodle/calendar:manageentries | Prohibit | diff --git a/mod/choice/tests/behat/choice_no_calendar_capabilities.feature b/mod/choice/tests/behat/choice_no_calendar_capabilities.feature index fd7ac210b0b..9ecbc749011 100644 --- a/mod/choice/tests/behat/choice_no_calendar_capabilities.feature +++ b/mod/choice/tests/behat/choice_no_calendar_capabilities.feature @@ -15,8 +15,7 @@ Feature: Choice with no calendar capabilites | user | course | role | | teacher1 | C1 | editingteacher | And I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 1" "permissions" page And I override the system permissions of "Teacher" role with: | capability | permission | | moodle/calendar:manageentries | Prohibit | diff --git a/mod/data/tests/behat/data_no_calendar_capabilities.feature b/mod/data/tests/behat/data_no_calendar_capabilities.feature index 346539a04af..c6b1365d4b8 100644 --- a/mod/data/tests/behat/data_no_calendar_capabilities.feature +++ b/mod/data/tests/behat/data_no_calendar_capabilities.feature @@ -15,8 +15,7 @@ Feature: Database with no calendar capabilites | user | course | role | | teacher1 | C1 | editingteacher | And I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 1" "permissions" page And I override the system permissions of "Teacher" role with: | capability | permission | | moodle/calendar:manageentries | Prohibit | diff --git a/mod/feedback/tests/behat/feedback_no_calendar_capabilities.feature b/mod/feedback/tests/behat/feedback_no_calendar_capabilities.feature index 180e2bb421e..60b6459f9e4 100644 --- a/mod/feedback/tests/behat/feedback_no_calendar_capabilities.feature +++ b/mod/feedback/tests/behat/feedback_no_calendar_capabilities.feature @@ -15,8 +15,7 @@ Feature: Feedback with no calendar capabilites | user | course | role | | teacher1 | C1 | editingteacher | And I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 1" "permissions" page And I override the system permissions of "Teacher" role with: | capability | permission | | moodle/calendar:manageentries | Prohibit | diff --git a/mod/lesson/tests/behat/lesson_course_reset.feature b/mod/lesson/tests/behat/lesson_course_reset.feature index fb034c6f703..ef8362e5239 100644 --- a/mod/lesson/tests/behat/lesson_course_reset.feature +++ b/mod/lesson/tests/behat/lesson_course_reset.feature @@ -53,8 +53,7 @@ Feature: Lesson reset And I am on the "Test lesson name" "lesson activity" page logged in as teacher1 And I navigate to "Reports" in current page administration And I should see "Sam1 Student1" - And I am on "Course 1" course homepage - And I navigate to "Reset" in current page administration + And I am on the "Course 1" "reset" page And I set the following fields to these values: | Delete all lesson attempts | 1 | And I press "Reset course" @@ -74,8 +73,7 @@ Feature: Lesson reset | Re-takes allowed | 1 | And I press "Save" And I should see "Sam1 Student1" - And I am on "Course 1" course homepage - And I navigate to "Reset" in current page administration + And I am on the "Course 1" "reset" page And I set the following fields to these values: | Delete all user overrides | 1 | And I press "Reset course" @@ -93,8 +91,7 @@ Feature: Lesson reset | Re-takes allowed | 1 | And I press "Save" And I should see "Group 1" - And I am on "Course 1" course homepage - And I navigate to "Reset" in current page administration + And I am on the "Course 1" "reset" page And I set the following fields to these values: | Delete all group overrides | 1 | And I press "Reset course" diff --git a/mod/lesson/tests/behat/lesson_no_calendar_capabilities.feature b/mod/lesson/tests/behat/lesson_no_calendar_capabilities.feature index cafd68398e0..0ca2bc91b93 100644 --- a/mod/lesson/tests/behat/lesson_no_calendar_capabilities.feature +++ b/mod/lesson/tests/behat/lesson_no_calendar_capabilities.feature @@ -22,8 +22,7 @@ Feature: Lesson with no calendar capabilites | intro | Test lesson description | | section | 1 | And I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 1" "permissions" page And I override the system permissions of "Teacher" role with: | capability | permission | | moodle/calendar:manageentries | Prohibit | diff --git a/mod/quiz/tests/behat/backup.feature b/mod/quiz/tests/behat/backup.feature index f6fecacd111..cc8952e10e9 100644 --- a/mod/quiz/tests/behat/backup.feature +++ b/mod/quiz/tests/behat/backup.feature @@ -66,8 +66,7 @@ Feature: Backup and restore of quizzes @javascript @_file_upload Scenario: Restore a Moodle 2.8 quiz backup - When I am on "Course 1" course homepage - And I navigate to "Restore" in current page administration + When I am on the "Course 1" "restore" page And I press "Manage backup files" And I upload "mod/quiz/tests/fixtures/moodle_28_quiz.mbz" file to "Files" filemanager And I press "Save changes" diff --git a/mod/quiz/tests/behat/quiz_no_calendar_capabilities.feature b/mod/quiz/tests/behat/quiz_no_calendar_capabilities.feature index 1f117002cf6..d2b7e04e61c 100644 --- a/mod/quiz/tests/behat/quiz_no_calendar_capabilities.feature +++ b/mod/quiz/tests/behat/quiz_no_calendar_capabilities.feature @@ -35,8 +35,7 @@ Feature: Quiz with no calendar capabilites | id_timeclose_month | 2 | | id_timeclose_year | 2017 | And I press "Save and return to course" - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 1" "permissions" page And I override the system permissions of "Teacher" role with: | capability | permission | | moodle/calendar:manageentries | Prohibit | diff --git a/mod/quiz/tests/behat/quiz_reset.feature b/mod/quiz/tests/behat/quiz_reset.feature index 71724d79986..a881bb21821 100644 --- a/mod/quiz/tests/behat/quiz_reset.feature +++ b/mod/quiz/tests/behat/quiz_reset.feature @@ -38,8 +38,7 @@ Feature: Quiz reset Scenario: Use course reset to clear all attempt data When I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Reset" in current page administration + And I am on the "Course 1" "reset" page And I set the following fields to these values: | Delete all quiz attempts | 1 | And I press "Reset course" @@ -52,8 +51,7 @@ Feature: Quiz reset | quiz | user | attempts | | Test quiz name | student1 | 2 | When I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Reset" in current page administration + And I am on the "Course 1" "reset" page And I set the field "Delete all user overrides" to "1" And I press "Reset course" And I press "Continue" @@ -65,8 +63,7 @@ Feature: Quiz reset | quiz | group | attempts | | Test quiz name | G1 | 2 | When I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Reset" in current page administration + And I am on the "Course 1" "reset" page And I set the following fields to these values: | Delete all group overrides | 1 | And I press "Reset course" diff --git a/mod/scorm/tests/behat/scorm_no_calendar_capabilities.feature b/mod/scorm/tests/behat/scorm_no_calendar_capabilities.feature index 4d8e7362b9e..7e194d56c4c 100644 --- a/mod/scorm/tests/behat/scorm_no_calendar_capabilities.feature +++ b/mod/scorm/tests/behat/scorm_no_calendar_capabilities.feature @@ -15,8 +15,7 @@ Feature: Scorm with no calendar capabilites | user | course | role | | teacher1 | C1 | editingteacher | And I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration + And I am on the "Course 1" "permissions" page And I override the system permissions of "Teacher" role with: | capability | permission | | moodle/calendar:manageentries | Prohibit | diff --git a/mod/wiki/tests/behat/reset_wiki_comments_tags_files.feature b/mod/wiki/tests/behat/reset_wiki_comments_tags_files.feature index 7bdcb45db44..9d51e6bbd7e 100644 --- a/mod/wiki/tests/behat/reset_wiki_comments_tags_files.feature +++ b/mod/wiki/tests/behat/reset_wiki_comments_tags_files.feature @@ -39,8 +39,7 @@ Feature: Teachers can reset wiki pages, tags and files And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager And I press "Save changes" And I should see "empty.txt" - And I am on "Course 1" course homepage - And I navigate to "Reset" in current page administration + And I am on the "Course 1" "reset" page Scenario: Reset page, tags and files Given I set the following fields to these values: diff --git a/theme/boost/layout/columns2.php b/theme/boost/layout/columns2.php index e56733a730d..9c34f59575f 100644 --- a/theme/boost/layout/columns2.php +++ b/theme/boost/layout/columns2.php @@ -54,9 +54,14 @@ $blockshtml = $OUTPUT->blocks('side-pre'); $hasblocks = strpos($blockshtml, 'data-block=') !== false; $secondarynavigation = false; +$overflow = ''; if ($PAGE->has_secondary_navigation()) { $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs'); $secondarynavigation = $moremenu->export_for_template($OUTPUT); + $overflowdata = $PAGE->secondarynav->get_overflow_menu_data(); + if (!is_null($overflowdata)) { + $overflow = $overflowdata->export_for_template($OUTPUT); + } } $primary = new core\navigation\output\primary($PAGE); @@ -79,6 +84,7 @@ $templatecontext = [ 'langmenu' => $primarymenu['lang'], 'regionmainsettingsmenu' => $regionmainsettingsmenu, 'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu), + 'overflow' => $overflow ]; $nav = $PAGE->flatnav; $templatecontext['firstcollectionlabel'] = $nav->get_collectionlabel(); diff --git a/theme/boost/layout/drawers.php b/theme/boost/layout/drawers.php index d2a52a6c9c9..aa74077bbff 100644 --- a/theme/boost/layout/drawers.php +++ b/theme/boost/layout/drawers.php @@ -79,9 +79,14 @@ $bodyattributes = $OUTPUT->body_attributes($extraclasses); $forceblockdraweropen = $OUTPUT->firstview_fakeblocks(); $secondarynavigation = false; +$overflow = ''; if ($PAGE->has_secondary_navigation()) { $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs'); $secondarynavigation = $moremenu->export_for_template($OUTPUT); + $overflowdata = $PAGE->secondarynav->get_overflow_menu_data(); + if (!is_null($overflowdata)) { + $overflow = $overflowdata->export_for_template($OUTPUT); + } } $primary = new core\navigation\output\primary($PAGE); @@ -108,6 +113,7 @@ $templatecontext = [ 'forceblockdraweropen' => $forceblockdraweropen, 'regionmainsettingsmenu' => $regionmainsettingsmenu, 'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu), + 'overflow' => $overflow ]; $nav = $PAGE->flatnav; diff --git a/theme/boost/templates/columns2.mustache b/theme/boost/templates/columns2.mustache index 04dfab3044b..8aa1c386b3d 100644 --- a/theme/boost/templates/columns2.mustache +++ b/theme/boost/templates/columns2.mustache @@ -79,6 +79,9 @@
{{/hasregionmainsettingsmenu}} {{{ output.course_content_header }}} + {{#overflow}} + {{> core/url_select}} + {{/overflow}} {{{ output.main_content }}} {{{ output.activity_navigation }}} {{{ output.course_content_footer }}} diff --git a/theme/boost/tests/behat/course_administration.feature b/theme/boost/tests/behat/course_administration.feature new file mode 100644 index 00000000000..7ebcd5a8b32 --- /dev/null +++ b/theme/boost/tests/behat/course_administration.feature @@ -0,0 +1,42 @@ +@javascript @theme_boost +Feature: Course administration navigation + As a teacher + I can navigate to course administration pages + + Background: + Given the following "courses" exist: + | fullname | shortname | newsitems | + | Course 1 | C1 | 5 | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + + Scenario: A Teacher can navigate to the course Import page. + Given I log in as "teacher1" + When I am on "Course 1" course homepage + And I navigate to "Course administration" in current page administration + Then I should see "Find a course to import data from:" + + Scenario Outline: A Teacher can navigate to other course administration pages. + Given I log in as "teacher1" + When I am on "Course 1" course homepage + And I navigate to "Course administration" in current page administration + And I select "" from the "jump" singleselect + Then I should see "" + + Examples: + | adminpage | title | + | Backup | Backup settings | + | Restore | Import a backup file | + | Import | Find a course to import data from: | + | Reset | Reset course | + + Scenario: An Administrator can view the course copy page. + Given I log in as "admin" + When I am on "Course 1" course homepage + And I navigate to "Course administration" in current page administration + And I select "Copy course" from the "jump" singleselect + Then I should see "This course will be duplicated and put into the selected course category" diff --git a/theme/classic/tests/behat/pageadministrationmenu.feature b/theme/classic/tests/behat/pageadministrationmenu.feature index 683f4b4aabb..e549fe2555f 100644 --- a/theme/classic/tests/behat/pageadministrationmenu.feature +++ b/theme/classic/tests/behat/pageadministrationmenu.feature @@ -28,7 +28,7 @@ Feature: Page administration menu And I should see "Updating: Choice" And I navigate to course participants And I should see the page administration menu - And I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "Enrolment methods" page And I should see "Enrolment methods" And I log out diff --git a/user/tests/behat/edit_user_enrolment.feature b/user/tests/behat/edit_user_enrolment.feature index a8f97334ab2..748a121e065 100644 --- a/user/tests/behat/edit_user_enrolment.feature +++ b/user/tests/behat/edit_user_enrolment.feature @@ -82,8 +82,7 @@ Feature: Edit user enrolment And I log in as "admin" And I navigate to "Plugins > Enrolments > Manage enrol plugins" in site administration And I click on "Enable" "link" in the "Course meta link" "table_row" - And I am on "Course 1" course homepage - And I add "Course meta link" enrolment method with: + And I add "Course meta link" enrolment method in "Course 1" with: | Link course | C2 | And I log out And I log in as "teacher1" diff --git a/user/tests/behat/view_full_profile.feature b/user/tests/behat/view_full_profile.feature index ac1a1c86a98..5a0071f0922 100644 --- a/user/tests/behat/view_full_profile.feature +++ b/user/tests/behat/view_full_profile.feature @@ -117,8 +117,7 @@ Feature: Access to full profiles of users And I should see "The details of this user are not available to you" And I log out And I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Users > Groups" in current page administration + And I am on the "Course 1" "groups" page And I press "Create group" And I set the following fields to these values: | Group name | Group 1 | diff --git a/user/tests/behat/view_participants.feature b/user/tests/behat/view_participants.feature index f023b5df653..4604bf25142 100644 --- a/user/tests/behat/view_participants.feature +++ b/user/tests/behat/view_participants.feature @@ -276,9 +276,7 @@ Feature: View course participants Scenario: Check status after disabling manual enrolment Given I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to course participants - When I navigate to "Users > Enrolment methods" in current page administration + And I am on the "Course 1" "enrolment methods" page And I click on "Disable" "link" in the "Manual enrolments" "table_row" Then I navigate to course participants And I should see "Not current" in the "student0x" "table_row"