Merge branch 'MDL-71610-master' of git://github.com/bmbrands/moodle

This commit is contained in:
Ilya Tregubov 2021-09-29 15:40:39 +02:00
commit 34a0ba3232
110 changed files with 769 additions and 265 deletions

View file

@ -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');

View file

@ -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');

View file

@ -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 |

View file

@ -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"

View file

@ -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

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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 |

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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:

View file

@ -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"

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 |

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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:

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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');
}
/**

View file

@ -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"

View file

@ -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"

47
editmode.php Normal file
View file

@ -0,0 +1,47 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* 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);

View file

@ -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 '<form action="index.php" enctype="application/x-www-form-urlencoded" method="post" id="gradereport_grader">'; // Enforce compatibility with our max_input_vars hack.
echo '<div>';
echo '<input type="hidden" value="'.s($courseid).'" name="id" />';

View file

@ -883,7 +883,7 @@ class grade_report_grader extends grade_report {
$categorycell->scope = 'col';
// Print icons.
if ($USER->gradeediting[$this->courseid]) {
if (!empty($USER->editing)) {
$categorycell->text .= $this->get_icons($element);
}
@ -1068,7 +1068,7 @@ class grade_report_grader extends grade_report {
}
// Do not show any icons if no grade (no record in DB to match)
if (!$item->needsupdate and $USER->gradeediting[$this->courseid]) {
if (!$item->needsupdate and !empty($USER->editing)) {
$itemcell->text .= $this->get_icons($element);
}
@ -1093,7 +1093,7 @@ class grade_report_grader extends grade_report {
if ($item->needsupdate) {
$itemcell->text .= "<span class='gradingerror{$hidden}'>" . $strerror . "</span>";
} else if ($USER->gradeediting[$this->courseid]) {
} else if (!empty($USER->editing)) {
if ($item->scaleid && !empty($scalesarray[$item->scaleid])) {
$itemcell->attributes['class'] .= ' grade_type_scale';
@ -1233,7 +1233,7 @@ class grade_report_grader extends grade_report {
// Student grades and feedback are already at $jsarguments['feedback'] and $jsarguments['grades']
}
$jsarguments['cfg']['isediting'] = (bool)$USER->gradeediting[$this->courseid];
$jsarguments['cfg']['isediting'] = !empty($USER->editing);
$jsarguments['cfg']['courseid'] = $this->courseid;
$jsarguments['cfg']['studentsperpage'] = $this->get_students_per_page();
$jsarguments['cfg']['showquickfeedback'] = (bool) $showquickfeedback;
@ -1246,7 +1246,7 @@ class grade_report_grader extends grade_report {
$PAGE->requires->js_init_call('M.gradereport_grader.init_report', $jsarguments, false, $module);
$PAGE->requires->strings_for_js(array('addfeedback', 'feedback', 'grade'), 'grades');
$PAGE->requires->strings_for_js(array('ajaxchoosescale', 'ajaxclicktoclose', 'ajaxerror', 'ajaxfailedupdate', 'ajaxfieldchanged'), 'gradereport_grader');
if (!$enableajax && $USER->gradeediting[$this->courseid]) {
if (!$enableajax && !empty($USER->editing)) {
$PAGE->requires->js_call_amd('core_form/changechecker', 'watchFormById', ['gradereport_grader']);
}
@ -1298,7 +1298,7 @@ class grade_report_grader extends grade_report {
public function get_left_icons_row($rows=array(), $colspan=1) {
global $USER;
if ($USER->gradeediting[$this->courseid]) {
if (!empty($USER->editing)) {
$controlsrow = new html_table_row();
$controlsrow->attributes['class'] = 'controls';
$controlscell = new html_table_cell();
@ -1395,7 +1395,7 @@ class grade_report_grader extends grade_report {
*/
public function get_right_icons_row($rows=array()) {
global $USER;
if ($USER->gradeediting[$this->courseid]) {
if (!empty($USER->editing)) {
$iconsrow = new html_table_row();
$iconsrow->attributes['class'] = 'controls';
@ -1575,7 +1575,7 @@ class grade_report_grader extends grade_report {
}
// Determine which display type to use for this average
if ($USER->gradeediting[$this->courseid]) {
if (!empty($USER->editing)) {
$displaytype = GRADE_DISPLAY_TYPE_REAL;
} else if ($averagesdisplaytype == GRADE_REPORT_PREFERENCE_INHERIT) { // no ==0 here, please resave the report and user preferences
@ -1685,7 +1685,7 @@ class grade_report_grader extends grade_report {
protected function get_icons($element) {
global $CFG, $USER, $OUTPUT;
if (!$USER->gradeediting[$this->courseid]) {
if (empty($USER->editing)) {
return '<div class="grade_icons" />';
}
@ -1981,4 +1981,3 @@ class grade_report_grader extends grade_report {
return $this->get_pref('studentsperpage');
}
}

View file

@ -55,7 +55,7 @@ Feature: We can change what we are viewing on the grader report
When I am on "Course 1" course homepage with editing mode on
And I open "Test assignment name 2" actions menu
And I click on "Hide" "link" in the "Test assignment name 2" activity
And I am on "Course 1" course homepage
And I am on "Course 1" course homepage with editing mode off
And I navigate to "View > Grader report" in the course gradebook
And I should see "Test assignment name 1"
And I should see "Test assignment name 2"

View file

@ -1053,7 +1053,7 @@ class grade_report_user extends grade_report {
}
// Determine which display type to use for this average
if (!empty($USER->gradeediting) && $USER->gradeediting[$this->courseid]) {
if (isset($USER->editing) && $USER->editing) {
$displaytype = GRADE_DISPLAY_TYPE_REAL;
} else if ($averagesdisplaytype == GRADE_REPORT_PREFERENCE_INHERIT) { // no ==0 here, please resave the report and user preferences

View file

@ -65,7 +65,7 @@ Feature: Calculated grade items can be used in the gradebook
And I set the following settings for grade item "Calc cat":
| Maximum grade | 50 |
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 "75.00" to the user "Student 1" for the grade item "grade item 1"
And I press "Save changes"
And I navigate to "View > User report" in the course gradebook
@ -131,7 +131,7 @@ Feature: Calculated grade items can be used in the gradebook
| Min and max grades used in calculation | Initial min and max grades |
And I press "Save changes"
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 "75.00" to the user "Student 1" for the grade item "grade item 1"
And I press "Save changes"
And I navigate to "View > User report" in the course gradebook

View file

@ -33,10 +33,10 @@ Feature: We can customise the letter boundary of a course.
| id_gradeboundary10 | 57 |
And I press "Save changes"
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 1" for the grade item "Test assignment one"
And I press "Save changes"
And I press "Turn editing off"
And I turn editing mode off
Then the following should exist in the "user-grades" table:
| -1- | -4- | -5- |
| Student 1 | D | D |

View file

@ -34,10 +34,10 @@ Feature: We can customise the letter boundary of a course in gradebook version 2
| id_gradeboundary10 | 57 |
And I press "Save changes"
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 1" for the grade item "Test assignment one"
And I press "Save changes"
And I press "Turn editing off"
And I turn editing mode off
Then the following should exist in the "user-grades" table:
| -1- | -4- | -5- |
| Student 1 | F | F |

View file

@ -85,7 +85,6 @@ Feature: We can set the grade to pass value
| Grade to pass | 3 |
And I press "Save and return to course"
And I navigate to "View > Grader report" in the course gradebook
And I turn editing mode on
And I click on "Edit assign Test Assignment 1" "link"
And I expand all fieldsets
Then the field "Grade to pass" matches value "3"
@ -124,7 +123,6 @@ Feature: We can set the grade to pass value
| Assessment grade to pass | 10 |
And I press "Save and return to course"
And I navigate to "View > Grader report" in the course gradebook
And I turn editing mode on
And I click on "Edit workshop Test Workshop 1 (submission)" "link"
And I expand all fieldsets
Then the field "Grade to pass" matches value "40"
@ -168,7 +166,6 @@ Feature: We can set the grade to pass value
| Grade to pass | 9.5 |
And I press "Save and return to course"
And I navigate to "View > Grader report" in the course gradebook
And I turn editing mode on
And I click on "Edit quiz Test Quiz 1" "link"
And I expand all fieldsets
Then the field "Grade to pass" matches value "9.5"
@ -190,7 +187,6 @@ Feature: We can set the grade to pass value
| Grade to pass | 90 |
And I press "Save and return to course"
And I navigate to "View > Grader report" in the course gradebook
And I turn editing mode on
And I click on "Edit lesson Test Lesson 1" "link"
And I expand all fieldsets
Then the field "Grade to pass" matches value "90"
@ -215,7 +211,6 @@ Feature: We can set the grade to pass value
| Ratings > Grade to pass | 90 |
And I press "Save and return to course"
And I navigate to "View > Grader report" in the course gradebook
And I turn editing mode on
And I click on "Edit data Test Database 1" "link"
And I expand all fieldsets
Then the field "Grade to pass" matches value "90"
@ -256,7 +251,6 @@ Feature: We can set the grade to pass value
| Ratings > Grade to pass | 90 |
And I press "Save and return to course"
And I navigate to "View > Grader report" in the course gradebook
And I turn editing mode on
And I click on "Edit forum Test Forum 1 rating" "link"
And I expand all fieldsets
Then the field "Grade to pass" matches value "90"
@ -280,7 +274,6 @@ Feature: We can set the grade to pass value
| Ratings > Grade to pass | 90 |
And I press "Save and return to course"
And I navigate to "View > Grader report" in the course gradebook
And I turn editing mode on
And I click on "Edit glossary Test Glossary 1" "link"
And I expand all fieldsets
Then the field "Grade to pass" matches value "90"

View file

@ -261,7 +261,7 @@ class core_grade_report_graderlib_testcase extends advanced_testcase {
// Set current user.
$this->setUser($manager);
$USER->gradeediting[$course->id] = false;
$USER->editing = false;
// Get the report.
$report = $this->create_report($course);

View file

@ -152,6 +152,7 @@ $string['cannotsetupblock'] = 'Blocks tables could NOT be set up successfully!';
$string['cannotsetupcapformod'] = 'Could not set up the capabilities for {$a}';
$string['cannotsetupcapforplugin'] = 'Could not set up the capabilities for {$a}';
$string['cannotshowhidecoursesincategory'] = 'Cannot show/hide the courses in category {$a}.';
$string['cannotswitcheditmodeon'] = 'Could not switch edit mode on';
$string['cannotsignup'] = 'You cannot create a new account because you are already logged in as {$a}.';
$string['cannotunassigncap'] = 'Could not unassign deprecated capability {$a->cap} from role {$a->role}';
$string['cannotunassignrolefrom'] = 'Cannot unassign this user from role id: {$a}';

View file

@ -579,6 +579,7 @@ $string['editfiles'] = 'Edit files';
$string['editgroupprofile'] = 'Edit group profile';
$string['editinga'] = 'Editing {$a}';
$string['editingteachershort'] = 'Editor';
$string['editmode'] = 'Edit mode';
$string['editlock'] = 'This value cannot be edited!';
$string['editmyprofile'] = 'Edit profile';
$string['editorbgcolor'] = 'Background-color';
@ -1901,6 +1902,7 @@ $string['serverlocaltime'] = 'Server\'s local time';
$string['sessionforceclean'] = 'As a security precaution, user-generated scripts have been disabled within this session.';
$string['sessiontimeoutsoon'] = 'Your session is about to time out. Do you want to extend your current session?';
$string['setcategorytheme'] = 'Set category theme';
$string['setmode'] = 'Set mode';
$string['setpassword'] = 'Set password';
$string['setpasswordinstructions'] = 'Please enter your new password below, then save changes.';
$string['settings'] = 'Settings';

View file

@ -8836,7 +8836,7 @@ function admin_externalpage_setup($section, $extrabutton = '', array $extraurlpa
$visiblepathtosection = array_reverse($extpage->visiblepath);
if ($PAGE->user_allowed_editing()) {
if ($PAGE->user_allowed_editing() && !$PAGE->theme->haseditswitch) {
if ($PAGE->user_is_editing()) {
$caption = get_string('blockseditoff');
$url = new moodle_url($PAGE->url, array('adminedit'=>'0', 'sesskey'=>sesskey()));

2
lib/amd/build/edit_switch.min.js vendored Normal file
View file

@ -0,0 +1,2 @@
define ("core/edit_switch",["exports","core/ajax","core/event_dispatcher","core/notification"],function(a,b,c,d){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=a.eventTypes=void 0;var e=function(a,c){return(0,b.call)([{methodname:"core_change_editmode",args:{context:a,setmode:c}}])[0]},f=function(a){if(a.checked){a.setAttribute("aria-checked",!0)}else{a.setAttribute("aria-checked",!1)}var b=h(a,a.checked);if(!b.defaultPrevented){window.location=a.dataset.pageurl}},g={editModeSet:"core/edit_switch/editModeSet"};a.eventTypes=g;var h=function(a,b){return(0,c.dispatchEvent)(g.editModeSet,{editMode:b},a,{cancelable:!0})};a.init=function init(a){var b=document.getElementById(a);b.addEventListener("change",function(){e(b.dataset.context,b.checked).then(function(a){if(a.success){f(b)}else{b.checked=!1}}).catch(d.exception)})}});
//# sourceMappingURL=edit_switch.min.js.map

File diff suppressed because one or more lines are too long

121
lib/amd/src/edit_switch.js Normal file
View file

@ -0,0 +1,121 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Controls the edit switch.
*
* @module core/edit_switch
* @copyright 2021 Bas Brands <bas@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import {call as fetchMany} from 'core/ajax';
import {dispatchEvent} from 'core/event_dispatcher';
import {exception as displayException} from 'core/notification';
/**
* Change the Edit mode.
*
* @param {number} context The contextid that editing is being set for
* @param {bool} setmode Whether editing is set or not
* @return {Promise} Resolved with an array file the stored file url.
*/
const setEditMode = (context, setmode) => fetchMany([{
methodname: 'core_change_editmode',
args: {
context,
setmode,
},
}])[0];
/**
* Toggle the edit switch
*
* @method
* @protected
* @param {HTMLElement} editSwitch
*/
const toggleEditSwitch = editSwitch => {
if (editSwitch.checked) {
editSwitch.setAttribute('aria-checked', true);
} else {
editSwitch.setAttribute('aria-checked', false);
}
const event = notifyEditModeSet(editSwitch, editSwitch.checked);
if (!event.defaultPrevented) {
window.location = editSwitch.dataset.pageurl;
}
};
/**
* Names of events for core/edit_switch.
*
* @static
* @property {String} editModeSet See {@link event:core/edit_switch/editModeSet}
*/
export const eventTypes = {
/**
* An event triggered when the edit mode toggled.
*
* @event core/edit_switch/editModeSet
* @type {CustomEvent}
* @property {HTMLElement} target The switch used to toggle the edit mode
* @property {object} detail
* @property {bool} detail.editMode
*/
editModeSet: 'core/edit_switch/editModeSet',
};
/**
* Dispatch the editModeSet event after changing the edit mode.
*
* This event is cancelable.
*
* The default action is to reload the page after toggling the edit mode.
*
* @method
* @protected
* @param {HTMLElement} container
* @param {bool} editMode
* @returns {CustomEvent}
*/
const notifyEditModeSet = (container, editMode) => dispatchEvent(
eventTypes.editModeSet,
{editMode},
container,
{cancelable: true}
);
/**
* Add the eventlistener for the editswitch.
*
* @param {string} editingSwitchId The id of the editing switch to listen for
*/
export const init = editingSwitchId => {
const editSwitch = document.getElementById(editingSwitchId);
editSwitch.addEventListener('change', () => {
setEditMode(editSwitch.dataset.context, editSwitch.checked)
.then(result => {
if (result.success) {
toggleEditSwitch(editSwitch);
} else {
editSwitch.checked = false;
}
return;
})
.catch(displayException);
});
};

View file

@ -134,7 +134,7 @@ trait behat_session_trait {
}
// How much we will be waiting for the element to appear.
if (!$timeout) {
if ($timeout === false) {
$timeout = self::get_timeout();
$microsleep = false;
} else {
@ -339,7 +339,7 @@ trait behat_session_trait {
protected function spin($lambda, $args = false, $timeout = false, $exception = false, $microsleep = false) {
// Using default timeout which is pretty high.
if (!$timeout) {
if ($timeout === false) {
$timeout = self::get_timeout();
}

103
lib/classes/external/editmode.php vendored Normal file
View file

@ -0,0 +1,103 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A web service to load the mapping of moodle pix names to fontawesome icon names.
*
* @package core
* @category external
* @copyright 2021 Bas Brands <bas@sonsbeekmedia.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\external;
use external_api;
use external_function_parameters;
use external_single_structure;
use external_value;
/**
* Web service to change the edit mode.
*
* @package core
* @copyright 2021 Bas Brands <bas@sonsbeekmedia.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class editmode extends external_api {
/**
* Description of the parameters suitable for the `change_editmode` function.
*
* @return external_function_parameters
*/
public static function change_editmode_parameters(): external_function_parameters {
return new external_function_parameters(
[
'setmode' => new external_value(PARAM_BOOL, 'Set edit mode to'),
'context' => new external_value(PARAM_INT, 'Page context id')
]
);
}
/**
* Save the image and return any warnings and the new image url
*
* @param bool $setmode the current edit mode
* @param int $contextid the current page context id
* @return array the new edit mode.
*/
public static function change_editmode(bool $setmode, int $contextid): array {
global $USER, $PAGE;
$params = self::validate_parameters(
self::change_editmode_parameters(),
[
'setmode' => $setmode,
'context' => $contextid
]
);
$context = \context_helper::instance_by_id($params['context']);
self::validate_context($context);
$PAGE->set_context($context);
if ($context->id === \context_user::instance($USER->id)->id) {
$PAGE->set_blocks_editing_capability('moodle/my:manageblocks');
}
$success = false;
if ($PAGE->user_allowed_editing()) {
$USER->editing = $setmode;
$success = true;
}
return ['success' => $success];
}
/**
* Description of the return value for the `change_editmode` function.
*
* @return external_single_structure
*/
public static function change_editmode_returns(): external_single_structure {
$keys = [
'success' => new external_value(PARAM_BOOL, 'The edit mode was changed', VALUE_REQUIRED),
];
return new external_single_structure($keys, 'editmode');
}
}

View file

@ -2785,7 +2785,13 @@ $functions = array(
'type' => 'read',
'ajax' => true,
],
'core_change_editmode' => [
'classname' => 'core\external\editmode',
'methodname' => 'change_editmode',
'description' => 'Change the editing mode',
'type' => 'write',
'ajax' => true,
],
);
$services = array(

View file

@ -2484,7 +2484,7 @@ class grade_item extends grade_object {
global $USER;
// Determine which display type to use for this average
if (isset($USER->gradeediting) && array_key_exists($this->courseid, $USER->gradeediting) && $USER->gradeediting[$this->courseid]) {
if (isset($USER->editing) && $USER->editing) {
$displaytype = GRADE_DISPLAY_TYPE_REAL;
} else if ($rangesdisplaytype == GRADE_REPORT_PREFERENCE_INHERIT) { // no ==0 here, please resave report and user prefs

View file

@ -5434,7 +5434,7 @@ class settings_navigation extends navigation_node {
}
$frontpage->id = 'frontpagesettings';
if ($this->page->user_allowed_editing()) {
if ($this->page->user_allowed_editing() && !$this->page->theme->haseditswitch) {
// Add the turn on/off settings
$url = new moodle_url('/course/view.php', array('id'=>$course->id, 'sesskey'=>sesskey()));

View file

@ -754,7 +754,7 @@ class theme_config {
'rendererfactory', 'csspostprocess', 'editor_sheets', 'editor_scss', 'rarrow', 'larrow', 'uarrow', 'darrow',
'hidefromselector', 'doctype', 'yuicssmodules', 'blockrtlmanipulations', 'blockrendermethod',
'scss', 'extrascsscallback', 'prescsscallback', 'csstreepostprocessor', 'addblockposition',
'iconsystem', 'precompiledcsscallback');
'iconsystem', 'precompiledcsscallback', 'haseditswitch');
foreach ($config as $key=>$value) {
if (in_array($key, $configurable)) {

View file

@ -2748,6 +2748,9 @@ EOD;
*/
public function edit_button(moodle_url $url) {
if ($this->page->theme->haseditswitch == true) {
return;
}
$url->param('sesskey', sesskey());
if ($this->page->user_is_editing()) {
$url->param('edit', 'off');
@ -2760,6 +2763,27 @@ EOD;
return $this->single_button($url, $editstring);
}
/**
* Create a navbar switch for toggling editing mode.
*
* @return string Html containing the edit switch
*/
public function edit_switch() {
if ($this->page->user_allowed_editing()) {
$temp = (object) [
'legacyseturl' => (new moodle_url('/editmode.php'))->out(false),
'pagecontextid' => $this->page->context->id,
'pageurl' => $this->page->url,
'sesskey' => sesskey(),
];
if ($this->page->user_is_editing()) {
$temp->checked = true;
}
return $this->render_from_template('core/editswitch', $temp);
}
}
/**
* Returns HTML to display a simple button to close a window
*

View file

@ -0,0 +1,63 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template theme_boost/editswitch
This template renders the top navbar.
Example context (json):
{
"url": "http://localhost/",
"sesskey": "sesskey",
"edit": 1,
"adminedit": true,
"checked": "",
"string": "Edit on"
}
}}
<form action="{{{legacyseturl}}}" method="post" class="d-flex align-items-center editmode-switch-form">
<div class="custom-control custom-control-right custom-switch text-nowrap">
<input type="checkbox"{{!
}} name="setmode"{{!
}}{{#checked}}{{!
}} aria-checked="true" checked{{!
}}{{/checked}}{{!
}}{{^checked}}{{!
}} aria-checked="false"{{!
}}{{/checked}}{{!
}} class="custom-control-input"{{!
}} id="{{uniqid}}-editingswitch"{{!
}} data-context="{{{pagecontextid}}}"{{!
}} data-pageurl="{{{pageurl}}}"{{!
}}>
<label class="custom-control-label" for="{{uniqid}}-editingswitch">
{{#str}} editmode {{/str}}
</label>
<input type="hidden" name="sesskey" value="{{{sesskey}}}">
<input type="hidden" name="pageurl" value="{{{pageurl}}}">
<input type="hidden" name="context" value="{{{pagecontextid}}}">
<noscript>
<input type="submit" value="{{#str}}setmode, core{{/str}}">
</noscript>
</div>
</form>
{{#js}}
require(['core/edit_switch'], function(editSwitch) {
editSwitch.init('{{uniqid}}-editingswitch');
});
{{/js}}

View file

@ -833,33 +833,38 @@ class behat_navigation extends behat_base {
/**
* Open the course homepage with editing mode enabled.
*
* @Given /^I am on "(?P<coursefullname_string>(?:[^"]|\\")*)" course homepage with editing mode on$/
* @throws coding_exception
* @param string $coursefullname The course full name of the course.
* @return void
*/
public function i_am_on_course_homepage_with_editing_mode_on($coursefullname) {
$this->i_am_on_course_homepage_with_editing_mode_set_to($coursefullname, 'on');
}
/**
* Open the course homepage with editing mode set to either on, or off.
*
* @Given I am on :coursefullname course homepage with editing mode :onoroff
* @throws coding_exception
* @param string $coursefullname The course full name of the course.
* @param string $onoroff Whehter to switch editing on, or off.
*/
public function i_am_on_course_homepage_with_editing_mode_set_to(string $coursefullname, string $onoroff): void {
global $DB;
$course = $DB->get_record("course", array("fullname" => $coursefullname), 'id', MUST_EXIST);
$url = new moodle_url('/course/view.php', ['id' => $course->id]);
if ($this->running_javascript() && $sesskey = $this->get_sesskey()) {
// Javascript is running so it is possible to grab the session ket and jump straight to editing mode.
$url->param('edit', 1);
$url->param('sesskey', $sesskey);
$this->execute('behat_general::i_visit', [$url]);
return;
}
// Visit the course page.
$this->execute('behat_general::i_visit', [$url]);
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')]);
switch ($onoroff) {
case 'on':
$this->execute('behat_navigation::i_turn_editing_mode_on');
break;
case 'off':
$this->execute('behat_navigation::i_turn_editing_mode_off');
break;
default:
throw new \coding_exception("Unknown editing mode '{$onoroff}'. Accepted values are 'on' and 'off'");
}
}
@ -1103,7 +1108,6 @@ class behat_navigation extends behat_base {
$this->execute('behat_general::i_visit', [$url]);
}
/**
* First checks to see if we are on this page via the breadcrumb. If not we then attempt to follow the link name given.
*
@ -1193,4 +1197,54 @@ class behat_navigation extends behat_base {
"//div[contains(concat(' ', @class, ' '), ' dropdown-menu ')]" .
"//div[contains(concat(' ', @class, ' '), ' submenu ')][@aria-label='" . $submenuname . "']";
}
/**
* Returns whether the user can edit the current page.
*
* @return bool
*/
protected function is_editing_on() {
$body = $this->find('xpath', "//body", false, false, 0);
return $body->hasClass('editing');
}
/**
* Turns editing mode on.
* @Given I switch editing mode on
* @Given I turn editing mode on
*/
public function i_turn_editing_mode_on() {
$this->execute('behat_forms::i_set_the_field_to', [get_string('editmode'), 1]);
if (!$this->running_javascript()) {
$this->execute('behat_general::i_click_on', [
get_string('setmode', 'core'),
'button',
]);
}
if (!$this->is_editing_on()) {
throw new ExpectationException('The edit mode could not be turned on', $this->getSession());
}
}
/**
* Turns editing mode off.
* @Given I switch editing mode off
* @Given I turn editing mode off
*/
public function i_turn_editing_mode_off() {
$this->execute('behat_forms::i_set_the_field_to', [get_string('editmode'), 0]);
if (!$this->running_javascript()) {
$this->execute('behat_general::i_click_on', [
get_string('setmode', 'core'),
'button',
]);
}
if ($this->is_editing_on()) {
throw new ExpectationException('The edit mode could not be turned off', $this->getSession());
}
}
}

View file

@ -44,15 +44,15 @@ Feature: Context freezing apply to child contexts
And I click on "Continue" "button"
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa1" course homepage
Then I should see "Turn editing on"
Then "Set mode" "button" should exist
When I follow "faa1b"
Then "Add a new discussion topic" "link" should exist
When I am on "courseaa2" course homepage
Then I should see "Turn editing on"
Then "Set mode" "button" should exist
When I follow "faa2"
Then "Add a new discussion topic" "link" should exist
When I am on "courseb" course homepage
Then I should see "Turn editing on"
Then "Set mode" "button" should exist
When I follow "fb"
Then "Add a new discussion topic" "link" should exist
@ -61,15 +61,15 @@ Feature: Context freezing apply to child contexts
And I follow "faa1"
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa1" course homepage
Then I should see "Turn editing on"
Then "Set mode" "button" should exist
When I follow "faa1b"
Then "Add a new discussion topic" "link" should exist
When I am on "courseaa2" course homepage
Then I should see "Turn editing on"
Then "Set mode" "button" should exist
When I follow "faa2"
Then "Add a new discussion topic" "link" should exist
When I am on "courseb" course homepage
Then I should see "Turn editing on"
Then "Set mode" "button" should exist
When I follow "fb"
And "Add a new discussion topic" "link" should exist
@ -89,23 +89,23 @@ Feature: Context freezing apply to child contexts
Scenario: Freeze course should freeze all children
Given I am on the "courseaa1" "Course" page logged in as "admin"
And I should see "Turn editing on"
And "Set mode" "button" should exist
When I follow "Freeze this context"
And I click on "Continue" "button"
Then I should not see "Turn editing on"
Then "Set mode" "button" should not exist
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa1" course homepage
Then I should not see "Turn editing on"
Then "Set mode" "button" should not exist
And "Unfreeze this context" "link" should exist in current page administration
When I follow "faa1b"
Then "Add a new discussion topic" "link" should not exist
And "Unfreeze this context" "link" should not exist in current page administration
When I am on "courseaa2" course homepage
Then I should see "Turn editing on"
Then "Set mode" "button" should exist
When I follow "faa2"
Then "Add a new discussion topic" "link" should exist
When I am on "courseb" course homepage
Then I should see "Turn editing on"
Then "Set mode" "button" should exist
When I follow "fb"
Then "Add a new discussion topic" "link" should exist
@ -114,15 +114,15 @@ Feature: Context freezing apply to child contexts
And I follow "faa1"
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa1" course homepage
Then I should not see "Turn editing on"
Then "Set mode" "button" should not exist
When I follow "faa1b"
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa2" course homepage
Then I should see "Turn editing on"
Then "Set mode" "button" should exist
When I follow "faa2"
Then "Add a new discussion topic" "link" should exist
When I am on "courseb" course homepage
Then I should see "Turn editing on"
Then "Set mode" "button" should exist
When I follow "fb"
Then "Add a new discussion topic" "link" should exist
@ -146,39 +146,39 @@ Feature: Context freezing apply to child contexts
And I click on "managecontextlock" action for "cata" in management category listing
And I click on "Continue" "button"
And I am on "courseaa1" course homepage
And I should not see "Turn editing on"
And "Set mode" "button" should not exist
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa1" course homepage
Then I should not see "Turn editing on"
Then "Set mode" "button" should not exist
And "Unfreeze this context" "link" should not exist in current page administration
When I follow "faa1b"
Then "Add a new discussion topic" "link" should not exist
And "Unfreeze this context" "link" should not exist in current page administration
When I am on "courseaa2" course homepage
Then I should not see "Turn editing on"
Then "Set mode" "button" should not exist
When I follow "faa2"
Then "Add a new discussion topic" "link" should not exist
And "Unfreeze this context" "link" should not exist in current page administration
When I am on "courseb" course homepage
Then I should see "Turn editing on"
Then "Set mode" "button" should exist
When I follow "fb"
Then "Add a new discussion topic" "link" should exist
And I log out
When I am on the "courseaa1" "Course" page logged in as "teacher"
Then I should not see "Turn editing on"
Then "Set mode" "button" should not exist
And I follow "faa1"
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa1" course homepage
Then I should not see "Turn editing on"
Then "Set mode" "button" should not exist
When I follow "faa1b"
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa2" course homepage
Then I should not see "Turn editing on"
Then "Set mode" "button" should not exist
When I follow "faa2"
Then "Add a new discussion topic" "link" should not exist
When I am on "courseb" course homepage
Then I should see "Turn editing on"
Then "Set mode" "button" should exist
When I follow "fb"
Then "Add a new discussion topic" "link" should exist

View file

@ -0,0 +1,79 @@
@core @turn_edit_mode_on @javascript
Feature: Turn editing mode on
Users should be able to turn editing mode on and off
Background:
Given the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I turn editing mode off
And I log out
Scenario: Edit mode on page Gradebook
Given the following "activities" exist:
| activity | course | idnumber | name | intro |
| assign | C1 | assign1 | Test Assignment 1 | Test Assignment 1 |
And I log in as "teacher1"
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 "Edit assign Test Assignment 1" "link" should exist
And I turn editing mode off
Then "Edit assign Test Assignment 1" "link" should not exist
Scenario: Edit mode on page Course
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I turn editing mode on
And I should see "Add an activity or resource"
And I turn editing mode off
Then I should not see "Add an activity or resource"
Scenario: Edit mode on page Homepage
Given I log in as "admin"
And I am on site homepage
And I turn editing mode on
And I should see "Add an activity or resource"
And I turn editing mode off
Then I should not see "Add an activity or resource"
Scenario: Edit mode on page Default profile
Given I log in as "admin"
And I navigate to "Appearance > Default profile page" in site administration
And I turn editing mode on
And I should see "Add a block"
And I turn editing mode off
Then I should not see "Add a block"
Scenario: Edit mode on page Profile
Given I log in as "admin"
And I follow "View profile"
And I turn editing mode on
And I should see "Add a block"
And I turn editing mode off
Then I should not see "Add a block"
Scenario: Edit mode on page Default dashboard
Given I log in as "admin"
And I navigate to "Appearance > Default Dashboard page" in site administration
And I turn editing mode on
And I should see "Add a block"
And I turn editing mode off
Then I should not see "Add a block"
Scenario: Edit mode on page Dashboard
And I log in as "teacher1"
And I turn editing mode on
And I should see "Add a block"
Then I turn editing mode off
Then I should not see "Add a block"

View file

@ -7,7 +7,7 @@ Feature: Embed videos without the media filter
Background:
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
@javascript
Scenario: Add a video in a URL resource. Make sure media filters work

View file

@ -346,7 +346,9 @@ function book_extend_settings_navigation(settings_navigation $settingsnav, navig
$url = new moodle_url('/mod/book/view.php', array('id'=>$params['id'], 'chapterid'=>$params['chapterid'], 'edit'=>$edit, 'sesskey'=>sesskey()));
$editnode = navigation_node::create($string, $url, navigation_node::TYPE_SETTING);
$booknode->add_node($editnode, $firstkey);
$PAGE->set_button($OUTPUT->single_button($url, $string));
if (!$PAGE->theme->haseditswitch) {
$PAGE->set_button($OUTPUT->single_button($url, $string));
}
}
$plugins = core_component::get_plugin_list('booktool');

View file

@ -73,7 +73,7 @@ Feature: In a book, create chapters and sub chapters
And "Delete chapter \"1. Dummy first chapter\"" "link" should exist in the "Table of contents" "block"
And "Hide chapter \"1. Dummy first chapter\"" "link" should exist in the "Table of contents" "block"
And "Add new chapter" "link" should exist in the "Table of contents" "block"
When I press "Turn editing off"
When I turn editing mode off
Then "Edit chapter \"1. Dummy first chapter\"" "link" should not exist in the "Table of contents" "block"
And "Delete chapter \"1. Dummy first chapter\"" "link" should not exist in the "Table of contents" "block"
And "Hide chapter \"1. Dummy first chapter\"" "link" should not exist in the "Table of contents" "block"

View file

@ -33,7 +33,7 @@ Feature: Edited book chapters handle tags correctly
Then I should see "Example" in the ".book-tags" "css_element"
And I should see "Chapter" in the ".book-tags" "css_element"
And I should see "Cool" in the ".book-tags" "css_element"
And I press "Turn editing on"
And I turn editing mode on
And I follow "Edit chapter \"1. Dummy first chapter\""
Then I should see "Example" in the ".form-autocomplete-selection" "css_element"
Then I should see "Chapter" in the ".form-autocomplete-selection" "css_element"
@ -42,6 +42,7 @@ Feature: Edited book chapters handle tags correctly
@javascript
Scenario: Book chapter edition of standard tags works as expected
Given I log in as "admin"
And I change window size to "large"
And I navigate to "Appearance > Manage tags" in site administration
And I follow "Default collection"
And I follow "Add standard tags"
@ -61,7 +62,7 @@ Feature: Edited book chapters handle tags correctly
Then I should see "OT1" in the ".book-tags" "css_element"
And I should see "OT3" in the ".book-tags" "css_element"
And I should not see "OT2" in the ".book-tags" "css_element"
And I press "Turn editing on"
And I turn editing mode on
And I follow "Edit chapter \"1. Dummy first chapter\""
And I should see "OT1" in the ".form-autocomplete-selection" "css_element"
And I should see "OT3" in the ".form-autocomplete-selection" "css_element"

View file

@ -17,7 +17,7 @@ Feature: Teachers can enable comments only if comments are enabled at site level
| teacher1 | C1 | editingteacher |
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I press "Turn editing on"
And I turn editing mode on
And I press "Add an activity or resource"
And I click on "Add a new Database" "link" in the "Add an activity or resource" "dialogue"
And I expand all fieldsets

View file

@ -231,7 +231,7 @@
// The code will be much nicer than this eventually.
$title = $courseshortname.': ' . format_string($data->name);
if ($PAGE->user_allowed_editing()) {
if ($PAGE->user_allowed_editing() && !$PAGE->theme->haseditswitch) {
// Change URL parameter and block display string value depending on whether editing is enabled or not
if ($PAGE->user_is_editing()) {
$urlediting = 'off';

View file

@ -232,7 +232,7 @@ Feature: Mapping courses in a feedback
And I add the "Main menu" block
And I click on "Delete" "link" in the "Course feedback" activity
And I press "Yes"
And I follow "Turn editing off"
And I turn editing mode off
And I am on site homepage
Then "Feedback" "block" should not exist
And I am on "Course 1" course homepage

View file

@ -40,6 +40,7 @@ Feature: Edited forum posts handle tags correctly
@javascript
Scenario: Forum post edition of standard tags works as expected
Given I log in as "admin"
And I change window size to "large"
And I navigate to "Appearance > Manage tags" in site administration
And I follow "Default collection"
And I follow "Add standard tags"

View file

@ -117,7 +117,6 @@ Feature: I can grade a students interaction across a forum
And I set the field "Ratings > Grade to pass" to "4"
When I press "Save and return to course"
And I navigate to "View > Grader report" in the course gradebook
And I turn editing mode on
# There shouldn't be any Whole forum grade gradeitem.
Then I should see "Test Forum 1 rating"

View file

@ -41,6 +41,7 @@ Feature: Edited glossary entries handle tags correctly
Scenario: Glossary entry edition of standard tags works as expected
Given I log in as "admin"
And I change window size to "large"
And I navigate to "Appearance > Manage tags" in site administration
And I follow "Default collection"
And I follow "Add standard tags"

View file

@ -68,7 +68,7 @@ Feature: A teacher can choose whether glossary entries require approval
| Tags | Test |
And I log out
And I log in as "teacher1"
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 "Tags" "link" in the "Navigation" "block"

View file

@ -42,6 +42,7 @@ Feature: Edited wiki pages handle tags correctly
@javascript
Scenario: Wiki page edition of standard tags works as expected
Given I log in as "admin"
And I change window size to "large"
And I navigate to "Appearance > Manage tags" in site administration
And I follow "Default collection"
And I follow "Add standard tags"

View file

@ -155,7 +155,10 @@ if (empty($CFG->forcedefaultmymoodle) && $PAGE->user_allowed_editing()) {
}
$url = new moodle_url("$CFG->wwwroot/my/index.php", $params);
$button = $OUTPUT->single_button($url, $editstring);
$button = '';
if (!$PAGE->theme->haseditswitch) {
$button = $OUTPUT->single_button($url, $editstring);
}
$PAGE->set_button($resetbutton . $button);
} else {

View file

@ -19,9 +19,9 @@ Feature: Add blocks to dashboard page
And I log in as "student1"
Scenario: Add blocks to page
When I press "Customise this page"
When I turn editing mode on
And I add the "Latest announcements" block
And I press "Stop customising this page"
And I turn editing mode off
Then I should see "Latest announcements" in the "Latest announcements" "block"
And I should see "Latest badges" in the "Latest badges" "block"
And I should see "Calendar" in the "Calendar" "block"

View file

@ -18,18 +18,18 @@ Feature: Reset all personalised pages to default
And I log in as "student1"
And I follow "Dashboard" in the user menu
And I press "Customise this page"
And I turn editing mode on
And I add the "Comments" block
And I press "Stop customising this page"
And I turn editing mode off
And I should see "Comments"
And I log out
And I log in as "student2"
And I follow "Profile" in the user menu
And I should not see "Logged in user"
And I press "Customise this page"
And I turn editing mode on
And I add the "Logged in user" block
And I press "Stop customising this page"
And I turn editing mode off
And I should see "Logged in user"
And I log out
@ -43,12 +43,12 @@ Feature: Reset all personalised pages to default
Scenario: Reset Dashboard for all users
Given I log in as "admin"
And I navigate to "Appearance > Default Dashboard page" in site administration
And I press "Blocks editing on"
And I turn editing mode on
And I add the "Latest announcements" block
And I open the "Latest badges" blocks action menu
And I follow "Delete Latest badges block"
And I press "Yes"
And I press "Blocks editing off"
And I turn editing mode off
And I log out
And I log in as "student1"
@ -91,7 +91,7 @@ Feature: Reset all personalised pages to default
Scenario: Reset profile for all users
Given I log in as "admin"
And I navigate to "Appearance > Default profile page" in site administration
And I press "Blocks editing on"
And I turn editing mode on
And I add the "Latest announcements" block
And I log out

View file

@ -19,7 +19,7 @@ Feature: Reset dashboard page to default
And I log in as "student1"
Scenario: Add blocks to page and reset
When I press "Customise this page"
When I turn editing mode on
And I add the "Latest announcements" block
And I add the "Comments" block
And I press "Reset page to default"

View file

@ -18,7 +18,7 @@ Feature: Restrict which blocks can be added to Dashboard
Scenario: The comments block can be added to Dashboard by default
And I log in as "student1"
And I press "Customise this page"
And I turn editing mode on
Then the add block selector should contain "Comments" block
And the add block selector should contain "Courses" block
And the add block selector should contain "Text" block
@ -32,7 +32,7 @@ Feature: Restrict which blocks can be added to Dashboard
| block/html:myaddinstance | Prohibit |
And I log out
And I log in as "student1"
And I press "Customise this page"
And I turn editing mode on
Then the add block selector should not contain "Comments" block
And the add block selector should not contain "Courses" block
And the add block selector should not contain "Text" block

View file

@ -10,7 +10,7 @@ Feature: Upload files
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And I log in as "admin"
And I press "Customise this page"
And I turn editing mode on
And I add the "Private files" block if not present
When I follow "Manage private files..."
And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager

View file

@ -103,7 +103,7 @@ Feature: Managers can create and manage tag collections
| Searchable | 0 |
And I press "Create"
And "Yes" "text" should not exist in the "//table[contains(@class,'tag-collections-table')]//tr[contains(.,'Hiddencoll')]" "xpath_element"
And I press "Blocks editing on"
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"

View file

@ -31,7 +31,7 @@ Feature: Users can edit tags to add description or rename
| moodle/user:viewdetails | Allow |
And I log out
When I log in as "editor1"
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"
@ -56,7 +56,7 @@ Feature: Users can edit tags to add description or rename
@javascript
Scenario: Manager can change tag description, related tags and rename the tag from tag view page
When I log in as "manager1"
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"
@ -89,7 +89,7 @@ Feature: Users can edit tags to add description or rename
Scenario: Renaming the tag from tag view page
When I log in as "manager1"
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 "Tags" "link" in the "Navigation" "block"

View file

@ -24,7 +24,7 @@ Feature: Users can flag tags and manager can reset flags
| moodle/user:viewdetails | Allow |
And I log out
And I log in as "user2"
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"
@ -46,7 +46,7 @@ Feature: Users can flag tags and manager can reset flags
And I should see "The person responsible will be notified"
And I log out
And I log in as "user3"
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"

View file

@ -22,7 +22,7 @@ Feature: Browsing tagged items
Scenario: Browse tag index with javascript disabled
When 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 "Tags" "link" in the "Navigation" "block"
@ -69,7 +69,7 @@ Feature: Browsing tagged items
@javascript
Scenario: Browse tag index with javascript enabled
When 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"

View file

@ -32,6 +32,9 @@ defined('MOODLE_INTERNAL') || die;
class core_renderer extends \core_renderer {
public function edit_button(moodle_url $url) {
if ($this->page->theme->haseditswitch) {
return;
}
$url->param('sesskey', sesskey());
if ($this->page->user_is_editing()) {
$url->param('edit', 'off');

Some files were not shown because too many files have changed in this diff Show more