diff --git a/admin/category.php b/admin/category.php index b203497bfeb..b0a682eb5a3 100644 --- a/admin/category.php +++ b/admin/category.php @@ -75,7 +75,7 @@ if ($PAGE->user_allowed_editing() && $adminediting != -1) { $USER->editing = $adminediting; } $buttons = null; -if ($PAGE->user_allowed_editing()) { +if ($PAGE->user_allowed_editing() && !$PAGE->theme->haseditswitch) { $url = clone($PAGE->url); if ($PAGE->user_is_editing()) { $caption = get_string('blockseditoff'); diff --git a/admin/settings.php b/admin/settings.php index 24b90244dc9..a3d48fc48c9 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -101,7 +101,7 @@ if (empty($SITE->fullname)) { echo $OUTPUT->render_from_template('core_admin/settings', $context); } else { - if ($PAGE->user_allowed_editing()) { + if ($PAGE->user_allowed_editing() && !$PAGE->theme->haseditswitch) { $url = clone($PAGE->url); if ($PAGE->user_is_editing()) { $caption = get_string('blockseditoff'); diff --git a/admin/tool/availabilityconditions/tests/behat/manage_conditions.feature b/admin/tool/availabilityconditions/tests/behat/manage_conditions.feature index 8fef761c017..4185bb1e341 100644 --- a/admin/tool/availabilityconditions/tests/behat/manage_conditions.feature +++ b/admin/tool/availabilityconditions/tests/behat/manage_conditions.feature @@ -8,7 +8,7 @@ Feature: Manage availability conditions Scenario: Display list of availability conditions # Check the report doesn't show when not enabled. Given I log in as "admin" - And I press "Customise this page" + And I turn editing mode on And I add the "Administration" block if not present And the following config values are set as admin: | enableavailability | 0 | diff --git a/admin/tool/behat/tests/behat/data_generators.feature b/admin/tool/behat/tests/behat/data_generators.feature index 69e536051dc..06f9c0baec1 100644 --- a/admin/tool/behat/tests/behat/data_generators.feature +++ b/admin/tool/behat/tests/behat/data_generators.feature @@ -139,19 +139,19 @@ Feature: Set up contextual data for tests | user5 | custom2 | System | | When I log in as "user1" And I am on site homepage - Then "Edit settings" "link" should exist in current page administration + Then I should see "Edit mode" And I log out And I log in as "user2" And I am on "Course 1" course homepage - And "Turn editing on" "button" should exist + Then I should see "Edit mode" And I log out And I log in as "user3" And I am on "Course 1" course homepage - And "Turn editing on" "button" should exist + Then I should see "Edit mode" And I log out And I log in as "user4" And I am on "Course 1" course homepage - And "Turn editing on" "button" should exist + Then I should see "Edit mode" And I log out And I log in as "user5" And I should see "You are logged in as" diff --git a/admin/tool/oauth2/tests/behat/basic_settings.feature b/admin/tool/oauth2/tests/behat/basic_settings.feature index d2c402c436c..311c84a3e86 100644 --- a/admin/tool/oauth2/tests/behat/basic_settings.feature +++ b/admin/tool/oauth2/tests/behat/basic_settings.feature @@ -6,6 +6,7 @@ Feature: Basic OAuth2 functionality Background: Given I log in as "admin" + And I change window size to "large" And I navigate to "Server > OAuth 2 services" in site administration Scenario: Create, edit and delete standard service for Google diff --git a/badges/tests/behat/add_badge.feature b/badges/tests/behat/add_badge.feature index 82d5c3b1ff9..4c36aff639f 100644 --- a/badges/tests/behat/add_badge.feature +++ b/badges/tests/behat/add_badge.feature @@ -10,7 +10,7 @@ Feature: Add badges to the system @javascript Scenario: Accessing the badges - And I press "Customise this page" + And I turn editing mode on # TODO MDL-57120 site "Badges" link not accessible without navigation block. And I add the "Navigation" block if not present And I click on "Site pages" "list_item" in the "Navigation" "block" @@ -133,7 +133,7 @@ Feature: Add badges to the system @javascript @_file_upload Scenario: Add a badge from Site badges section - Given I press "Customise this page" + Given I turn editing mode on # TODO MDL-57120 site "Badges" link not accessible without navigation block. And I add the "Navigation" block if not present When I click on "Site pages" "list_item" in the "Navigation" "block" diff --git a/badges/tests/behat/award_badge.feature b/badges/tests/behat/award_badge.feature index 9d5c590f713..60158d60192 100644 --- a/badges/tests/behat/award_badge.feature +++ b/badges/tests/behat/award_badge.feature @@ -83,7 +83,7 @@ Feature: Award badges And I should see "Add a new badge" # Teacher 1 should NOT have access to manage/create site badges in the Site badges section. When I am on homepage - And I press "Customise this page" + And I turn editing mode on # TODO MDL-57120 site "Badges" link not accessible without navigation block. And I add the "Navigation" block if not present And I click on "Site pages" "list_item" in the "Navigation" "block" diff --git a/blocks/activity_modules/tests/behat/block_activity_modules.feature b/blocks/activity_modules/tests/behat/block_activity_modules.feature index 63e6dba5d76..9a606bd8a50 100644 --- a/blocks/activity_modules/tests/behat/block_activity_modules.feature +++ b/blocks/activity_modules/tests/behat/block_activity_modules.feature @@ -31,7 +31,7 @@ Feature: Block activity modules When I log in as "admin" And I am on site homepage - And I follow "Turn editing on" + And I turn editing mode on And I add the "Activities" block And I click on "Assignments" "link" in the "Activities" "block" Then I should see "Frontpage assignment name" diff --git a/blocks/activity_results/tests/behat/addblockinactivity.feature b/blocks/activity_results/tests/behat/addblockinactivity.feature index 3a4b42d432d..47a9d1207e9 100644 --- a/blocks/activity_results/tests/behat/addblockinactivity.feature +++ b/blocks/activity_results/tests/behat/addblockinactivity.feature @@ -36,7 +36,6 @@ Feature: The activity results block displays student scores And I am on "Course 1" course homepage with editing mode on And I should see "Test page name" And I navigate to "View > Grader report" in the course gradebook - And I turn editing mode on And I give the grade "90.00" to the user "Student 1" for the grade item "Test assignment 1" And I give the grade "80.00" to the user "Student 2" for the grade item "Test assignment 1" And I give the grade "70.00" to the user "Student 3" for the grade item "Test assignment 1" diff --git a/blocks/activity_results/tests/behat/highscoreswithoutgroups.feature b/blocks/activity_results/tests/behat/highscoreswithoutgroups.feature index 6af65257a1a..b19dbeecc39 100644 --- a/blocks/activity_results/tests/behat/highscoreswithoutgroups.feature +++ b/blocks/activity_results/tests/behat/highscoreswithoutgroups.feature @@ -30,7 +30,6 @@ Feature: The activity results block displays student high scores And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I navigate to "View > Grader report" in the course gradebook - And I turn editing mode on And I give the grade "90.00" to the user "Student 1" for the grade item "Test assignment" And I give the grade "80.00" to the user "Student 2" for the grade item "Test assignment" And I give the grade "70.00" to the user "Student 3" for the grade item "Test assignment" diff --git a/blocks/activity_results/tests/behat/highscoreswithscalesandgroups.feature b/blocks/activity_results/tests/behat/highscoreswithscalesandgroups.feature index 3f221f1089f..88acb700f75 100644 --- a/blocks/activity_results/tests/behat/highscoreswithscalesandgroups.feature +++ b/blocks/activity_results/tests/behat/highscoreswithscalesandgroups.feature @@ -63,7 +63,6 @@ Feature: The activity results block displays student in group high scores as sca And I press "Save and return to course" And I am on "Course 1" course homepage And I navigate to "View > Grader report" in the course gradebook - And I turn editing mode on And I give the grade "Excellent!" to the user "Student 1" for the grade item "Test assignment" And I give the grade "Very good" to the user "Student 2" for the grade item "Test assignment" And I give the grade "Very good" to the user "Student 3" for the grade item "Test assignment" diff --git a/blocks/activity_results/tests/behat/highscoreswithseperategroups.feature b/blocks/activity_results/tests/behat/highscoreswithseperategroups.feature index 1b8953be518..251576d5462 100644 --- a/blocks/activity_results/tests/behat/highscoreswithseperategroups.feature +++ b/blocks/activity_results/tests/behat/highscoreswithseperategroups.feature @@ -53,7 +53,6 @@ Feature: The activity results block displays student in separate groups scores And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I navigate to "View > Grader report" in the course gradebook - And I turn editing mode on And I give the grade "100.00" to the user "Student 1" for the grade item "Test assignment" And I give the grade "90.00" to the user "Student 2" for the grade item "Test assignment" And I give the grade "90.00" to the user "Student 3" for the grade item "Test assignment" diff --git a/blocks/activity_results/tests/behat/lowscoreswithoutgroups.feature b/blocks/activity_results/tests/behat/lowscoreswithoutgroups.feature index 1c0577d61e9..6188e511b8b 100644 --- a/blocks/activity_results/tests/behat/lowscoreswithoutgroups.feature +++ b/blocks/activity_results/tests/behat/lowscoreswithoutgroups.feature @@ -35,7 +35,6 @@ Feature: The activity results block displays student low scores And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I navigate to "View > Grader report" in the course gradebook - And I turn editing mode on And I give the grade "90.00" to the user "Student 1" for the grade item "Test assignment" And I give the grade "80.00" to the user "Student 2" for the grade item "Test assignment" And I give the grade "70.00" to the user "Student 3" for the grade item "Test assignment" diff --git a/blocks/activity_results/tests/behat/lowscoreswithscales.feature b/blocks/activity_results/tests/behat/lowscoreswithscales.feature index 59b3623cc79..62e6238046e 100644 --- a/blocks/activity_results/tests/behat/lowscoreswithscales.feature +++ b/blocks/activity_results/tests/behat/lowscoreswithscales.feature @@ -49,7 +49,6 @@ Feature: The activity results block displays student low scores as scales And I press "Save and return to course" And I am on "Course 1" course homepage And I navigate to "View > Grader report" in the course gradebook - And I turn editing mode on And I give the grade "Excellent!" to the user "Student 1" for the grade item "Test assignment" And I give the grade "Very good" to the user "Student 2" for the grade item "Test assignment" And I give the grade "Good" to the user "Student 3" for the grade item "Test assignment" diff --git a/blocks/activity_results/tests/behat/lowscoreswithscalesandgroups.feature b/blocks/activity_results/tests/behat/lowscoreswithscalesandgroups.feature index ee08e782767..345164b6489 100644 --- a/blocks/activity_results/tests/behat/lowscoreswithscalesandgroups.feature +++ b/blocks/activity_results/tests/behat/lowscoreswithscalesandgroups.feature @@ -74,7 +74,7 @@ Feature: The activity results block displays students in groups low scores as sc And I give the grade "Good" to the user "Student 5" for the grade item "Test assignment" And I give the grade "Average" to the user "Student 6" for the grade item "Test assignment" And I press "Save changes" - And I am on "Course 1" course homepage with editing mode on + And I am on "Course 1" course homepage Scenario: Try to configure the block on the course page to show 1 low score Given I add the "Activity results" block diff --git a/blocks/activity_results/tests/behat/lowscoreswithseperategroups.feature b/blocks/activity_results/tests/behat/lowscoreswithseperategroups.feature index eadf2e9b0d9..523681e74b9 100644 --- a/blocks/activity_results/tests/behat/lowscoreswithseperategroups.feature +++ b/blocks/activity_results/tests/behat/lowscoreswithseperategroups.feature @@ -47,7 +47,6 @@ Feature: The activity results block displays students in separate groups scores And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I navigate to "View > Grader report" in the course gradebook - And I turn editing mode on And I give the grade "100.00" to the user "Student 1" for the grade item "Test assignment" And I give the grade "90.00" to the user "Student 2" for the grade item "Test assignment" And I give the grade "90.00" to the user "Student 3" for the grade item "Test assignment" diff --git a/blocks/activity_results/tests/behat/lowscoreswithvisiblegroups.feature b/blocks/activity_results/tests/behat/lowscoreswithvisiblegroups.feature index 13ed3f897fb..29d7a29e9bb 100644 --- a/blocks/activity_results/tests/behat/lowscoreswithvisiblegroups.feature +++ b/blocks/activity_results/tests/behat/lowscoreswithvisiblegroups.feature @@ -53,7 +53,6 @@ Feature: The activity results block displays student in visible groups low score And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I navigate to "View > Grader report" in the course gradebook - And I turn editing mode on And I give the grade "100.00" to the user "Student 1" for the grade item "Test assignment" And I give the grade "90.00" to the user "Student 2" for the grade item "Test assignment" And I give the grade "90.00" to the user "Student 3" for the grade item "Test assignment" diff --git a/blocks/badges/tests/behat/block_badges_frontpage.feature b/blocks/badges/tests/behat/block_badges_frontpage.feature index 388f4a30eb9..3a030b79bd4 100644 --- a/blocks/badges/tests/behat/block_badges_frontpage.feature +++ b/blocks/badges/tests/behat/block_badges_frontpage.feature @@ -16,7 +16,7 @@ Feature: Enable Block Badges on the frontpage and view awarded badges | teacher1 | C1 | editingteacher | And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Latest badges" block And I log out And I log in as "teacher1" diff --git a/blocks/blog_menu/tests/behat/block_blog_menu_frontpage.feature b/blocks/blog_menu/tests/behat/block_blog_menu_frontpage.feature index 8e1df8263f3..f20b2e5c17f 100644 --- a/blocks/blog_menu/tests/behat/block_blog_menu_frontpage.feature +++ b/blocks/blog_menu/tests/behat/block_blog_menu_frontpage.feature @@ -10,7 +10,7 @@ Feature: Enable Block blog menu on the frontpage | student1 | Student | 1 | student1@example.com | S1 | And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Blog menu" block And I log out diff --git a/blocks/blog_recent/tests/behat/block_blog_recent_frontpage.feature b/blocks/blog_recent/tests/behat/block_blog_recent_frontpage.feature index 38640424a0b..e7403cd513b 100644 --- a/blocks/blog_recent/tests/behat/block_blog_recent_frontpage.feature +++ b/blocks/blog_recent/tests/behat/block_blog_recent_frontpage.feature @@ -10,7 +10,7 @@ Feature: Feature: Students can use the recent blog entries block to view recent | student1 | Student | 1 | student1@example.com | S1 | And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Recent blog entries" block # TODO MDL-57120 site "Blogs" link not accessible without navigation block. And I add the "Navigation" block if not present @@ -89,7 +89,7 @@ Feature: Feature: Students can use the recent blog entries block to view recent Then I log out And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I configure the "Recent blog entries" block And I set the following fields to these values: | id_config_numberofrecentblogentries | 2 | diff --git a/blocks/calendar_upcoming/tests/behat/block_calendar_upcoming_frontpage.feature b/blocks/calendar_upcoming/tests/behat/block_calendar_upcoming_frontpage.feature index 8336f521fba..b2d956011d1 100644 --- a/blocks/calendar_upcoming/tests/behat/block_calendar_upcoming_frontpage.feature +++ b/blocks/calendar_upcoming/tests/behat/block_calendar_upcoming_frontpage.feature @@ -16,7 +16,7 @@ Feature: View a site event on the frontpage | id_eventtype | Site | | id_name | My Site Event | And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Upcoming events" block And I log out When I log in as "teacher1" diff --git a/blocks/comments/tests/behat/block_comment_dashboard.feature b/blocks/comments/tests/behat/block_comment_dashboard.feature index 66e49c6e9db..fcb19e7c827 100644 --- a/blocks/comments/tests/behat/block_comment_dashboard.feature +++ b/blocks/comments/tests/behat/block_comment_dashboard.feature @@ -14,7 +14,7 @@ Feature: Enable Block comments on the dashboard and view comments Scenario: Add the comments block on the dashboard and add comments with Javascript disabled When I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on And I add the "Comments" block And I follow "Show comments" And I add "I'm a comment from the teacher" comment to comments block @@ -23,7 +23,7 @@ Feature: Enable Block comments on the dashboard and view comments @javascript Scenario: Add the comments block on the dashboard and add comments with Javascript enabled When I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on And I add the "Comments" block And I add "I'm a comment from the teacher" comment to comments block Then I should see "I'm a comment from the teacher" diff --git a/blocks/comments/tests/behat/block_comment_frontpage.feature b/blocks/comments/tests/behat/block_comment_frontpage.feature index 6b883f2cad4..cb8d76dd036 100644 --- a/blocks/comments/tests/behat/block_comment_frontpage.feature +++ b/blocks/comments/tests/behat/block_comment_frontpage.feature @@ -10,7 +10,7 @@ Feature: Enable Block comments on the frontpage and view comments | teacher1 | Teacher | 1 | teacher1@example.com | T1 | And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Comments" block And I follow "Show comments" And I add "I'm a comment from admin" comment to comments block diff --git a/blocks/course_list/tests/behat/block_course_list_dashboard.feature b/blocks/course_list/tests/behat/block_course_list_dashboard.feature index 873208b477d..2b5df28cbeb 100644 --- a/blocks/course_list/tests/behat/block_course_list_dashboard.feature +++ b/blocks/course_list/tests/behat/block_course_list_dashboard.feature @@ -27,7 +27,7 @@ Feature: Enable the course_list block on the dashboard and view it's contents Scenario: Add the course list block on the dashboard and navigate to the course listing Given I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on When I add the "Courses" block Then I should see "Course 1" in the "My courses" "block" And I should see "Course 2" in the "My courses" "block" @@ -38,7 +38,7 @@ Feature: Enable the course_list block on the dashboard and view it's contents Scenario: Add the course list block on the dashboard and navigate to another course Given I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on When I add the "Courses" block Then I should see "Course 1" in the "My courses" "block" And I should see "Course 2" in the "My courses" "block" @@ -49,7 +49,7 @@ Feature: Enable the course_list block on the dashboard and view it's contents Scenario: Add the course list block on the dashboard and view as an admin Given I log in as "admin" - And I press "Customise this page" + And I turn editing mode on When I add the "Courses" block Then I should see "Category 1" in the "Course categories" "block" And I should see "Category A" in the "Course categories" "block" diff --git a/blocks/course_list/tests/behat/block_course_list_frontpage.feature b/blocks/course_list/tests/behat/block_course_list_frontpage.feature index 0a897ba84b9..0f8b0c5845c 100644 --- a/blocks/course_list/tests/behat/block_course_list_frontpage.feature +++ b/blocks/course_list/tests/behat/block_course_list_frontpage.feature @@ -28,7 +28,7 @@ Feature: Enable the course_list block on the frontpage and view it's contents Scenario: Add the course list block on the frontpage and navigate to the course listing Given I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Courses" block And I log out When I log in as "teacher1" @@ -43,7 +43,7 @@ Feature: Enable the course_list block on the frontpage and view it's contents Scenario: Add the course list block on the frontpage page and navigate to another course Given I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Courses" block And I log out When I log in as "teacher1" @@ -58,7 +58,7 @@ Feature: Enable the course_list block on the frontpage and view it's contents Scenario: Add the course list block on the frontpage page and view as an admin Given I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on When I add the "Courses" block Then I should see "Category 1" in the "Course categories" "block" And I should see "Category A" in the "Course categories" "block" @@ -72,7 +72,7 @@ Feature: Enable the course_list block on the frontpage and view it's contents Scenario: Add the course list block on the frontpage page and view as a guest Given I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Courses" block And I log out When I log in as "guest" diff --git a/blocks/login/tests/behat/login_block.feature b/blocks/login/tests/behat/login_block.feature index 2f86023f056..b06547a5ccf 100644 --- a/blocks/login/tests/behat/login_block.feature +++ b/blocks/login/tests/behat/login_block.feature @@ -10,7 +10,7 @@ Feature: Login from a block | testuser | testpass | Test | User | student1@example.com | And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Login" block Scenario: Login block visible to non-logged in users diff --git a/blocks/myprofile/tests/behat/block_myprofile.feature b/blocks/myprofile/tests/behat/block_myprofile.feature index 8801de340d9..d95de68c082 100644 --- a/blocks/myprofile/tests/behat/block_myprofile.feature +++ b/blocks/myprofile/tests/behat/block_myprofile.feature @@ -9,7 +9,7 @@ Feature: The logged in user block allows users to view their profile information | username | firstname | lastname | email | country | | teacher1 | Teacher | One | teacher1@example.com | AU | And I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on When I add the "Logged in user" block And I configure the "Logged in user" block And I set the following fields to these values: @@ -28,7 +28,7 @@ Feature: The logged in user block allows users to view their profile information | username | firstname | lastname | email | city | | teacher1 | Teacher | One | teacher1@example.com | Perth | And I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on When I add the "Logged in user" block And I configure the "Logged in user" block And I set the following fields to these values: @@ -47,7 +47,7 @@ Feature: The logged in user block allows users to view their profile information | username | firstname | lastname | email | | teacher1 | Teacher | One | teacher1@example.com | And I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on When I add the "Logged in user" block And I configure the "Logged in user" block And I set the following fields to these values: @@ -66,7 +66,7 @@ Feature: The logged in user block allows users to view their profile information | username | firstname | lastname | email | phone1 | | teacher1 | Teacher | One | teacher1@example.com | 555-5555 | And I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on When I add the "Logged in user" block And I configure the "Logged in user" block And I set the following fields to these values: @@ -85,7 +85,7 @@ Feature: The logged in user block allows users to view their profile information | username | firstname | lastname | email | phone2 | | teacher1 | Teacher | One | teacher1@example.com | 555-5555 | And I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on When I add the "Logged in user" block And I configure the "Logged in user" block And I set the following fields to these values: @@ -104,7 +104,7 @@ Feature: The logged in user block allows users to view their profile information | username | firstname | lastname | email | institution | | teacher1 | Teacher | One | teacher1@example.com | myinstitution | And I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on When I add the "Logged in user" block And I configure the "Logged in user" block And I set the following fields to these values: @@ -123,7 +123,7 @@ Feature: The logged in user block allows users to view their profile information | username | firstname | lastname | email | address | | teacher1 | Teacher | One | teacher1@example.com | myaddress | And I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on When I add the "Logged in user" block And I configure the "Logged in user" block And I set the following fields to these values: @@ -142,7 +142,7 @@ Feature: The logged in user block allows users to view their profile information | username | firstname | lastname | email | | teacher1 | Teacher | One | teacher1@example.com | And I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on When I add the "Logged in user" block And I configure the "Logged in user" block And I set the following fields to these values: @@ -161,7 +161,7 @@ Feature: The logged in user block allows users to view their profile information | username | firstname | lastname | email | | teacher1 | Teacher | One | teacher1@example.com | And I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on When I add the "Logged in user" block And I configure the "Logged in user" block And I set the following fields to these values: @@ -180,7 +180,7 @@ Feature: The logged in user block allows users to view their profile information | username | firstname | lastname | email | | teacher1 | Teacher | One | teacher1@example.com | And I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on When I add the "Logged in user" block And I configure the "Logged in user" block And I set the following fields to these values: @@ -199,7 +199,7 @@ Feature: The logged in user block allows users to view their profile information | username | firstname | lastname | email | | teacher1 | Teacher | One | teacher1@example.com | And I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on When I add the "Logged in user" block And I configure the "Logged in user" block And I set the following fields to these values: diff --git a/blocks/myprofile/tests/behat/block_myprofile_dashboard.feature b/blocks/myprofile/tests/behat/block_myprofile_dashboard.feature index e1305226ce1..da323581aa2 100644 --- a/blocks/myprofile/tests/behat/block_myprofile_dashboard.feature +++ b/blocks/myprofile/tests/behat/block_myprofile_dashboard.feature @@ -9,6 +9,6 @@ Feature: The logged in user block allows users to view their profile information | username | firstname | lastname | email | | teacher1 | Teacher | One | teacher1@example.com | And I log in as "teacher1" - And I press "Customise this page" + And I turn editing mode on When I add the "Logged in user" block Then I should see "Teacher One" in the "Logged in user" "block" diff --git a/blocks/myprofile/tests/behat/block_myprofile_frontpage.feature b/blocks/myprofile/tests/behat/block_myprofile_frontpage.feature index 1e6707848d6..c7d5e37a071 100644 --- a/blocks/myprofile/tests/behat/block_myprofile_frontpage.feature +++ b/blocks/myprofile/tests/behat/block_myprofile_frontpage.feature @@ -10,7 +10,7 @@ Feature: The logged in user block allows users to view their profile information | teacher1 | Teacher | One | teacher1@example.com | T1 | And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Logged in user" block And I log out diff --git a/blocks/online_users/tests/behat/block_online_users_frontpage.feature b/blocks/online_users/tests/behat/block_online_users_frontpage.feature index e8f9591f6d7..5da03deadab 100644 --- a/blocks/online_users/tests/behat/block_online_users_frontpage.feature +++ b/blocks/online_users/tests/behat/block_online_users_frontpage.feature @@ -21,7 +21,7 @@ Feature: The online users block allow you to see who is currently online on fron Scenario: View the online users block on the front page and see myself Given I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on When I add the "Online users" block Then I should see "Admin User" in the "Online users" "block" And I should see "1 online user" in the "Online users" "block" @@ -29,7 +29,7 @@ Feature: The online users block allow you to see who is currently online on fron Scenario: View the online users block on the front page as a logged in user Given I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Online users" block And I log out And I log in as "student2" @@ -45,7 +45,7 @@ Feature: The online users block allow you to see who is currently online on fron Scenario: View the online users block on the front page as a guest Given I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Online users" block And I log out And I log in as "student2" @@ -65,7 +65,7 @@ Feature: The online users block allow you to see who is currently online on fron | block_online_users_onlinestatushiding | 1 | And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Online users" block And I log out When I log in as "student1" @@ -104,7 +104,7 @@ Feature: The online users block allow you to see who is currently online on fron | block_online_users_onlinestatushiding | 1 | And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Online users" block And I log out And I log in as "student1" @@ -125,7 +125,7 @@ Feature: The online users block allow you to see who is currently online on fron | block_online_users_onlinestatushiding | 1 | And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Online users" block And I log out And I log in as "student1" diff --git a/blocks/private_files/tests/behat/block_private_files_frontpage.feature b/blocks/private_files/tests/behat/block_private_files_frontpage.feature index 0e79d0a911a..cd3ef3b1665 100644 --- a/blocks/private_files/tests/behat/block_private_files_frontpage.feature +++ b/blocks/private_files/tests/behat/block_private_files_frontpage.feature @@ -13,7 +13,7 @@ Feature: The private files block allows users to store files privately in moodle | teacher1 | Teacher | 1 | teacher1@example.com | And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Private files" block And I log out diff --git a/blocks/recentlyaccesseditems/tests/behat/block_recentlyaccesseditems_dashboard.feature b/blocks/recentlyaccesseditems/tests/behat/block_recentlyaccesseditems_dashboard.feature index f635459c7ae..5d1f562177e 100644 --- a/blocks/recentlyaccesseditems/tests/behat/block_recentlyaccesseditems_dashboard.feature +++ b/blocks/recentlyaccesseditems/tests/behat/block_recentlyaccesseditems_dashboard.feature @@ -22,7 +22,7 @@ Feature: The recently accessed items block allows users to easily access their m | idnumber | Test forum name | | name | Test forum name | And I log in as "student1" - And I press "Customise this page" + And I turn editing mode on And I add the "Recently accessed items" block Scenario: User has not accessed any item diff --git a/blocks/search_forums/tests/behat/block_search_forums_frontpage.feature b/blocks/search_forums/tests/behat/block_search_forums_frontpage.feature index 31d868376cd..53d09348b57 100644 --- a/blocks/search_forums/tests/behat/block_search_forums_frontpage.feature +++ b/blocks/search_forums/tests/behat/block_search_forums_frontpage.feature @@ -10,7 +10,7 @@ Feature: The search forums block allows users to search for forum posts on front | student1 | Student | 1 | student1@example.com | S1 | And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Search forums" block And I log out diff --git a/blocks/site_main_menu/tests/behat/add_url.feature b/blocks/site_main_menu/tests/behat/add_url.feature index 1b2a7df7682..f5ce28b6471 100644 --- a/blocks/site_main_menu/tests/behat/add_url.feature +++ b/blocks/site_main_menu/tests/behat/add_url.feature @@ -8,7 +8,7 @@ Feature: Add URL to main menu block Scenario: Add a URL in menu block and ensure it appears Given I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Main menu" block When I add a "URL" to section "0" and I fill the form with: | Name | google | diff --git a/blocks/site_main_menu/tests/behat/edit_activities.feature b/blocks/site_main_menu/tests/behat/edit_activities.feature index e8aa3315c9a..78701455da5 100644 --- a/blocks/site_main_menu/tests/behat/edit_activities.feature +++ b/blocks/site_main_menu/tests/behat/edit_activities.feature @@ -13,7 +13,7 @@ Feature: Edit activities in main menu block | idnumber | forum | And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Main menu" block When I set the field "Edit title" in the "My forum name" "block_site_main_menu > Activity" to "New forum name" Then I should not see "My forum name" @@ -28,7 +28,7 @@ Feature: Edit activities in main menu block | allowstealth | 1 | And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I add the "Main menu" block When I add a "Forum" to section "0" and I fill the form with: | Forum name | Visible forum | @@ -61,7 +61,7 @@ Feature: Edit activities in main menu block And the field "Availability" matches value "Make available but not shown on course page" And I press "Save and return to course" And "My forum name" activity in site main menu block should be available but hidden from course page - And I navigate to "Turn editing off" in current page administration + And I turn editing mode off And "My forum name" activity in site main menu block should be available but hidden from course page And I log out And I should not see "My forum name" in the "Main menu" "block" diff --git a/blocks/tag_flickr/tests/behat/configuring_tag_flickr_block.feature b/blocks/tag_flickr/tests/behat/configuring_tag_flickr_block.feature index c9278270013..c6670012b9b 100644 --- a/blocks/tag_flickr/tests/behat/configuring_tag_flickr_block.feature +++ b/blocks/tag_flickr/tests/behat/configuring_tag_flickr_block.feature @@ -7,7 +7,7 @@ Feature: Adding and configuring Flickr block @javascript Scenario: Adding Flickr block to the tags site page Given I log in as "admin" - And I press "Customise this page" + And I turn editing mode on # TODO MDL-57120 site "Tags" link not accessible without navigation block. And I add the "Navigation" block if not present And I click on "Site pages" "list_item" in the "Navigation" "block" diff --git a/blocks/tag_youtube/tests/behat/configure_tag_youtube_block.feature b/blocks/tag_youtube/tests/behat/configure_tag_youtube_block.feature index 6952b95b160..4da87fe05f2 100644 --- a/blocks/tag_youtube/tests/behat/configure_tag_youtube_block.feature +++ b/blocks/tag_youtube/tests/behat/configure_tag_youtube_block.feature @@ -14,7 +14,7 @@ Feature: Adding and configuring YouTube block Given the following config values are set as admin: | apikey | | block_tag_youtube | And I follow "Dashboard" in the user menu - And I press "Customise this page" + And I turn editing mode on # TODO MDL-57120 site "Tags" link not accessible without navigation block. And I add the "Navigation" block if not present And I click on "Site pages" "list_item" in the "Navigation" "block" @@ -34,7 +34,7 @@ Feature: Adding and configuring YouTube block Given the following config values are set as admin: | apikey | invalidapikeyvalue | block_tag_youtube | And I follow "Dashboard" in the user menu - And I press "Customise this page" + And I turn editing mode on And I add the "Navigation" block if not present And I click on "Site pages" "list_item" in the "Navigation" "block" And I click on "Tags" "link" in the "Navigation" "block" diff --git a/blocks/tags/tests/behat/tagcloud.feature b/blocks/tags/tests/behat/tagcloud.feature index 6a8bd414895..dbe47565bed 100644 --- a/blocks/tags/tests/behat/tagcloud.feature +++ b/blocks/tags/tests/behat/tagcloud.feature @@ -23,7 +23,7 @@ Feature: Block tags displaying tag cloud Scenario: Add Tags block on a front page When I log in as "admin" And I am on site homepage - And I follow "Turn editing on" + And I turn editing mode on And I add the "Tags" block And I log out And I am on site homepage diff --git a/blocks/tests/behat/configure_block_throughout_site.feature b/blocks/tests/behat/configure_block_throughout_site.feature index a312ce6d058..f633c84d570 100644 --- a/blocks/tests/behat/configure_block_throughout_site.feature +++ b/blocks/tests/behat/configure_block_throughout_site.feature @@ -30,7 +30,7 @@ Feature: Add and configure blocks throughout the site Scenario: Add and configure a block throughtout the site Given I log in as "manager1" And I am on site homepage - And I follow "Turn editing on" + And I turn editing mode on And I add the "Comments" block And I configure the "Comments" block And I set the following fields to these values: @@ -50,7 +50,7 @@ Feature: Add and configure blocks throughout the site Scenario: Blocks on the dashboard page can have roles assigned to them Given I log in as "manager1" - When I press "Customise this page" + When I turn editing mode on Then I should see "Assign roles in Private files block" Scenario: Blocks on courses can have roles assigned to them @@ -63,7 +63,7 @@ Feature: Add and configure blocks throughout the site Scenario: Blocks can safely be customised Given I log in as "admin" And I am on homepage - And I press "Customise this page" + And I turn editing mode on And I add the "Text" block And I configure the "(new text block)" block And I set the following fields to these values: diff --git a/blocks/tests/behat/hide_blocks.feature b/blocks/tests/behat/hide_blocks.feature index db11e3f529d..0a4f9fae911 100644 --- a/blocks/tests/behat/hide_blocks.feature +++ b/blocks/tests/behat/hide_blocks.feature @@ -23,5 +23,5 @@ Feature: Block visibility And I turn editing mode on And I open the "Search forums" blocks action menu And I click on "Hide Search forums block" "link" in the "Search forums" "block" - And I follow "Turn editing off" + And I turn editing mode off And ".empty-region-side-post" "css_element" should exist in the "body" "css_element" diff --git a/blocks/tests/behat/manage_blocks.feature b/blocks/tests/behat/manage_blocks.feature index 7af0a432a13..2f5b1fcefe1 100644 --- a/blocks/tests/behat/manage_blocks.feature +++ b/blocks/tests/behat/manage_blocks.feature @@ -48,7 +48,7 @@ Feature: Block appearances And I set the following fields to these values: | Display on page types | Any course page | And I press "Save changes" - And I press "Turn editing off" + And I turn editing mode off And I follow "Test survey name" And I should not see "Comments" @@ -58,5 +58,5 @@ Feature: Block appearances And I set the following fields to these values: | Visible | No | And I press "Save changes" - And I press "Turn editing off" + And I turn editing mode off Then I should not see "Comments" diff --git a/calendar/tests/behat/category_events.feature b/calendar/tests/behat/category_events.feature index 021126ad4fe..734c7acddc6 100644 --- a/calendar/tests/behat/category_events.feature +++ b/calendar/tests/behat/category_events.feature @@ -67,7 +67,7 @@ Feature: Course Category Events @javascript Scenario: Manager of a Category can see all child and parent events in their category Given I log in as "managera" - And I press "Customise this page" + And I turn editing mode on # TODO MDL-57120 site "Tags" link not accessible without navigation block. When I add the "Navigation" block if not present And I click on "Site pages" "list_item" in the "Navigation" "block" @@ -80,7 +80,7 @@ Feature: Course Category Events And I should not see "DB2 event" And I log out Given I log in as "managerb" - And I press "Customise this page" + And I turn editing mode on # TODO MDL-57120 site "Tags" link not accessible without navigation block. When I add the "Navigation" block if not present And I click on "Site pages" "list_item" in the "Navigation" "block" @@ -95,7 +95,7 @@ Feature: Course Category Events @javascript Scenario: Users enrolled in a course can see all child and parent events in their category Given I log in as "student1" - And I press "Customise this page" + And I turn editing mode on # TODO MDL-57120 site "Tags" link not accessible without navigation block. When I add the "Navigation" block if not present And I click on "Site pages" "list_item" in the "Navigation" "block" diff --git a/completion/tests/behat/activity_completion_criteria.feature b/completion/tests/behat/activity_completion_criteria.feature index 09f59fe42b2..fbab217b8d3 100644 --- a/completion/tests/behat/activity_completion_criteria.feature +++ b/completion/tests/behat/activity_completion_criteria.feature @@ -116,7 +116,7 @@ Feature: Allow to mark course as completed without cron for activity completion Given I log in as "teacher1" And I am on "Completion course" course homepage And I navigate to "View > Grader report" in the course gradebook - And I press "Turn editing on" + And I turn editing mode on And I give the grade "57" to the user "Student First" for the grade item "Test assignment name" And I press "Save changes" And I log out diff --git a/contentbank/contenttype/h5p/tests/behat/admin_replace_content.feature b/contentbank/contenttype/h5p/tests/behat/admin_replace_content.feature index c91828e0a4f..c34e19f0128 100644 --- a/contentbank/contenttype/h5p/tests/behat/admin_replace_content.feature +++ b/contentbank/contenttype/h5p/tests/behat/admin_replace_content.feature @@ -9,7 +9,7 @@ Feature: Replace H5P file from an existing content | contextlevel | reference | contenttype | user | contentname | filepath | | System | | contenttype_h5p | admin | filltheblanks.h5p | /h5p/tests/fixtures/filltheblanks.h5p | And I log in as "admin" - And I press "Customise this page" + And I turn editing mode on And I add the "Navigation" block if not present And I expand "Site pages" node And I click on "Content bank" "link" diff --git a/contentbank/contenttype/h5p/tests/behat/admin_upload_content.feature b/contentbank/contenttype/h5p/tests/behat/admin_upload_content.feature index 29959c58fe3..dbc596a9a15 100644 --- a/contentbank/contenttype/h5p/tests/behat/admin_upload_content.feature +++ b/contentbank/contenttype/h5p/tests/behat/admin_upload_content.feature @@ -9,7 +9,7 @@ Feature: H5P file upload to content bank for admins And I follow "Manage private files..." And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Files" filemanager And I click on "Save changes" "button" - And I press "Customise this page" + And I turn editing mode on And I add the "Navigation" block if not present And I expand "Site pages" node And I click on "Content bank" "link" diff --git a/contentbank/contenttype/h5p/tests/behat/teacher_upload_content.feature b/contentbank/contenttype/h5p/tests/behat/teacher_upload_content.feature index 488fde877d5..1146a082656 100644 --- a/contentbank/contenttype/h5p/tests/behat/teacher_upload_content.feature +++ b/contentbank/contenttype/h5p/tests/behat/teacher_upload_content.feature @@ -25,7 +25,7 @@ Feature: H5P file upload to content bank for non admins And I click on "Save changes" "button" Scenario: Teachers can not access system level content bank - Given I press "Customise this page" + Given I turn editing mode on And I add the "Navigation" block if not present When I expand "Site pages" node Then I should not see "Content bank" diff --git a/course/tests/behat/activities_visibility_icons.feature b/course/tests/behat/activities_visibility_icons.feature index d26ae6716b8..f6269f67aa1 100644 --- a/course/tests/behat/activities_visibility_icons.feature +++ b/course/tests/behat/activities_visibility_icons.feature @@ -17,12 +17,15 @@ Feature: Toggle activities visibility from the course page | user | course | role | | teacher1 | C1 | editingteacher | | student1 | C1 | student | + And the following "activity" exists: + | activity | forum | + | course | C1 | + | idnumber | C1F1 | + | name | Test forum name | + | intro | Test forum description | + | visible | 1 | And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on - And I add a "Forum" to section "1" and I fill the form with: - | Forum name | Test forum name | - | Description | Test forum description | - | Availability | Show on course page | When I open "Test forum name" actions menu Then "Test forum name" actions menu should not have "Show" item And "Test forum name" actions menu should not have "Make available" item @@ -60,7 +63,6 @@ Feature: Toggle activities visibility from the course page And I log in as "student1" And I am on "Course 1" course homepage And I should not see "Test forum name" - And I log out @javascript Scenario: Activities can be made available and unavailable inside a hidden section @@ -75,13 +77,17 @@ Feature: Toggle activities visibility from the course page | user | course | role | | teacher1 | C1 | editingteacher | | student1 | C1 | student | + And the following "activity" exists: + | activity | forum | + | course | C1 | + | idnumber | C1F1 | + | section | 2 | + | name | Test forum name | + | intro | Test forum description | + | visible | 1 | And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I add the "Recent activity" block - And I add a "Forum" to section "2" and I fill the form with: - | Forum name | Test forum name | - | Description | Test forum description | - | Availability | Show on course page | When I hide section "2" Then "Test forum name" activity should be hidden And I open "Test forum name" actions menu @@ -116,7 +122,6 @@ Feature: Toggle activities visibility from the course page And I click on "Test forum name" "link" in the "Recent activity" "block" And I should see "Test forum name" And I should see "(There are no discussion topics yet in this forum)" - And I log out @javascript Scenario: Activities can be made available but not visible on a course page diff --git a/course/tests/behat/behat_course.php b/course/tests/behat/behat_course.php index a477f391041..bc3d23ba331 100644 --- a/course/tests/behat/behat_course.php +++ b/course/tests/behat/behat_course.php @@ -82,32 +82,6 @@ class behat_course extends behat_base { ]; } - /** - * Turns editing mode on. - * @Given /^I turn editing mode on$/ - */ - public function i_turn_editing_mode_on() { - - try { - $this->execute("behat_forms::press_button", get_string('turneditingon')); - } catch (Exception $e) { - $this->execute("behat_navigation::i_navigate_to_in_current_page_administration", [get_string('turneditingon')]); - } - } - - /** - * Turns editing mode off. - * @Given /^I turn editing mode off$/ - */ - public function i_turn_editing_mode_off() { - - try { - $this->execute("behat_forms::press_button", get_string('turneditingoff')); - } catch (Exception $e) { - $this->execute("behat_navigation::i_navigate_to_in_current_page_administration", [get_string('turneditingoff')]); - } - } - /** * Creates a new course with the provided table data matching course settings names with the desired values. * @@ -733,9 +707,7 @@ class behat_course extends behat_base { * @throws ExpectationException */ public function activity_should_be_hidden($activityname) { - if ($this->is_course_editor()) { - // The activity should exist. $activitynode = $this->get_activity_node($activityname); @@ -758,7 +730,6 @@ class behat_course extends behat_base { } } else { - // It should not exist at all. try { $this->get_activity_node($activityname); @@ -1310,15 +1281,13 @@ class behat_course extends behat_base { * * @return bool */ - protected function is_course_editor() { - - // We don't need to behat_base::spin() here as all is already loaded. - if (!$this->getSession()->getPage()->findButton(get_string('turneditingoff')) && - !$this->getSession()->getPage()->findButton(get_string('turneditingon'))) { + protected function is_course_editor(): bool { + try { + $this->find('field', get_string('editmode'), false, false, 0); + return true; + } catch (ElementNotFoundException $e) { return false; } - - return true; } /** @@ -1327,7 +1296,8 @@ class behat_course extends behat_base { * @return bool */ protected function is_editing_on() { - return $this->getSession()->getPage()->findButton(get_string('turneditingoff')) ? true : false; + $body = $this->find('xpath', "//body", false, false, 0); + return $body->hasClass('editing'); } /** diff --git a/course/tests/behat/coursetags.feature b/course/tests/behat/coursetags.feature index 73d3ec57860..a9e9c6b2285 100644 --- a/course/tests/behat/coursetags.feature +++ b/course/tests/behat/coursetags.feature @@ -47,7 +47,7 @@ Feature: Tagging courses And I press "Save and display" And I log out And I log in as "user1" - And I press "Customise this page" + And I turn editing mode on # TODO MDL-57120 "Tags" link not accessible without navigation block. And I add the "Navigation" block if not present And I click on "Site pages" "list_item" in the "Navigation" "block" @@ -84,7 +84,7 @@ Feature: Tagging courses And I press "Save changes" And I log out And I log in as "user1" - And I press "Customise this page" + And I turn editing mode on # TODO MDL-57120 "Tags" link not accessible without navigation block. And I add the "Navigation" block if not present And I click on "Site pages" "list_item" in the "Navigation" "block" diff --git a/course/tests/behat/frontpage_topic_section.feature b/course/tests/behat/frontpage_topic_section.feature index f2cf92cb4cd..5c9bbfb9385 100644 --- a/course/tests/behat/frontpage_topic_section.feature +++ b/course/tests/behat/frontpage_topic_section.feature @@ -23,23 +23,23 @@ Feature: Front page topic section | assign | Acceptance test site | 1 | Frontpage assignment | Assignment description | assign0 | And I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I click on "Edit summary" "link" in the "region-main" "region" And I click on "Custom" "checkbox" And I set the field "New value for Section name" to "New section name" When I press "Save changes" And I should see "New section name" in the "region-main" "region" - Then I navigate to "Turn editing off" in current page administration + Then I turn editing mode off And I should see "New section name" in the "region-main" "region" @javascript Scenario: Topic description appears in the frontpage Given I log in as "admin" And I am on site homepage - And I navigate to "Turn editing on" in current page administration + And I turn editing mode on And I click on "Edit summary" "link" in the "region-main" "region" And I set the field "Summary" to "New section description" When I press "Save changes" And I should see "New section description" in the "region-main" "region" - Then I navigate to "Turn editing off" in current page administration + Then I turn editing mode off And I should see "New section description" in the "region-main" "region" diff --git a/editmode.php b/editmode.php new file mode 100644 index 00000000000..36c340d4f98 --- /dev/null +++ b/editmode.php @@ -0,0 +1,47 @@ +. + +/** + * Set Mode. + * + * @package core + * @copyright 2021 Andrew Lyons + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +require_once('config.php'); + +$setmode = optional_param('setmode', false, PARAM_BOOL); +$contextid = required_param('context', PARAM_INT); +$pageurl = required_param('pageurl', PARAM_LOCALURL); + +require_sesskey(); +require_login(); + +$context = \context_helper::instance_by_id($contextid); +$PAGE->set_context($context); + +if ($context->id === \context_user::instance($USER->id)->id) { + $PAGE->set_blocks_editing_capability('moodle/my:manageblocks'); +} + +if ($PAGE->user_allowed_editing()) { + $USER->editing = $setmode; +} else { + \core\notification::add(get_string('cannotswitcheditmodeon', 'error'), \core\notification::ERROR); +} + +redirect($pageurl); diff --git a/grade/report/grader/index.php b/grade/report/grader/index.php index 63a3bd17c99..bbd74e3233c 100644 --- a/grade/report/grader/index.php +++ b/grade/report/grader/index.php @@ -81,27 +81,18 @@ if (!isset($USER->grade_last_report)) { $USER->grade_last_report[$course->id] = 'grader'; // Build editing on/off buttons - -if (!isset($USER->gradeediting)) { - $USER->gradeediting = array(); -} - +$buttons = ''; if (has_capability('moodle/grade:edit', $context)) { - if (!isset($USER->gradeediting[$course->id])) { - $USER->gradeediting[$course->id] = 0; - } - if (($edit == 1) and confirm_sesskey()) { - $USER->gradeediting[$course->id] = 1; - } else if (($edit == 0) and confirm_sesskey()) { - $USER->gradeediting[$course->id] = 0; + if (($edit != - 1) and $PAGE->user_allowed_editing()) { + $USER->editing = $edit; } // page params for the turn editting on $options = $gpr->get_options(); $options['sesskey'] = sesskey(); - if ($USER->gradeediting[$course->id]) { + if (isset($USER->editing) && $USER->editing) { $options['edit'] = 0; $string = get_string('turneditingoff'); } else { @@ -109,10 +100,9 @@ if (has_capability('moodle/grade:edit', $context)) { $string = get_string('turneditingon'); } - $buttons = new single_button(new moodle_url('index.php', $options), $string, 'get'); -} else { - $USER->gradeediting[$course->id] = 0; - $buttons = ''; + if (!$PAGE->theme->haseditswitch) { + $buttons = new single_button(new moodle_url('index.php', $options), $string, 'get'); + } } $gradeserror = array(); @@ -147,14 +137,14 @@ if ($report->currentgroup == -2) { exit; } -// processing posted grades & feedback here -if ($data = data_submitted() and confirm_sesskey() and has_capability('moodle/grade:edit', $context)) { +$warnings = []; +$isediting = has_capability('moodle/grade:edit', $context) && isset($USER->editing) && $USER->editing; +if ($isediting && ($data = data_submitted()) && confirm_sesskey()) { + // Processing posted grades & feedback here. $warnings = $report->process_data($data); -} else { - $warnings = array(); } -// final grades MUST be loaded after the processing +// Final grades MUST be loaded after the processing. $report->load_users(); $report->load_final_grades(); echo $report->group_selector; @@ -186,7 +176,7 @@ if ($numusers == 0) { $reporthtml = $report->get_grade_table($displayaverages); // print submit button -if ($USER->gradeediting[$course->id] && ($report->get_pref('showquickfeedback') || $report->get_pref('quickgrading'))) { +if (!empty($USER->editing) && ($report->get_pref('showquickfeedback') || $report->get_pref('quickgrading'))) { echo '