From b983003e2e224f5c770ad5cec59537de7732ea6b Mon Sep 17 00:00:00 2001 From: Mathew May Date: Fri, 27 Aug 2021 16:04:01 +0800 Subject: [PATCH] MDL-70197 navigation: Remove old navigation elements and migrate behat --- admin/search.php | 2 +- .../behat/tests/behat/data_generators.feature | 1 + .../tests/behat/manage_defaults.feature | 26 +-- .../tests/behat/course_competencies.feature | 2 +- admin/tool/lp/tests/behat/plan_crud.feature | 2 +- .../tests/behat/course_report_monitor.feature | 3 +- admin/tool/monitor/tests/behat/rule.feature | 18 +- .../monitor/tests/behat/subscription.feature | 3 +- admin/tool/policy/tests/behat/consent.feature | 2 +- .../tests/behat/basic_functionality.feature | 3 +- .../tests/behat/upload_users.feature | 14 +- .../availability_completion_previous.feature | 4 + badges/tests/behat/award_badge.feature | 2 +- .../tests/behat/criteria_competency.feature | 17 +- ...lock_completionstatus_manual_other.feature | 9 +- .../block_course_summary_frontpage.feature | 2 +- blocks/tests/behat/behat_blocks.php | 8 +- .../configure_block_throughout_site.feature | 2 +- blocks/tests/behat/manage_blocks.feature | 3 +- completion/tests/behat/behat_completion.php | 3 +- .../tests/behat/admin_upload_content.feature | 2 +- .../behat/teacher_replace_content.feature | 2 + .../tests/behat/access_permissions.feature | 3 +- contentbank/tests/behat/edit_content.feature | 2 +- .../tests/behat/course_courseindex.feature | 14 +- .../behat/courseindex_completion.feature | 7 - .../behat/courseindex_keyboardnav.feature | 1 - course/tests/behat/behat_course.php | 2 +- .../behat/course_collapse_sections.feature | 4 +- course/tests/behat/course_controls.feature | 10 +- course/tests/behat/course_creation.feature | 2 +- ...ourse_download_content_permissions.feature | 21 ++- files/tests/behat/course_files.feature | 6 +- .../form/guide/tests/behat/edit_guide.feature | 7 +- .../rubric/tests/behat/edit_rubric.feature | 2 + .../tests/behat/grade_calculation.feature | 1 + .../tests/behat/negative_points.feature | 3 + grade/grading/tests/behat/behat_grading.php | 6 +- grade/tests/behat/behat_grade.php | 2 +- .../tests/behat/grade_letter_boundary.feature | 3 +- .../grade_letter_boundary_20160518.feature | 3 +- index.php | 7 + lib/amd/build/addblockmodal.min.js | 2 +- lib/amd/build/addblockmodal.min.js.map | 2 +- lib/amd/src/addblockmodal.js | 10 +- lib/blocklib.php | 19 ++- lib/classes/navigation/views/secondary.php | 4 + lib/enrollib.php | 1 + lib/navigationlib.php | 39 ++--- lib/templates/add_block_button.mustache | 41 +++++ lib/templates/full_header.mustache | 12 +- lib/templates/moremenu_children.mustache | 4 +- lib/templates/settings_link_page.mustache | 5 - lib/tests/behat/alpha_chooser.feature | 6 +- lib/tests/behat/behat_deprecated.php | 14 ++ lib/tests/behat/behat_navigation.php | 100 +++++++++-- .../editpdf/tests/behat/annotate_pdf.feature | 2 - mod/assign/tests/behat/comment_inline.feature | 2 - mod/assign/tests/behat/display_grade.feature | 4 - mod/assign/tests/behat/grading_status.feature | 2 - mod/assign/tests/behat/quickgrading.feature | 3 - mod/assign/tests/behat/rescale_grades.feature | 2 - .../tests/behat/steps_blind_marking.feature | 10 -- .../tests/behat/submission_comments.feature | 2 - mod/assign/view.php | 7 + mod/book/tests/behat/log_entries.feature | 23 +-- ...activity_info_completion_automatic.feature | 3 +- .../activity_info_completion_manual.feature | 6 +- .../tests/behat/multiple_options.feature | 1 - mod/feedback/tests/behat/anonymous.feature | 12 +- .../tests/behat/coursemapping.feature | 3 +- mod/feedback/tests/behat/groups.feature | 18 +- .../tests/behat/non_anonymous.feature | 7 +- mod/forum/view.php | 5 + .../tests/behat/import_entries.feature | 4 +- .../tests/behat/grading_attempts.feature | 2 +- .../tests/behat/behat_mod_lesson_behat.php | 4 +- .../grading/tests/behat/grading.feature | 2 +- .../report/overview/tests/behat/basic.feature | 4 +- .../overview/tests/behat/regrading.feature | 4 +- .../behat/attempt_redo_questions.feature | 1 + ...completion_condition_attempts_used.feature | 3 +- ...pletion_condition_minimum_attempts.feature | 3 +- ...completion_condition_passing_grade.feature | 3 +- mod/quiz/tests/behat/editing_add.feature | 2 +- .../editing_add_from_question_bank.feature | 2 +- .../behat/quiz_activity_completion.feature | 3 +- .../settings_form_fields_disableif.feature | 3 - mod/quiz/view.php | 5 + my/index.php | 4 + my/indexsys.php | 4 + my/lib.php | 32 ++++ .../tests/behat/question_comment.feature | 10 +- .../behat/question_comment_column.feature | 4 +- .../behat/delete_question_column.feature | 4 +- .../tests/behat/export_to_xml_action.feature | 8 +- .../tests/behat/preview_question.feature | 2 +- .../behat/preview_question_action.feature | 14 +- .../tests/behat/tag_question_action.feature | 12 +- .../behat/view_view_creator_column.feature | 4 +- .../behat/view_question_name_column.feature | 4 +- .../behat/view_question_name_column.feature | 4 +- .../behat/view_question_type_column.feature | 4 +- question/renderer.php | 2 +- question/tests/behat/behat_question.php | 4 - question/tests/behat/delete_questions.feature | 4 +- .../tests/behat/duplicate_questions.feature | 2 +- .../tests/behat/edit_question_tags.feature | 2 +- question/tests/behat/edit_questions.feature | 2 +- .../edit_questions_standard_tags.feature | 2 +- .../behat/filter_questions_by_tag.feature | 2 +- .../tests/behat/question_categories.feature | 4 +- .../question_categories_idnumber.feature | 8 +- question/tests/behat/select_questions.feature | 2 +- question/tests/behat/sort_questions.feature | 2 +- .../tests/behat/backup_and_restore.feature | 2 +- .../tests/behat/breakdown_by_activity.feature | 5 +- .../behat/course_report_competency.feature | 3 +- .../tests/behat/completion_report.feature | 3 +- .../behat/course_report_completion.feature | 3 +- .../log/tests/behat/course_report_log.feature | 3 +- report/log/tests/behat/user_log.feature | 5 +- .../tests/behat/course_report_loglive.feature | 3 +- .../tests/behat/loglive_report.feature | 4 + .../tests/behat/course_report_outline.feature | 3 +- report/outline/tests/behat/filter.feature | 6 +- report/outline/tests/behat/outline.feature | 21 ++- report/outline/tests/behat/user.feature | 4 +- .../behat/course_report_participation.feature | 3 +- .../tests/behat/filter_participation.feature | 9 +- .../tests/behat/message_participants.feature | 9 +- .../behat/activity_completion_report.feature | 9 +- .../activity_completion_report_filter.feature | 3 +- .../behat/course_report_progress.feature | 6 +- theme/boost/layout/columns2.php | 52 +++--- theme/boost/layout/drawers.php | 57 +++---- theme/boost/scss/moodle/buttons.scss | 2 +- theme/boost/scss/moodle/course.scss | 13 +- theme/boost/scss/moodle/variables.scss | 5 + theme/boost/style/moodle.css | 15 +- theme/boost/templates/columns2.mustache | 3 +- theme/boost/templates/drawers.mustache | 3 +- theme/boost/templates/nav-drawer.mustache | 9 - theme/boost/templates/navbar.mustache | 8 +- .../behat/regionmainsettingsmenu.feature | 13 -- theme/classic/style/moodle.css | 15 +- .../behat_theme_classic_behat_completion.php | 40 +++++ .../behat_theme_classic_behat_grading.php | 42 +++++ .../behat_theme_classic_behat_navigation.php | 161 +++++++++++++++++- .../behat_theme_classic_behat_question.php | 49 ++++++ 150 files changed, 944 insertions(+), 445 deletions(-) create mode 100644 lib/templates/add_block_button.mustache delete mode 100644 theme/boost/templates/nav-drawer.mustache create mode 100644 theme/classic/tests/behat/behat_theme_classic_behat_completion.php create mode 100644 theme/classic/tests/behat/behat_theme_classic_behat_grading.php create mode 100644 theme/classic/tests/behat/behat_theme_classic_behat_question.php diff --git a/admin/search.php b/admin/search.php index 1bcf3c38c17..e54fb30fb63 100644 --- a/admin/search.php +++ b/admin/search.php @@ -59,7 +59,7 @@ if ($data = data_submitted() and confirm_sesskey() and isset($data->action) and } } -$PAGE->has_secondary_navigation_setter(false); +$PAGE->set_primary_active_tab('siteadminnode'); // and finally, if we get here, then there are matching settings and we have to print a form // to modify them diff --git a/admin/tool/behat/tests/behat/data_generators.feature b/admin/tool/behat/tests/behat/data_generators.feature index ea5d19e743b..a54c5466742 100644 --- a/admin/tool/behat/tests/behat/data_generators.feature +++ b/admin/tool/behat/tests/behat/data_generators.feature @@ -385,6 +385,7 @@ Feature: Set up contextual data for tests | enableoutcomes | 1 | When I log in as "admin" And I am on "Course 1" course homepage + And I navigate to "Grades" in current page administration And I follow "Outcomes" Then I should see "Grade outcome 1" in the "#addoutcomes" "css_element" And I should see "Grade outcome 2" in the "#removeoutcomes" "css_element" diff --git a/admin/tool/dataprivacy/tests/behat/manage_defaults.feature b/admin/tool/dataprivacy/tests/behat/manage_defaults.feature index 0bb5e755965..6f884e3c51d 100644 --- a/admin/tool/dataprivacy/tests/behat/manage_defaults.feature +++ b/admin/tool/dataprivacy/tests/behat/manage_defaults.feature @@ -49,7 +49,7 @@ Feature: Manage data registry defaults And the field "categoryid" matches value "Not set (use the default value)" And the field "purposeid" matches value "Not set (use the default value)" And I should see "3 years" - And I click on "Courses" "link" + And I click on "Courses" "link" in the ".data-registry" "css_element" And I wait until the page is ready And I click on "Physics 101" "link" And I wait until the page is ready @@ -80,7 +80,7 @@ Feature: Manage data registry defaults Then the field "categoryid" matches value "Category 2" And the field "purposeid" matches value "Purpose 2" And I should see "5 years" - And I click on "Courses" "link" + And I click on "Courses" "link" in the ".data-registry" "css_element" And I wait until the page is ready # Physics 101 is also a category, so it will get the category default. And I click on "Physics 101" "link" @@ -102,7 +102,7 @@ Feature: Manage data registry defaults Then the field "categoryid" matches value "Category 2" And the field "purposeid" matches value "Purpose 2" And I should see "5 years" - And I click on "Courses" "link" + And I click on "Courses" "link" in the ".data-registry" "css_element" And I wait until the page is ready # Physics 101 is also a category, so it will get the category default. And I click on "Physics 101" "link" @@ -138,7 +138,7 @@ Feature: Manage data registry defaults Given I set the category and purpose for the course "Physics 101" to "Category 2" and "Purpose 2" And I navigate to "Users > Privacy and policies > Data registry" in site administration And I click on "Set defaults" "link" - And I click on "Courses" "link" + And I click on "Courses" "link" in the "#region-main" "css_element" And I should see "Inherit" And I should not see "Add a new module default" And I press "Edit" @@ -150,7 +150,7 @@ Feature: Manage data registry defaults And I navigate to "Users > Privacy and policies > Data registry" in site administration And I click on "Science and technology" "link" And I wait until the page is ready - And I click on "Courses" "link" + And I click on "Courses" "link" in the ".data-registry" "css_element" And I wait until the page is ready And I click on "Physics 101" "link" And I wait until the page is ready @@ -168,7 +168,7 @@ Feature: Manage data registry defaults Given I set the category and purpose for the course "Physics 101" to "Category 2" and "Purpose 2" And I navigate to "Users > Privacy and policies > Data registry" in site administration And I click on "Set defaults" "link" - And I click on "Courses" "link" + And I click on "Courses" "link" in the "#region-main" "css_element" And I should see "Inherit" And I should not see "Add a new module default" And I press "Edit" @@ -181,7 +181,7 @@ Feature: Manage data registry defaults And I navigate to "Users > Privacy and policies > Data registry" in site administration And I click on "Science and technology" "link" And I wait until the page is ready - And I click on "Courses" "link" + And I click on "Courses" "link" in the ".data-registry" "css_element" And I wait until the page is ready And I click on "Physics 101" "link" And I wait until the page is ready @@ -211,7 +211,7 @@ Feature: Manage data registry defaults And I navigate to "Users > Privacy and policies > Data registry" in site administration And I click on "Science and technology" "link" And I wait until the page is ready - And I click on "Courses" "link" + And I click on "Courses" "link" in the ".data-registry" "css_element" And I wait until the page is ready And I click on "Physics 101" "link" And I wait until the page is ready @@ -240,7 +240,7 @@ Feature: Manage data registry defaults And I navigate to "Users > Privacy and policies > Data registry" in site administration And I click on "Science and technology" "link" And I wait until the page is ready - And I click on "Courses" "link" + And I click on "Courses" "link" in the ".data-registry" "css_element" And I wait until the page is ready And I click on "Physics 101" "link" And I wait until the page is ready @@ -273,7 +273,7 @@ Feature: Manage data registry defaults And I navigate to "Users > Privacy and policies > Data registry" in site administration And I click on "Science and technology" "link" And I wait until the page is ready - And I click on "Courses" "link" + And I click on "Courses" "link" in the ".data-registry" "css_element" And I wait until the page is ready And I click on "Physics 101" "link" And I wait until the page is ready @@ -303,7 +303,7 @@ Feature: Manage data registry defaults And I navigate to "Users > Privacy and policies > Data registry" in site administration And I click on "Science and technology" "link" And I wait until the page is ready - And I click on "Courses" "link" + And I click on "Courses" "link" in the ".data-registry" "css_element" And I wait until the page is ready And I click on "Physics 101" "link" And I wait until the page is ready @@ -331,7 +331,7 @@ Feature: Manage data registry defaults And I navigate to "Users > Privacy and policies > Data registry" in site administration And I click on "Science and technology" "link" And I wait until the page is ready - And I click on "Courses" "link" + And I click on "Courses" "link" in the ".data-registry" "css_element" And I wait until the page is ready And I click on "Physics 101" "link" And I wait until the page is ready @@ -360,7 +360,7 @@ Feature: Manage data registry defaults And I navigate to "Users > Privacy and policies > Data registry" in site administration And I click on "Science and technology" "link" And I wait until the page is ready - And I click on "Courses" "link" + And I click on "Courses" "link" in the ".data-registry" "css_element" And I wait until the page is ready And I click on "Physics 101" "link" And I wait until the page is ready diff --git a/admin/tool/lp/tests/behat/course_competencies.feature b/admin/tool/lp/tests/behat/course_competencies.feature index 7d901c7a0ad..11dc3e4aa9c 100644 --- a/admin/tool/lp/tests/behat/course_competencies.feature +++ b/admin/tool/lp/tests/behat/course_competencies.feature @@ -25,7 +25,7 @@ Feature: See the competencies for an activity on the course competencies page. | page | PageName1 | PageDesc1 | C1 | PAGE1 | 1 | 1 | | page | PageName2 | PageDesc2 | C1 | PAGE2 | 1 | 1 | And I am on the "Course 1" course page logged in as admin - And I follow "Competencies" + And I navigate to "Competencies" in current page administration And I press "Add competencies to course" And "Competency picker" "dialogue" should be visible And I select "Test-Comp1" of the competency tree diff --git a/admin/tool/lp/tests/behat/plan_crud.feature b/admin/tool/lp/tests/behat/plan_crud.feature index c5d579b9d2d..4e7554e5ea2 100644 --- a/admin/tool/lp/tests/behat/plan_crud.feature +++ b/admin/tool/lp/tests/behat/plan_crud.feature @@ -152,7 +152,7 @@ Feature: Manage plearning plan And I create a course with: | Course full name | New course fullname | | Course short name | New course shortname | - And I follow "Competencies" + And I navigate to "Competencies" in current page administration And I press "Add competencies to course" And "Competency picker" "dialogue" should be visible And I select "comp1" of the competency tree diff --git a/admin/tool/monitor/tests/behat/course_report_monitor.feature b/admin/tool/monitor/tests/behat/course_report_monitor.feature index ad5ee2c8018..033b9ce68a7 100644 --- a/admin/tool/monitor/tests/behat/course_report_monitor.feature +++ b/admin/tool/monitor/tests/behat/course_report_monitor.feature @@ -22,7 +22,8 @@ Feature: In a course administration page, navigate through report page, test for And I navigate to "Reports > Event monitoring rules" in site administration And I click on "Enable" "link" And I am on "Course 1" course homepage - When I navigate to "Reports > Event monitoring rules" in current page administration + When I navigate to "Reports" in current page administration + And I select "Event monitoring rules" from the "Report type" singleselect Then "Report" "field" should exist And the "Report" select box should contain "Event monitoring rules" And the field "Report" matches value "Event monitoring rules" diff --git a/admin/tool/monitor/tests/behat/rule.feature b/admin/tool/monitor/tests/behat/rule.feature index 822cf9672f4..221ae54df5e 100644 --- a/admin/tool/monitor/tests/behat/rule.feature +++ b/admin/tool/monitor/tests/behat/rule.feature @@ -18,7 +18,8 @@ Feature: tool_monitor_rule And I navigate to "Reports > Event monitoring rules" in site administration And I click on "Enable" "link" And I am on "Course 1" course homepage - And I navigate to "Reports > Event monitoring rules" in current page administration + And I navigate to "Reports" in current page administration + And I select "Event monitoring rules" from the "Report type" singleselect And I press "Add a new rule" And I set the following fields to these values: | name | New rule course level | @@ -45,7 +46,8 @@ Feature: tool_monitor_rule Scenario: Add a rule on course level Given I log in as "teacher1" And I am on "Course 1" course homepage - And I navigate to "Reports > Event monitoring rules" in current page administration + And I navigate to "Reports" in current page administration + And I select "Event monitoring rules" from the "Report type" singleselect When I press "Add a new rule" And I set the following fields to these values: | name | New rule | @@ -65,7 +67,8 @@ Feature: tool_monitor_rule Scenario: Delete a rule on course level Given I log in as "teacher1" And I am on "Course 1" course homepage - And I navigate to "Reports > Event monitoring rules" in current page administration + And I navigate to "Reports" in current page administration + And I select "Event monitoring rules" from the "Report type" singleselect When I click on "Delete rule" "link" Then I should see "Are you sure you want to delete the rule \"New rule course level\"?" And I press "Continue" @@ -75,7 +78,8 @@ Feature: tool_monitor_rule Scenario: Edit a rule on course level Given I log in as "teacher1" And I am on "Course 1" course homepage - And I navigate to "Reports > Event monitoring rules" in current page administration + And I navigate to "Reports" in current page administration + And I select "Event monitoring rules" from the "Report type" singleselect When I click on "Edit rule" "link" And I set the following fields to these values: | name | New rule quiz | @@ -94,7 +98,8 @@ Feature: tool_monitor_rule Scenario: Duplicate a rule on course level Given I log in as "teacher1" And I am on "Course 1" course homepage - And I navigate to "Reports > Event monitoring rules" in current page administration + And I navigate to "Reports" in current page administration + And I select "Event monitoring rules" from the "Report type" singleselect When I click on "Duplicate rule" "link" in the "New rule course level" "table_row" Then I should see "Rule successfully duplicated" And "#toolmonitorrules_r1" "css_element" should appear before "#toolmonitorrules_r2" "css_element" @@ -153,7 +158,8 @@ Feature: tool_monitor_rule Scenario: Duplicate a rule on site level Given I log in as "teacher1" And I am on "Course 1" course homepage - And I navigate to "Reports > Event monitoring rules" in current page administration + And I navigate to "Reports" in current page administration + And I select "Event monitoring rules" from the "Report type" singleselect When I click on "Duplicate rule" "link" in the "New rule site level" "table_row" Then I should see "Rule successfully duplicated" And "#toolmonitorrules_r2" "css_element" should appear after "#toolmonitorrules_r1" "css_element" diff --git a/admin/tool/monitor/tests/behat/subscription.feature b/admin/tool/monitor/tests/behat/subscription.feature index c91d45a6951..3b881b4b625 100644 --- a/admin/tool/monitor/tests/behat/subscription.feature +++ b/admin/tool/monitor/tests/behat/subscription.feature @@ -23,7 +23,8 @@ Feature: tool_monitor_subscriptions And I navigate to "Reports > Event monitoring rules" in site administration And I click on "Enable" "link" And I am on "Course 1" course homepage - And I navigate to "Reports > Event monitoring rules" in current page administration + And I navigate to "Reports" in current page administration + And I select "Event monitoring rules" from the "Report type" singleselect And I press "Add a new rule" And I set the following fields to these values: | name | New rule course level | diff --git a/admin/tool/policy/tests/behat/consent.feature b/admin/tool/policy/tests/behat/consent.feature index 2cd4e5b773d..edc4dcc0c88 100644 --- a/admin/tool/policy/tests/behat/consent.feature +++ b/admin/tool/policy/tests/behat/consent.feature @@ -465,7 +465,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign When I press "Log in as a guest" Then I should see "If you continue browsing this website, you agree to our policies" # Confirm when navigating, the pop-up policies are displayed. - When I follow "Home" + When I am on the "My courses" page Then I should see "If you continue browsing this website, you agree to our policies" And I should see "This site policy" And I should see "This guests policy" diff --git a/admin/tool/recyclebin/tests/behat/basic_functionality.feature b/admin/tool/recyclebin/tests/behat/basic_functionality.feature index ce29515267d..09c921f580f 100644 --- a/admin/tool/recyclebin/tests/behat/basic_functionality.feature +++ b/admin/tool/recyclebin/tests/behat/basic_functionality.feature @@ -124,8 +124,7 @@ Feature: Basic recycle bin functionality Scenario: Show recycle bin on category action menu Given I log in as "admin" And I navigate to "Courses > Manage courses and categories" in site administration - And I click on "Actions menu" "link" - And I click on "Recycle bin" "link" + And I navigate to "Recycle bin" in current page administration Then I should see "There are no items in the recycle bin." @javascript diff --git a/admin/tool/uploaduser/tests/behat/upload_users.feature b/admin/tool/uploaduser/tests/behat/upload_users.feature index 0d1cef6e580..c6cdbce7cc9 100644 --- a/admin/tool/uploaduser/tests/behat/upload_users.feature +++ b/admin/tool/uploaduser/tests/behat/upload_users.feature @@ -129,16 +129,14 @@ Feature: Upload users And I press "Upload users" And I should see "Users created: 4" And I press "Continue" - And I log out # Boost check. - And I log in as "jonest" - And I am on "Maths" course homepage - And "Calendar" "link" should be visible - And I log out + And I navigate to "Users > Accounts > Browse list of users" in site administration + And I click on ".icon[title=Edit]" "css_element" in the "jonest@example.com" "table_row" + And I should see "Boost" # Classic check. - And I log in as "reznor" - And I am on "Maths" course homepage - And "Calendar" "link" should not be visible + And I navigate to "Users > Accounts > Browse list of users" in site administration + And I click on ".icon[title=Edit]" "css_element" in the "reznor@example.com" "table_row" + And I should see "Classic" @javascript Scenario: Upload users setting their user theme when allowuserthemes is false diff --git a/availability/condition/completion/tests/behat/availability_completion_previous.feature b/availability/condition/completion/tests/behat/availability_completion_previous.feature index ae21266a7c3..bf3848f319b 100644 --- a/availability/condition/completion/tests/behat/availability_completion_previous.feature +++ b/availability/condition/completion/tests/behat/availability_completion_previous.feature @@ -42,6 +42,7 @@ Feature: Confirm that availability_completion works with previous activity setti # Remove Page 2 and check Page3 depends now on Page1. When I turn editing mode on + And I change window size to "large" And I delete "Page2" activity And I turn editing mode off Then I should see "Not available unless: The activity Page1 is marked complete" in the "region-main" "region" @@ -92,6 +93,7 @@ Feature: Confirm that availability_completion works with previous activity setti # Test if I disable completion tracking on Page2 section 5 depends on Page2. When I turn editing mode on + And I change window size to "large" When I open "Page2" actions menu And I click on "Edit settings" "link" in the "Page2" activity And I set the following fields to these values: @@ -120,6 +122,7 @@ Feature: Confirm that availability_completion works with previous activity setti # Remove Page 2 and check Section 4 depends now on Page1. When I turn editing mode on + And I change window size to "large" And I delete "Page2" activity And I turn editing mode off Then I should see "Not available unless: The activity Page1 is marked complete" in the "region-main" "region" @@ -160,6 +163,7 @@ Feature: Confirm that availability_completion works with previous activity setti Scenario: Test previous activities on empty sections Given I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on + And I change window size to "large" # Set section 2 restriction to Previous Activity with completion. When I edit the section "2" diff --git a/badges/tests/behat/award_badge.feature b/badges/tests/behat/award_badge.feature index e1c25e83744..6394a5f825d 100644 --- a/badges/tests/behat/award_badge.feature +++ b/badges/tests/behat/award_badge.feature @@ -88,7 +88,7 @@ Feature: Award badges # Teacher 1 should have access to manage/create badges in the Badges navigation section. When I log in as "teacher1" And I am on "Course 1" course homepage - And I follow "Badges" + And I navigate to "Badges > Manage badges" in current page administration Then I should see "Course Badge 1" And I should see "Course Badge 2" And I should see "Manage badges" diff --git a/badges/tests/behat/criteria_competency.feature b/badges/tests/behat/criteria_competency.feature index 9f7ca5ae2c8..5e588e08bf6 100644 --- a/badges/tests/behat/criteria_competency.feature +++ b/badges/tests/behat/criteria_competency.feature @@ -27,8 +27,7 @@ Feature: Award badges based on competency completion Scenario: Award badge for completing a competency in a course # Add a competency to the course When I am on "Course 1" course homepage - And I follow "Competencies" - And I press "Add competencies to course" + And I navigate to "Competencies > Add competencies to course" in current page administration And "Competency picker" "dialogue" should be visible And I select "comp1" of the competency tree And I click on "Add" "button" in the "Competency picker" "dialogue" @@ -58,7 +57,7 @@ Feature: Award badges based on competency completion And I press "Continue" # Rate the competency in the course And I am on "Course 1" course homepage - And I follow "Competencies" + And I navigate to "Competencies" in current page administration And I click on "comp1" "link" in the "[data-region='coursecompetencies']" "css_element" And I press "Rate" And I set the following fields to these values: @@ -75,8 +74,7 @@ Feature: Award badges based on competency completion Scenario: Award badge for completing a competency in the site # Add a competency to the course When I am on "Course 1" course homepage - And I follow "Competencies" - And I press "Add competencies to course" + And I navigate to "Competencies > Add competencies to course" in current page administration And "Competency picker" "dialogue" should be visible And I select "comp1" of the competency tree And I click on "Add" "button" in the "Competency picker" "dialogue" @@ -110,7 +108,7 @@ Feature: Award badges based on competency completion And I press "Continue" # Rate the competency in the course And I am on "Course 1" course homepage - And I follow "Competencies" + And I navigate to "Competencies" in current page administration And I click on "comp1" "link" in the "[data-region='coursecompetencies']" "css_element" And I press "Rate" And I set the following fields to these values: @@ -127,8 +125,7 @@ Feature: Award badges based on competency completion Scenario: Award badge for completing all competencies in the site # Add a competency to the course When I am on "Course 1" course homepage - And I follow "Competencies" - And I press "Add competencies to course" + And I navigate to "Competencies > Add competencies to course" in current page administration And "Competency picker" "dialogue" should be visible And I select "comp1" of the competency tree And I click on "Add" "button" in the "Competency picker" "dialogue" @@ -164,7 +161,7 @@ Feature: Award badges based on competency completion And I press "Continue" # Rate the competency in the course And I am on "Course 1" course homepage - And I follow "Competencies" + And I navigate to "Competencies" in current page administration And I click on "comp1" "link" in the "[data-region='coursecompetencies']" "css_element" And I press "Rate" And I set the following fields to these values: @@ -180,7 +177,7 @@ Feature: Award badges based on competency completion # Rate the other competency. And I log in as "admin" And I am on "Course 1" course homepage - And I follow "Competencies" + And I navigate to "Competencies" in current page administration And I click on "comp2" "link" in the "[data-region='coursecompetencies']" "css_element" And I press "Rate" And I set the following fields to these values: diff --git a/blocks/completionstatus/tests/behat/block_completionstatus_manual_other.feature b/blocks/completionstatus/tests/behat/block_completionstatus_manual_other.feature index ebe242faa8c..8be0a3f92ce 100644 --- a/blocks/completionstatus/tests/behat/block_completionstatus_manual_other.feature +++ b/blocks/completionstatus/tests/behat/block_completionstatus_manual_other.feature @@ -36,7 +36,8 @@ Feature: Enable Block Completion in a course using manual completion by others And I log out And I log in as "teacher1" And I am on "Course 1" course homepage - And I navigate to "Reports > Course completion" in current page administration + And I navigate to "Reports" in current page administration + And I select "Course completion" from the "Report type" singleselect And I follow "Click to mark user complete" # Running completion task just after clicking sometimes fail, as record # should be created before the task runs. @@ -71,7 +72,8 @@ Feature: Enable Block Completion in a course using manual completion by others And I log out And I log in as "teacher1" And I am on "Course 1" course homepage - And I navigate to "Reports > Course completion" in current page administration + And I navigate to "Reports" in current page administration + And I select "Course completion" from the "Report type" singleselect And I follow "Click to mark user complete" And I log out And I log in as "student1" @@ -85,7 +87,8 @@ Feature: Enable Block Completion in a course using manual completion by others And I log out And I log in as "teacher2" And I am on "Course 1" course homepage - And I navigate to "Reports > Course completion" in current page administration + And I navigate to "Reports" in current page administration + And I select "Course completion" from the "Report type" singleselect And I follow "Click to mark user complete" # Running completion task just after clicking sometimes fail, as record # should be created before the task runs. diff --git a/blocks/course_summary/tests/behat/block_course_summary_frontpage.feature b/blocks/course_summary/tests/behat/block_course_summary_frontpage.feature index ac91d6de2ea..3b7aca2a814 100644 --- a/blocks/course_summary/tests/behat/block_course_summary_frontpage.feature +++ b/blocks/course_summary/tests/behat/block_course_summary_frontpage.feature @@ -9,7 +9,7 @@ Feature: Course summary block used on the frontpage And I am on site homepage And I turn editing mode on And I add the "Course/site summary" block - And I navigate to "Edit settings" in current page administration + And I navigate to "Front page settings" in site administration And I set the following fields to these values: | summary | Proved the summary block works! | And I press "Save changes" diff --git a/blocks/tests/behat/behat_blocks.php b/blocks/tests/behat/behat_blocks.php index 94f9b33e28e..d2f22b192e3 100644 --- a/blocks/tests/behat/behat_blocks.php +++ b/blocks/tests/behat/behat_blocks.php @@ -47,7 +47,7 @@ class behat_blocks extends behat_base { */ public function i_add_the_block($blockname) { $addblock = get_string('addblock'); - $this->execute('behat_navigation::i_select_from_flat_navigation_drawer', $addblock); + $this->execute('behat_general::i_click_on_in_the', [$addblock, 'link_exact', '.block_fake', 'css_element']); if (!$this->running_javascript()) { $this->execute('behat_general::i_click_on_in_the', [$blockname, 'link_exact', '#region-main', 'css_element']); @@ -121,7 +121,8 @@ class behat_blocks extends behat_base { */ public function the_add_block_selector_should_contain_block($blockname) { $addblock = get_string('addblock'); - $this->execute('behat_navigation::i_select_from_flat_navigation_drawer', $addblock); + $this->execute('behat_general::i_click_on', [$addblock, 'link_exact']); + $cancelstr = get_string('cancel'); if (!$this->running_javascript()) { @@ -141,7 +142,8 @@ class behat_blocks extends behat_base { */ public function the_add_block_selector_should_not_contain_block($blockname) { $addblock = get_string('addblock'); - $this->execute('behat_navigation::i_select_from_flat_navigation_drawer', $addblock); + $this->execute('behat_general::i_click_on', [$addblock, 'link_exact']); + $cancelstr = get_string('cancel'); if (!$this->running_javascript()) { diff --git a/blocks/tests/behat/configure_block_throughout_site.feature b/blocks/tests/behat/configure_block_throughout_site.feature index f6cfc09be4a..fd9c4d91027 100644 --- a/blocks/tests/behat/configure_block_throughout_site.feature +++ b/blocks/tests/behat/configure_block_throughout_site.feature @@ -46,7 +46,7 @@ Feature: Add and configure blocks throughout the site And I press "Save changes" And I am on "Course 1" course homepage # The first block matching the pattern should be top-left block - And I should see "Comments" in the "//*[@id='region-pre' or @id='block-region-side-pre']/descendant::*[contains(concat(' ', normalize-space(@class), ' '), ' block ')]" "xpath_element" + And I should see "Comments" in the "//*[@id='region-pre' or @id='block-region-side-pre']/descendant::*[contains(concat(' ', normalize-space(@class), ' '), ' block_comments ')]" "xpath_element" Scenario: Blocks on the dashboard page can have roles assigned to them Given I log in as "manager1" diff --git a/blocks/tests/behat/manage_blocks.feature b/blocks/tests/behat/manage_blocks.feature index 0a2e25dd657..485a3b91068 100644 --- a/blocks/tests/behat/manage_blocks.feature +++ b/blocks/tests/behat/manage_blocks.feature @@ -58,7 +58,6 @@ Feature: Block appearances And I set the following fields to these values: | Visible | No | And I press "Save changes" - And I click on "Topic 1" "link" - And I turn editing mode off + And I am on "Course 1" course homepage with editing mode off And I click on "Test book name" "link" in the "region-main" "region" Then I should not see "Comments" diff --git a/completion/tests/behat/behat_completion.php b/completion/tests/behat/behat_completion.php index ba99eed53a4..cecc1d89089 100644 --- a/completion/tests/behat/behat_completion.php +++ b/completion/tests/behat/behat_completion.php @@ -87,7 +87,8 @@ class behat_completion extends behat_base { $reportsnode = get_string('reports'); $this->execute("behat_navigation::i_navigate_to_in_current_page_administration", - $reportsnode . ' > ' . $completionnode); + $reportsnode); + $this->execute("behat_forms::i_select_from_the_singleselect", [$completionnode, "Report type"]); } /** diff --git a/contentbank/contenttype/h5p/tests/behat/admin_upload_content.feature b/contentbank/contenttype/h5p/tests/behat/admin_upload_content.feature index dbc596a9a15..917ecb1e098 100644 --- a/contentbank/contenttype/h5p/tests/behat/admin_upload_content.feature +++ b/contentbank/contenttype/h5p/tests/behat/admin_upload_content.feature @@ -50,7 +50,7 @@ Feature: H5P file upload to content bank for admins And I navigate to "Plugins > Content bank > Manage content types" in site administration And I click on "Disable" "icon" in the "H5P" "table_row" And I wait until the page is ready - When I click on "Content bank" "link" + When I navigate to "Plugins > Content bank" in site administration Then I should not see "filltheblanks.h5p" Scenario: Contents in a context are not available from other contexts diff --git a/contentbank/contenttype/h5p/tests/behat/teacher_replace_content.feature b/contentbank/contenttype/h5p/tests/behat/teacher_replace_content.feature index d994b6738d7..014b032aa3f 100644 --- a/contentbank/contenttype/h5p/tests/behat/teacher_replace_content.feature +++ b/contentbank/contenttype/h5p/tests/behat/teacher_replace_content.feature @@ -35,6 +35,8 @@ Feature: Replace H5P file from an existing content requires special capabilities And I click on "Content bank" "link" # Force the content deploy And I click on "admincontent" "link" + And I am on "Course 1" course homepage + And I expand "Site pages" node And I click on "Content bank" "link" Scenario: Teacher can replace its own H5P files diff --git a/contentbank/tests/behat/access_permissions.feature b/contentbank/tests/behat/access_permissions.feature index 1b7ad49610f..e1d17c8ce67 100644 --- a/contentbank/tests/behat/access_permissions.feature +++ b/contentbank/tests/behat/access_permissions.feature @@ -17,7 +17,8 @@ Feature: Access permission to content Bank Scenario: Admins access content bank Given I log in as "admin" - Then "Content bank" "link" should exist + And I am on "Course 1" course homepage + Then "Content bank" "link" should exist in current page administration Scenario: Editing teachers can access content bank at course level Given I log in as "teacher1" diff --git a/contentbank/tests/behat/edit_content.feature b/contentbank/tests/behat/edit_content.feature index 133b84937e3..85eaaa2e934 100644 --- a/contentbank/tests/behat/edit_content.feature +++ b/contentbank/tests/behat/edit_content.feature @@ -195,6 +195,6 @@ Feature: Content bank use editor feature And I click on "Content bank" "link" And I follow "ipsums.h5p" Then "Edit" "link" should exist in the "region-main" "region" - And I click on "Content bank" "link" + And I navigate to "Content bank" in current page administration And I follow "filltheblanks.h5p" Then "Edit" "link" should not exist in the "region-main" "region" diff --git a/course/format/tests/behat/course_courseindex.feature b/course/format/tests/behat/course_courseindex.feature index 55c831d7d1d..77f187d2bab 100644 --- a/course/format/tests/behat/course_courseindex.feature +++ b/course/format/tests/behat/course_courseindex.feature @@ -30,8 +30,7 @@ Feature: Course index depending on role Given I am on the "C1" "Course" page logged in as "teacher1" Given the "multilang" filter is "on" And the "multilang" filter applies to "content and headings" - And I am on the "C1" "Course" page logged in as "teacher1" - When I click on "Side panel" "button" + When I am on the "C1" "Course" page logged in as "teacher1" Then I should see "Open course index drawer" And I am on the "Activity sample 1" "assign activity editing" page And I set the field "Assignment name" in the "General" "fieldset" to "ActivityAktivität sample 1" @@ -44,7 +43,6 @@ Feature: Course index depending on role Scenario: Course index as a teacher Given I log in as "teacher1" And I am on "Course 1" course homepage - And I click on "Side panel" "button" When I click on "Open course index drawer" "button" Then I should see "Topic 1" in the "courseindex-content" "region" And I should see "Topic 2" in the "courseindex-content" "region" @@ -63,7 +61,6 @@ Feature: Course index depending on role And I log out And I log in as "teacher1" And I am on "Course 1" course homepage - And I click on "Side panel" "button" When I click on "Open course index drawer" "button" Then I should see "Topic 1" in the "courseindex-content" "region" And I should see "Topic 2" in the "courseindex-content" "region" @@ -82,7 +79,6 @@ Feature: Course index depending on role And I log out And I log in as "student1" And I am on "Course 1" course homepage - And I click on "Side panel" "button" When I click on "Open course index drawer" "button" Then I should see "Topic 1" in the "courseindex-content" "region" And I should not see "Topic 2" in the "courseindex-content" "region" @@ -95,7 +91,6 @@ Feature: Course index depending on role Scenario: Delete an activity as a teacher Given I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on - And I click on "Side panel" "button" When I delete "Activity sample 2" activity And I click on "Open course index drawer" "button" Then I should not see "Activity sample 2" in the "courseindex-content" "region" @@ -104,7 +99,6 @@ Feature: Course index depending on role Scenario: Highlight sections are represented in the course index. Given I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on - And I click on "Side panel" "button" And I turn section "2" highlighting on And I click on "Open course index drawer" "button" # Current section is only marked visually in the course index. @@ -124,7 +118,6 @@ Feature: Course index depending on role | book | Second activity in section 1 | Test book description | C1 | sample4 | 1 | And I log in as "teacher1" And I am on "Course 1" course homepage - And I click on "Side panel" "button" When I click on "Open course index drawer" "button" # Sections should be opened by default. Then I should see "Topic 1" in the "courseindex-content" "region" @@ -174,7 +167,6 @@ Feature: Course index depending on role @javascript Scenario: Course index section preferences Given I am on the "C1" "Course" page logged in as "teacher1" - And I click on "Side panel" "button" When I click on "Open course index drawer" "button" Then I should see "Topic 1" in the "courseindex-content" "region" And I should see "Activity sample 1" in the "courseindex-content" "region" @@ -205,6 +197,7 @@ Feature: Course index depending on role And I delete section "1" And I click on "Delete" "button" in the ".modal" "css_element" And I reload the page + And I click on "Open course index drawer" "button" And I should not see "Activity sample 1" in the "courseindex-content" "region" And I should see "Topic 1" in the "courseindex-content" "region" And I should see "Activity sample 2" in the "courseindex-content" "region" @@ -215,7 +208,6 @@ Feature: Course index depending on role Scenario: Adding section should alter the course index Given I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on - And I click on "Side panel" "button" And I click on "Open course index drawer" "button" When I click on "Add topic after" "link" in the "Topic 4" "section" Then I should see "Topic 5" in the "courseindex-content" "region" @@ -224,7 +216,6 @@ Feature: Course index depending on role Scenario: Remove a section should alter the course index Given I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on - And I click on "Side panel" "button" And I click on "Open course index drawer" "button" When I delete section "4" Then I should not see "Topic 4" in the "courseindex-content" "region" @@ -233,7 +224,6 @@ Feature: Course index depending on role Scenario: Delete a previous section should alter the course index unnamed sections Given I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on - And I click on "Side panel" "button" And I click on "Open course index drawer" "button" When I delete section "1" And I click on "Delete" "button" in the ".modal" "css_element" diff --git a/course/format/tests/behat/courseindex_completion.feature b/course/format/tests/behat/courseindex_completion.feature index 56e7de3e74f..afc63064798 100644 --- a/course/format/tests/behat/courseindex_completion.feature +++ b/course/format/tests/behat/courseindex_completion.feature @@ -26,7 +26,6 @@ Feature: Course index completion icons @javascript Scenario: Teacher does not see completion icons. Given I am on the "C1" "Course" page logged in as "teacher1" - And I click on "Side panel" "button" When I click on "Open course index drawer" "button" Then I should see "Topic 1" in the "courseindex-content" "region" And I should see "Activity sample 1" in the "courseindex-content" "region" @@ -35,7 +34,6 @@ Feature: Course index completion icons @javascript Scenario: User should see the completion icons Given I am on the "C1" "Course" page logged in as "student1" - And I click on "Side panel" "button" When I click on "Open course index drawer" "button" Then I should see "Topic 1" in the "courseindex-content" "region" And I should see "Activity sample 1" in the "courseindex-content" "region" @@ -44,7 +42,6 @@ Feature: Course index completion icons @javascript Scenario: Manual completion shoudl update the course index completion Given I am on the "C1" "Course" page logged in as "student1" - And I click on "Side panel" "button" And I click on "Open course index drawer" "button" And "To do" "icon" should exist in the "courseindex-content" "region" When I press "Mark as done" @@ -57,7 +54,6 @@ Feature: Course index completion icons @javascript Scenario: Refresh the page should keep the completion consistent Given I am on the "C1" "Course" page logged in as "student1" - And I click on "Side panel" "button" And I click on "Open course index drawer" "button" And "To do" "icon" should exist in the "courseindex-content" "region" When I press "Mark as done" @@ -72,7 +68,6 @@ Feature: Course index completion icons | assign | Activity sample 2 | Test assignment description | C1 | sample2 | 1 | 1 | 1 | When I am on the "sample2" "Activity" page logged in as "student1" And I am on the "C1" "Course" page - And I click on "Side panel" "button" And I click on "Open course index drawer" "button" Then "Done" "icon" should exist in the "courseindex-content" "region" @@ -94,7 +89,6 @@ Feature: Course index completion icons | slot | response | | 1 | False | When I am on the "C1" "Course" page logged in as "student1" - And I click on "Side panel" "button" And I click on "Open course index drawer" "button" And "Failed" "icon" should exist in the "courseindex-content" "region" @@ -116,6 +110,5 @@ Feature: Course index completion icons | slot | response | | 1 | True | When I am on the "C1" "Course" page logged in as "student1" - And I click on "Side panel" "button" And I click on "Open course index drawer" "button" And "Done" "icon" should exist in the "courseindex-content" "region" diff --git a/course/format/tests/behat/courseindex_keyboardnav.feature b/course/format/tests/behat/courseindex_keyboardnav.feature index 46d746a3b02..6a29fd791d2 100644 --- a/course/format/tests/behat/courseindex_keyboardnav.feature +++ b/course/format/tests/behat/courseindex_keyboardnav.feature @@ -17,7 +17,6 @@ Feature: Verify that courseindex is usable with the keyboard | book | Activity sample 2 | Test book description | C1 | sample2 | 2 | | choice | Activity sample 3 | Test choice description | C1 | sample3 | 3 | Given I am on the "C1" "Course" page logged in as "admin" - And I click on "Side panel" "button" And I click on "Open course index drawer" "button" And I should see "Topic 1" in the "courseindex-content" "region" And the focused element is "[data-preference='drawer-open-index'] .drawertoggle" "css_element" diff --git a/course/tests/behat/behat_course.php b/course/tests/behat/behat_course.php index 6cb2402191c..ee3878125ba 100644 --- a/course/tests/behat/behat_course.php +++ b/course/tests/behat/behat_course.php @@ -1938,7 +1938,7 @@ class behat_course extends behat_base { * @Given /^I navigate to course participants$/ */ public function i_navigate_to_course_participants() { - $this->execute('behat_navigation::i_select_from_flat_navigation_drawer', get_string('participants')); + $this->execute('behat_navigation::i_select_from_secondary_navigation', get_string('participants')); } /** diff --git a/course/tests/behat/course_collapse_sections.feature b/course/tests/behat/course_collapse_sections.feature index 16a8778ee45..79d4d83e527 100644 --- a/course/tests/behat/course_collapse_sections.feature +++ b/course/tests/behat/course_collapse_sections.feature @@ -155,7 +155,7 @@ Feature: Collapse course sections | Course layout | Show one section per page | And I press "Save and display" And "[data-toggle=collapse]" "css_element" should not exist in the "region-main" "region" - And I follow "Topic 2" + And I click on "Topic 2" "link" in the "region-main" "region" And I should see "Assignment 2" in the "region-main" "region" And "[data-toggle=collapse]" "css_element" should not exist in the "region-main" "region" Then "Topic 1" "section" should not exist @@ -178,7 +178,7 @@ Feature: Collapse course sections | Course layout | Show one section per page | And I press "Save and display" And "[data-toggle=collapse]" "css_element" should not exist in the "region-main" "region" - And I follow "8 May - 14 May" + And I click on "8 May - 14 May" "link" in the "region-main" "region" And I should see "Assignment 2" in the "region-main" "region" And "[data-toggle=collapse]" "css_element" should not exist in the "region-main" "region" Then "1 May - 7 May" "section" should not exist diff --git a/course/tests/behat/course_controls.feature b/course/tests/behat/course_controls.feature index b8c22e34b22..835dd275392 100644 --- a/course/tests/behat/course_controls.feature +++ b/course/tests/behat/course_controls.feature @@ -27,9 +27,8 @@ Feature: Course activity controls works as expected | user | course | role | | teacher1 | C1 | editingteacher | And I log in as "teacher1" - And I am on "Course 1" course homepage - When I follow - And I turn editing mode on + And I am on "Course 1" course homepage with editing mode on + When I follow the breadcrumb And I add the "Recent activity" block And I open the action menu in "Recent activity" "block" And I click on "Delete Recent activity block" "link" @@ -99,9 +98,8 @@ Feature: Course activity controls works as expected | forum | Test forum name 1 | Test forum description 1 | C1 | 0001 | 1 | | forum | Test forum name 2 | Test forum description 2 | C1 | 0002 | 1 | And I log in as "teacher1" - And I am on "Course 1" course homepage - When I follow - And I turn editing mode on + And I am on "Course 1" course homepage with editing mode on + When I follow the breadcrumb And I add the "Recent activity" block And I open the action menu in "Recent activity" "block" And I click on "Delete Recent activity block" "link" diff --git a/course/tests/behat/course_creation.feature b/course/tests/behat/course_creation.feature index 73ec8538cb8..40b384c6055 100644 --- a/course/tests/behat/course_creation.feature +++ b/course/tests/behat/course_creation.feature @@ -27,7 +27,7 @@ Feature: Managers can create courses And I log out And I am on the Announcements "forum activity" page logged in as student1 And "Add a new topic" "link" should not exist - And "Forced subscription" "text" should exist in current page administration + And "Forced subscription" "text" should exist Scenario: Create a course from the management interface and return to it Given the following "courses" exist: diff --git a/course/tests/behat/course_download_content_permissions.feature b/course/tests/behat/course_download_content_permissions.feature index 21edbd45663..74dd85e3d84 100644 --- a/course/tests/behat/course_download_content_permissions.feature +++ b/course/tests/behat/course_download_content_permissions.feature @@ -27,11 +27,13 @@ Feature: Access to downloading course content can be controlled And I navigate to "Settings" in current page administration And I set the field "Enable download course content" to "Yes" And I press "Save and display" - And "Download course content" "link" should exist in current page administration + And I navigate to "Course administration" in current page administration + And "Download course content" "link" should exist When the following config values are set as admin: | downloadcoursecontentallowed | 0 | And I am on "Hockey 101" course homepage - Then "Download course content" "link" should not exist in current page administration + And I navigate to "Course administration" in current page administration + And "Download course content" "link" should not exist And I navigate to "Settings" in current page administration And I should not see "Enable download course content" @@ -43,7 +45,8 @@ Feature: Access to downloading course content can be controlled And I set the field "Enable download course content" to "Yes" And I press "Save changes" And I am on "Hockey 101" course homepage - Then "Download course content" "link" should exist in current page administration + And I navigate to "Course administration" in current page administration + Then "Download course content" "link" should exist Scenario: A teacher can enable and disable the download course content feature when it is available Given I log in as "teacher1" @@ -53,11 +56,13 @@ Feature: Access to downloading course content can be controlled And I should see "Enable download course content" And I set the field "Enable download course content" to "Yes" And I press "Save and display" - Then "Download course content" "link" should exist in current page administration + And I navigate to "Course administration" in current page administration + Then "Download course content" "link" should exist And I navigate to "Settings" in current page administration And I set the field "Enable download course content" to "No" And I press "Save and display" - And "Download course content" "link" should not exist in current page administration + And I navigate to "Course administration" in current page administration + And "Download course content" "link" should not exist Scenario: Teachers require a capability to access the download course content feature or modify its availability in a course Given I log in as "admin" @@ -68,7 +73,8 @@ Feature: Access to downloading course content can be controlled # Check teacher can see download option and enable dropdown. And I log in as "teacher1" And I am on "Hockey 101" course homepage - And "Download course content" "link" should exist in current page administration + And I navigate to "Course administration" in current page administration + And "Download course content" "link" should exist And I navigate to "Settings" in current page administration And "Enable download course content" "select" should exist And I log out @@ -82,7 +88,8 @@ Feature: Access to downloading course content can be controlled # Check teacher can no longer see download option, and that enable value is visible, but dropdown no longer available. When I log in as "teacher1" And I am on "Hockey 101" course homepage - Then "Download course content" "link" should not exist in current page administration + And I navigate to "Course administration" in current page administration + Then "Download course content" "link" should not exist And I navigate to "Settings" in current page administration And I should see "Enable download course content" And I should see "Site default (Yes)" diff --git a/files/tests/behat/course_files.feature b/files/tests/behat/course_files.feature index daea45c0433..c7e95c94f92 100644 --- a/files/tests/behat/course_files.feature +++ b/files/tests/behat/course_files.feature @@ -14,8 +14,7 @@ Feature: Course files | legacyfilesaddallowed | 1 | When I log in as "admin" And I am on "Course 1" course homepage - Then "Legacy course files" "link" should exist in current page administration - And I navigate to "Legacy course files" in current page administration + Then I navigate to "Legacy course files" in current page administration And I press "Edit legacy course files" And "Add..." "link" should be visible And "Create folder" "link" should be visible @@ -30,8 +29,7 @@ Feature: Course files | legacyfilesaddallowed | 0 | When I log in as "admin" And I am on "Course 1" course homepage - Then "Legacy course files" "link" should exist in current page administration - And I navigate to "Legacy course files" in current page administration + Then I navigate to "Legacy course files" in current page administration And I press "Edit legacy course files" And "Add..." "link" should not be visible And "Create folder" "link" should not be visible diff --git a/grade/grading/form/guide/tests/behat/edit_guide.feature b/grade/grading/form/guide/tests/behat/edit_guide.feature index 7381dd0a334..1ae960f7cbb 100644 --- a/grade/grading/form/guide/tests/behat/edit_guide.feature +++ b/grade/grading/form/guide/tests/behat/edit_guide.feature @@ -36,6 +36,7 @@ Feature: Marking guides can be created and edited And I press "Save and return to course" # Defining a marking guide When I go to "Test assignment 1 name" advanced grading definition page + And I change window size to "large" And I set the following fields to these values: | Name | Assignment 1 marking guide | | Description | Marking guide test description | @@ -85,7 +86,8 @@ Feature: Marking guides can be created and edited @javascript Scenario: Grading and viewing graded marking guide # Grading a student. - When I go to "Student 1" "Test assignment 1 name" activity advanced grading page + When I navigate to "Assignment" in current page administration + And I go to "Student 1" "Test assignment 1 name" activity advanced grading page And I grade by filling the marking guide with: | Guide criterion A | 25 | Very good | | Guide criterion B | 20 | | @@ -97,8 +99,7 @@ Feature: Marking guides can be created and edited And I wait "1" seconds Then the field "Guide criterion B criterion remark" matches value "Comment \"4\"" When I press "Save changes" - And I follow "Edit settings" - And I follow "Test assignment 1 name" + And I follow "Assignment: Test assignment 1 name" And I follow "View all submissions" # Checking that the user grade is correct. Then I should see "80" in the "Student 1" "table_row" diff --git a/grade/grading/form/rubric/tests/behat/edit_rubric.feature b/grade/grading/form/rubric/tests/behat/edit_rubric.feature index 1172d9866e1..2c5dc289818 100644 --- a/grade/grading/form/rubric/tests/behat/edit_rubric.feature +++ b/grade/grading/form/rubric/tests/behat/edit_rubric.feature @@ -49,6 +49,7 @@ Feature: Rubrics can be created and edited And I press "Save rubric and make it ready" Then I should see "Ready for use" # Grading two students. + And I navigate to "Assignment" in current page administration And I go to "Student 1" "Test assignment 1 name" activity advanced grading page And I grade by filling the rubric with: | Criterion 1 | 50 | Very good | @@ -64,6 +65,7 @@ Feature: Rubrics can be created and edited # Checking that the user grade is correct. And I should see "65" in the "Student 1" "table_row" # Updating the user grade. + And I am on the "Test assignment 1 name" "assign activity" page And I go to "Student 1" "Test assignment 1 name" activity advanced grading page And I grade by filling the rubric with: | Criterion 1 | 20 | Bad, I changed my mind | diff --git a/grade/grading/form/rubric/tests/behat/grade_calculation.feature b/grade/grading/form/rubric/tests/behat/grade_calculation.feature index 7eb16133014..fa62ae43670 100644 --- a/grade/grading/form/rubric/tests/behat/grade_calculation.feature +++ b/grade/grading/form/rubric/tests/behat/grade_calculation.feature @@ -35,6 +35,7 @@ Feature: Converting rubric score to grades | Criterion 2 | Level 21 | 20 | Level 22 | 25 | Level 23 | 30 | | | | Criterion 3 | Level 31 | 10 | Level 32 | 20 | | | | | And I press "Save rubric and make it ready" + And I navigate to "Assignment" in current page administration # Grading a student. And I go to "Student 1" "Test assignment 1" activity advanced grading page And I grade by filling the rubric with: diff --git a/grade/grading/form/rubric/tests/behat/negative_points.feature b/grade/grading/form/rubric/tests/behat/negative_points.feature index 363bb6feea7..4d8b1bc3411 100644 --- a/grade/grading/form/rubric/tests/behat/negative_points.feature +++ b/grade/grading/form/rubric/tests/behat/negative_points.feature @@ -39,18 +39,21 @@ Feature: Rubrics can have levels with negative scores | Criterion 3 | Level 31 | 10 | Level 32 | 20 | | | | | And I press "Save rubric and make it ready" # Grading a student. + And I navigate to "Assignment" in current page administration And I go to "Student 1" "Test assignment 1" activity advanced grading page And I grade by filling the rubric with: | Criterion 1 | 25 | | | Criterion 2 | 30 | | | Criterion 3 | 10 | | And I save the advanced grading form + And I am on the "Test assignment 1" "assign activity" page And I go to "Student 2" "Test assignment 1" activity advanced grading page And I grade by filling the rubric with: | Criterion 1 | 25 | | | Criterion 2 | -20 | | | Criterion 3 | 10 | | And I save the advanced grading form + And I am on the "Test assignment 1" "assign activity" page And I go to "Student 3" "Test assignment 1" activity advanced grading page And I grade by filling the rubric with: | Criterion 1 | -11 | | diff --git a/grade/grading/tests/behat/behat_grading.php b/grade/grading/tests/behat/behat_grading.php index 54c2a450ca5..5ee23b1d0db 100644 --- a/grade/grading/tests/behat/behat_grading.php +++ b/grade/grading/tests/behat/behat_grading.php @@ -47,7 +47,11 @@ class behat_grading extends behat_base { */ public function i_go_to_advanced_grading_page($activityname) { - $this->execute("behat_general::i_click_on_in_the", [$this->escape($activityname), 'link', 'page', 'region']); + try { + $this->execute("behat_general::i_click_on_in_the", [$this->escape($activityname), 'link', 'page', 'region']); + } catch (Exception $e) { + $this->execute('behat_navigation::go_to_breadcrumb_location', $this->escape($activityname)); + } $this->execute('behat_navigation::i_navigate_to_in_current_page_administration', get_string('gradingmanagement', 'grading')); diff --git a/grade/tests/behat/behat_grade.php b/grade/tests/behat/behat_grade.php index 02a4d1e0037..a95939db62a 100644 --- a/grade/tests/behat/behat_grade.php +++ b/grade/tests/behat/behat_grade.php @@ -325,7 +325,7 @@ class behat_grade extends behat_base { // If we are not on one of the gradebook pages already, follow "Grades" link in the navigation drawer. $xpath = '//div[contains(@class,\'grade-navigation\')]'; if (!$this->getSession()->getPage()->findAll('xpath', $xpath)) { - $this->execute('behat_navigation::i_select_from_flat_navigation_drawer', get_string('grades')); + $this->execute('behat_navigation::i_select_from_secondary_navigation', get_string('grades')); } $this->select_in_gradebook_tabs($gradepath); diff --git a/grade/tests/behat/grade_letter_boundary.feature b/grade/tests/behat/grade_letter_boundary.feature index 2b0fa5bb652..c65e27b47f1 100644 --- a/grade/tests/behat/grade_letter_boundary.feature +++ b/grade/tests/behat/grade_letter_boundary.feature @@ -36,7 +36,8 @@ Feature: We can customise the letter boundary of a course. 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 turn editing mode off + And I am on "Course 1" course homepage with editing mode off + And I navigate to "View > Grader report" in the course gradebook Then the following should exist in the "user-grades" table: | -1- | -4- | -5- | | Student 1 | D | D | diff --git a/grade/tests/behat/grade_letter_boundary_20160518.feature b/grade/tests/behat/grade_letter_boundary_20160518.feature index b46c43c5ef4..bbeea47b7e3 100644 --- a/grade/tests/behat/grade_letter_boundary_20160518.feature +++ b/grade/tests/behat/grade_letter_boundary_20160518.feature @@ -37,7 +37,8 @@ Feature: We can customise the letter boundary of a course in gradebook version 2 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 turn editing mode off + And I am on "Course 1" course homepage with editing mode off + And I navigate to "View > Grader report" in the course gradebook Then the following should exist in the "user-grades" table: | -1- | -4- | -5- | | Student 1 | F | F | diff --git a/index.php b/index.php index cd37dc75907..d8c88df1258 100644 --- a/index.php +++ b/index.php @@ -98,6 +98,13 @@ $PAGE->set_title($SITE->fullname); $PAGE->set_heading($SITE->fullname); $PAGE->has_secondary_navigation_setter(false); $courserenderer = $PAGE->get_renderer('core', 'course'); + +if ($hassiteconfig) { + $editurl = new moodle_url('/course/view.php', ['id' => SITEID, 'sesskey' => sesskey()]); + $editbutton = $OUTPUT->edit_button($editurl); + $PAGE->set_button($editbutton); +} + echo $OUTPUT->header(); $siteformatoptions = course_get_format($SITE)->get_format_options(); diff --git a/lib/amd/build/addblockmodal.min.js b/lib/amd/build/addblockmodal.min.js index 830678757f5..bea876da82f 100644 --- a/lib/amd/build/addblockmodal.min.js +++ b/lib/amd/build/addblockmodal.min.js @@ -1,2 +1,2 @@ -define ("core/addblockmodal",["exports","core/modal_factory","core/templates","core/str","core/ajax"],function(a,b,c,d,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=f(b);c=f(c);e=f(e);function f(a){return a&&a.__esModule?a:{default:a}}function g(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function h(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var i=a.apply(b,c);function f(a){g(i,d,e,f,h,"next",a)}function h(a){g(i,d,e,f,h,"throw",a)}f(void 0)})}}var i={ADD_BLOCK:"[data-key=\"addblock\"]"},j=null,k=function(a,b,c){document.addEventListener("click",function(d){if(d.target.closest(i.ADD_BLOCK)){d.preventDefault();if(j){j.show()}else{l().then(function(d){j=d;var e=m(c,a,b);d.setBody(e);d.show();return e}).catch(function(){j.destroy();j=null})}}})},l=function(){return b.default.create({type:b.default.types.CANCEL,title:(0,d.get_string)("addblock")})},m=function(){var a=h(regeneratorRuntime.mark(function a(b,d,e){var f;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.next=2;return n(d,e);case 2:f=a.sent;return a.abrupt("return",c.default.render("core/add_block_body",{blocks:f,url:b}));case 4:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),n=function(){var a=h(regeneratorRuntime.mark(function a(b,c){var d;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:d={methodname:"core_block_fetch_addable_blocks",args:{pagecontextid:M.cfg.contextid,pagetype:b,pagelayout:c}};return a.abrupt("return",e.default.call([d])[0]);case 2:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.init=function init(a,b,c){k(a,b,c)}}); +define ("core/addblockmodal",["exports","core/modal_factory","core/templates","core/str","core/ajax"],function(a,b,c,d,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=f(b);c=f(c);e=f(e);function f(a){return a&&a.__esModule?a:{default:a}}function g(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function h(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var i=a.apply(b,c);function f(a){g(i,d,e,f,h,"next",a)}function h(a){g(i,d,e,f,h,"throw",a)}f(void 0)})}}var i={ADD_BLOCK:"[data-key=\"addblock\"]"},j=null,k=function(a,b,c){document.addEventListener("click",function(d){if(d.target.closest(i.ADD_BLOCK)){d.preventDefault();if(null===c){c=d.target.closest(i.ADD_BLOCK).dataset.url}if(j){j.show()}else{l().then(function(d){j=d;var e=m(c,a,b);d.setBody(e);d.show();return e}).catch(function(){j.destroy();j=null})}}})},l=function(){return b.default.create({type:b.default.types.CANCEL,title:(0,d.get_string)("addblock")})},m=function(){var a=h(regeneratorRuntime.mark(function a(b,d,e){var f;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:a.next=2;return n(d,e);case 2:f=a.sent;return a.abrupt("return",c.default.render("core/add_block_body",{blocks:f,url:b}));case 4:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}(),n=function(){var a=h(regeneratorRuntime.mark(function a(b,c){var d;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:d={methodname:"core_block_fetch_addable_blocks",args:{pagecontextid:M.cfg.contextid,pagetype:b,pagelayout:c}};return a.abrupt("return",e.default.call([d])[0]);case 2:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.init=function init(a,b){var c=2.\n\n/**\n * Show an add block modal instead of doing it on a separate page.\n *\n * @module core/addblockmodal\n * @copyright 2016 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport ModalFactory from 'core/modal_factory';\nimport Templates from 'core/templates';\nimport {get_string as getString} from 'core/str';\nimport Ajax from 'core/ajax';\n\nconst SELECTORS = {\n ADD_BLOCK: '[data-key=\"addblock\"]'\n};\n\nlet addBlockModal = null;\n\n/**\n * Register related event listeners.\n *\n * @method registerListenerEvents\n * @param {String} pageType The type of the page\n * @param {String} pageLayout The layout of the page\n * @param {String} addBlockUrl The add block URL\n */\nconst registerListenerEvents = (pageType, pageLayout, addBlockUrl) => {\n document.addEventListener('click', e => {\n\n if (e.target.closest(SELECTORS.ADD_BLOCK)) {\n e.preventDefault();\n\n if (addBlockModal) { // The 'add block' modal has been already created.\n // Display the 'add block' modal.\n addBlockModal.show();\n } else {\n buildAddBlockModal()\n .then(modal => {\n addBlockModal = modal;\n const modalBody = renderBlocks(addBlockUrl, pageType, pageLayout);\n modal.setBody(modalBody);\n modal.show();\n\n return modalBody;\n })\n .catch(() => {\n addBlockModal.destroy();\n // Unset the addBlockModal in case this is a transient error and it goes away on a relaunch.\n addBlockModal = null;\n });\n }\n }\n });\n};\n\n/**\n * Method that creates the 'add block' modal.\n *\n * @method buildAddBlockModal\n * @returns {Promise} The modal promise (modal's body will be rendered later).\n */\nconst buildAddBlockModal = () => {\n return ModalFactory.create({\n type: ModalFactory.types.CANCEL,\n title: getString('addblock')\n });\n};\n\n/**\n * Method that renders the list of available blocks.\n *\n * @method renderBlocks\n * @param {String} addBlockUrl The add block URL\n * @param {String} pageType The type of the page\n * @param {String} pageLayout The layout of the page\n * @return {Promise}\n */\nconst renderBlocks = async(addBlockUrl, pageType, pageLayout) => {\n // Fetch all addable blocks in the given page.\n const blocks = await getAddableBlocks(pageType, pageLayout);\n\n return Templates.render('core/add_block_body', {\n blocks: blocks,\n url: addBlockUrl\n });\n};\n\n/**\n * Method that fetches all addable blocks in a given page.\n *\n * @method getAddableBlocks\n * @param {String} pageType The type of the page\n * @param {String} pageLayout The layout of the page\n * @return {Promise}\n */\nconst getAddableBlocks = async(pageType, pageLayout) => {\n const request = {\n methodname: 'core_block_fetch_addable_blocks',\n args: {\n pagecontextid: M.cfg.contextid,\n pagetype: pageType,\n pagelayout: pageLayout\n },\n };\n\n return Ajax.call([request])[0];\n};\n\n/**\n * Set up the actions.\n *\n * @method init\n * @param {String} pageType The type of the page\n * @param {String} pageLayout The layout of the page\n * @param {String} addBlockUrl The add block URL\n */\nexport const init = (pageType, pageLayout, addBlockUrl) => {\n registerListenerEvents(pageType, pageLayout, addBlockUrl);\n};\n"],"file":"addblockmodal.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/addblockmodal.js"],"names":["SELECTORS","ADD_BLOCK","addBlockModal","registerListenerEvents","pageType","pageLayout","addBlockUrl","document","addEventListener","e","target","closest","preventDefault","dataset","url","show","buildAddBlockModal","then","modal","modalBody","renderBlocks","setBody","catch","destroy","ModalFactory","create","type","types","CANCEL","title","getAddableBlocks","blocks","Templates","render","request","methodname","args","pagecontextid","M","cfg","contextid","pagetype","pagelayout","Ajax","call","init"],"mappings":"sMAuBA,OACA,OAEA,O,qXAEMA,CAAAA,CAAS,CAAG,CACdC,SAAS,CAAE,yBADG,C,CAIdC,CAAa,CAAG,I,CAUdC,CAAsB,CAAG,SAACC,CAAD,CAAWC,CAAX,CAAuBC,CAAvB,CAAuC,CAClEC,QAAQ,CAACC,gBAAT,CAA0B,OAA1B,CAAmC,SAAAC,CAAC,CAAI,CAEpC,GAAIA,CAAC,CAACC,MAAF,CAASC,OAAT,CAAiBX,CAAS,CAACC,SAA3B,CAAJ,CAA2C,CACvCQ,CAAC,CAACG,cAAF,GAEA,GAAoB,IAAhB,GAAAN,CAAJ,CAA0B,CACtBA,CAAW,CAAGG,CAAC,CAACC,MAAF,CAASC,OAAT,CAAiBX,CAAS,CAACC,SAA3B,EAAsCY,OAAtC,CAA8CC,GAC/D,CAED,GAAIZ,CAAJ,CAAmB,CAEfA,CAAa,CAACa,IAAd,EACH,CAHD,IAGO,CACHC,CAAkB,GACjBC,IADD,CACM,SAAAC,CAAK,CAAI,CACXhB,CAAa,CAAGgB,CAAhB,CACA,GAAMC,CAAAA,CAAS,CAAGC,CAAY,CAACd,CAAD,CAAcF,CAAd,CAAwBC,CAAxB,CAA9B,CACAa,CAAK,CAACG,OAAN,CAAcF,CAAd,EACAD,CAAK,CAACH,IAAN,GAEA,MAAOI,CAAAA,CACV,CARD,EASCG,KATD,CASO,UAAM,CACTpB,CAAa,CAACqB,OAAd,GAEArB,CAAa,CAAG,IACnB,CAbD,CAcH,CACJ,CACJ,CA7BD,CA8BH,C,CAQKc,CAAkB,CAAG,UAAM,CAC7B,MAAOQ,WAAaC,MAAb,CAAoB,CACvBC,IAAI,CAAEF,UAAaG,KAAb,CAAmBC,MADF,CAEvBC,KAAK,CAAE,iBAAU,UAAV,CAFgB,CAApB,CAIV,C,CAWKT,CAAY,4CAAG,WAAMd,CAAN,CAAmBF,CAAnB,CAA6BC,CAA7B,wGAEIyB,CAAAA,CAAgB,CAAC1B,CAAD,CAAWC,CAAX,CAFpB,QAEX0B,CAFW,iCAIVC,UAAUC,MAAV,CAAiB,qBAAjB,CAAwC,CAC3CF,MAAM,CAAEA,CADmC,CAE3CjB,GAAG,CAAER,CAFsC,CAAxC,CAJU,0CAAH,uD,CAkBZwB,CAAgB,4CAAG,WAAM1B,CAAN,CAAgBC,CAAhB,yFACf6B,CADe,CACL,CACZC,UAAU,CAAE,iCADA,CAEZC,IAAI,CAAE,CACFC,aAAa,CAAEC,CAAC,CAACC,GAAF,CAAMC,SADnB,CAEFC,QAAQ,CAAErC,CAFR,CAGFsC,UAAU,CAAErC,CAHV,CAFM,CADK,0BAUdsC,UAAKC,IAAL,CAAU,CAACV,CAAD,CAAV,EAAqB,CAArB,CAVc,0CAAH,uD,QAqBF,QAAPW,CAAAA,IAAO,CAACzC,CAAD,CAAWC,CAAX,CAA8C,IAAvBC,CAAAA,CAAuB,wDAAT,IAAS,CAC9DH,CAAsB,CAACC,CAAD,CAAWC,CAAX,CAAuBC,CAAvB,CACzB,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Show an add block modal instead of doing it on a separate page.\n *\n * @module core/addblockmodal\n * @copyright 2016 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport ModalFactory from 'core/modal_factory';\nimport Templates from 'core/templates';\nimport {get_string as getString} from 'core/str';\nimport Ajax from 'core/ajax';\n\nconst SELECTORS = {\n ADD_BLOCK: '[data-key=\"addblock\"]'\n};\n\nlet addBlockModal = null;\n\n/**\n * Register related event listeners.\n *\n * @method registerListenerEvents\n * @param {String} pageType The type of the page\n * @param {String} pageLayout The layout of the page\n * @param {String|null} addBlockUrl The add block URL\n */\nconst registerListenerEvents = (pageType, pageLayout, addBlockUrl) => {\n document.addEventListener('click', e => {\n\n if (e.target.closest(SELECTORS.ADD_BLOCK)) {\n e.preventDefault();\n\n if (addBlockUrl === null) {\n addBlockUrl = e.target.closest(SELECTORS.ADD_BLOCK).dataset.url;\n }\n\n if (addBlockModal) { // The 'add block' modal has been already created.\n // Display the 'add block' modal.\n addBlockModal.show();\n } else {\n buildAddBlockModal()\n .then(modal => {\n addBlockModal = modal;\n const modalBody = renderBlocks(addBlockUrl, pageType, pageLayout);\n modal.setBody(modalBody);\n modal.show();\n\n return modalBody;\n })\n .catch(() => {\n addBlockModal.destroy();\n // Unset the addBlockModal in case this is a transient error and it goes away on a relaunch.\n addBlockModal = null;\n });\n }\n }\n });\n};\n\n/**\n * Method that creates the 'add block' modal.\n *\n * @method buildAddBlockModal\n * @returns {Promise} The modal promise (modal's body will be rendered later).\n */\nconst buildAddBlockModal = () => {\n return ModalFactory.create({\n type: ModalFactory.types.CANCEL,\n title: getString('addblock')\n });\n};\n\n/**\n * Method that renders the list of available blocks.\n *\n * @method renderBlocks\n * @param {String} addBlockUrl The add block URL\n * @param {String} pageType The type of the page\n * @param {String} pageLayout The layout of the page\n * @return {Promise}\n */\nconst renderBlocks = async(addBlockUrl, pageType, pageLayout) => {\n // Fetch all addable blocks in the given page.\n const blocks = await getAddableBlocks(pageType, pageLayout);\n\n return Templates.render('core/add_block_body', {\n blocks: blocks,\n url: addBlockUrl\n });\n};\n\n/**\n * Method that fetches all addable blocks in a given page.\n *\n * @method getAddableBlocks\n * @param {String} pageType The type of the page\n * @param {String} pageLayout The layout of the page\n * @return {Promise}\n */\nconst getAddableBlocks = async(pageType, pageLayout) => {\n const request = {\n methodname: 'core_block_fetch_addable_blocks',\n args: {\n pagecontextid: M.cfg.contextid,\n pagetype: pageType,\n pagelayout: pageLayout\n },\n };\n\n return Ajax.call([request])[0];\n};\n\n/**\n * Set up the actions.\n *\n * @method init\n * @param {String} pageType The type of the page\n * @param {String} pageLayout The layout of the page\n * @param {String|null} addBlockUrl The add block URL\n */\nexport const init = (pageType, pageLayout, addBlockUrl = null) => {\n registerListenerEvents(pageType, pageLayout, addBlockUrl);\n};\n"],"file":"addblockmodal.min.js"} \ No newline at end of file diff --git a/lib/amd/src/addblockmodal.js b/lib/amd/src/addblockmodal.js index 16b42e883f6..bf585059af1 100644 --- a/lib/amd/src/addblockmodal.js +++ b/lib/amd/src/addblockmodal.js @@ -38,7 +38,7 @@ let addBlockModal = null; * @method registerListenerEvents * @param {String} pageType The type of the page * @param {String} pageLayout The layout of the page - * @param {String} addBlockUrl The add block URL + * @param {String|null} addBlockUrl The add block URL */ const registerListenerEvents = (pageType, pageLayout, addBlockUrl) => { document.addEventListener('click', e => { @@ -46,6 +46,10 @@ const registerListenerEvents = (pageType, pageLayout, addBlockUrl) => { if (e.target.closest(SELECTORS.ADD_BLOCK)) { e.preventDefault(); + if (addBlockUrl === null) { + addBlockUrl = e.target.closest(SELECTORS.ADD_BLOCK).dataset.url; + } + if (addBlockModal) { // The 'add block' modal has been already created. // Display the 'add block' modal. addBlockModal.show(); @@ -128,8 +132,8 @@ const getAddableBlocks = async(pageType, pageLayout) => { * @method init * @param {String} pageType The type of the page * @param {String} pageLayout The layout of the page - * @param {String} addBlockUrl The add block URL + * @param {String|null} addBlockUrl The add block URL */ -export const init = (pageType, pageLayout, addBlockUrl) => { +export const init = (pageType, pageLayout, addBlockUrl = null) => { registerListenerEvents(pageType, pageLayout, addBlockUrl); }; diff --git a/lib/blocklib.php b/lib/blocklib.php index 56feb707a4a..d01f0685cf4 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -837,12 +837,23 @@ class block_manager { } } - public function add_block_at_end_of_default_region($blockname) { + /** + * When passed a block name create a new instance of the block in the specified region. + * + * @param string $blockname Name of the block to add. + * @param null|string $blockregion If defined add the new block to the specified region. + */ + public function add_block_at_end_of_default_region($blockname, $blockregion = null) { if (empty($this->birecordsbyregion)) { // No blocks or block regions exist yet. return; } - $defaulregion = $this->get_default_region(); + + if ($blockregion === null) { + $defaulregion = $this->get_default_region(); + } else { + $defaulregion = $blockregion; + } $lastcurrentblock = end($this->birecordsbyregion[$defaulregion]); if ($lastcurrentblock) { @@ -1458,6 +1469,8 @@ class block_manager { global $CFG, $PAGE, $OUTPUT; $blocktype = optional_param('bui_addblock', null, PARAM_PLUGIN); + $blockregion = optional_param('bui_blockregion', null, PARAM_TEXT); + if ($blocktype === null) { return false; } @@ -1519,7 +1532,7 @@ class block_manager { throw new moodle_exception('cannotaddthisblocktype', '', $this->page->url->out(), $blocktype); } - $this->add_block_at_end_of_default_region($blocktype); + $this->add_block_at_end_of_default_region($blocktype, $blockregion); // If the page URL was a guess, it will contain the bui_... param, so we must make sure it is not there. $this->page->ensure_param_not_in_url('bui_addblock'); diff --git a/lib/classes/navigation/views/secondary.php b/lib/classes/navigation/views/secondary.php index 591a530c073..eeec8eaecbe 100644 --- a/lib/classes/navigation/views/secondary.php +++ b/lib/classes/navigation/views/secondary.php @@ -58,6 +58,10 @@ class secondary extends view { 'outcomes' => 2.2, 'coursecompletion' => 6, 'filtermanagement' => 9, + 'unenrolself' => 10, + 'coursetags' => 11, + 'download' => 12, + 'contextlocking' => 13, ], ]; $nodes['navigation'] = [ diff --git a/lib/enrollib.php b/lib/enrollib.php index cd572e19d68..9e6e8a8cc5a 100644 --- a/lib/enrollib.php +++ b/lib/enrollib.php @@ -515,6 +515,7 @@ function enrol_add_course_navigation(navigation_node $coursenode, $course) { if ($unenrollink = $plugin->get_unenrolself_link($instance)) { $shortname = format_string($course->shortname, true, array('context' => $coursecontext)); $coursenode->add(get_string('unenrolme', 'core_enrol', $shortname), $unenrollink, navigation_node::TYPE_SETTING, null, 'unenrolself', new pix_icon('i/user', '')); + $coursenode->get('unenrolself')->set_force_into_more_menu(); break; //TODO. deal with multiple unenrol links - not likely case, but still... } diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 87a7a1409e8..11189b76bef 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -844,6 +844,24 @@ class navigation_node implements renderable { return $this->action; } + /** + * Return an array consisting of the additional attributes for the action url. + * + * @return array Formatted array to parse in a template + */ + public function actionattributes() { + if ($this->action instanceof action_link) { + return array_map(function($key, $value) { + return [ + 'name' => $key, + 'value' => $value + ]; + }, array_keys($this->action->attributes), $this->action->attributes); + } + + return []; + } + /** * Sets whether the node and its children should be added into a "more" menu whenever possible. * @@ -4100,27 +4118,8 @@ class flat_navigation extends navigation_node_collection { $flat->icon = new pix_icon('t/preferences', ''); $this->add($flat); } - - // Add-a-block in editing mode. - if (isset($this->page->theme->addblockposition) && - $this->page->theme->addblockposition == BLOCK_ADDBLOCK_POSITION_FLATNAV && - $PAGE->user_is_editing() && $PAGE->user_can_edit_blocks()) { - $url = new moodle_url($PAGE->url, ['bui_addblock' => '', 'sesskey' => sesskey()]); - $addablock = navigation_node::create(get_string('addblock'), $url); - $flat = new flat_navigation_node($addablock, 0); - $flat->set_showdivider(true, get_string('blocksaddedit')); - $flat->key = 'addblock'; - $flat->icon = new pix_icon('i/addblock', ''); - $this->add($flat); - - $addblockurl = "?{$url->get_query_string(false)}"; - - $PAGE->requires->js_call_amd('core/addblockmodal', 'init', - [$PAGE->pagetype, $PAGE->pagelayout, $addblockurl]); - } } - /** * Override the parent so we can set a label for this collection if it has not been set yet. * @@ -4518,6 +4517,7 @@ class settings_navigation extends navigation_node { if (!$adminoptions->update && $adminoptions->tags) { $url = new moodle_url('/course/tags.php', array('id' => $course->id)); $coursenode->add(get_string('coursetags', 'tag'), $url, self::TYPE_SETTING, null, 'coursetags', new pix_icon('i/settings', '')); + $coursenode->get('coursetags')->set_force_into_more_menu(); } // add enrol nodes @@ -4654,6 +4654,7 @@ class settings_navigation extends navigation_node { $coursenode->add($linkattr->displaystring, $actionlink, self::TYPE_SETTING, null, 'download', new pix_icon('t/download', '')); + $coursenode->get('download')->set_force_into_more_menu(); } // Return we are done diff --git a/lib/templates/add_block_button.mustache b/lib/templates/add_block_button.mustache new file mode 100644 index 00000000000..c7276dab7b5 --- /dev/null +++ b/lib/templates/add_block_button.mustache @@ -0,0 +1,41 @@ +{{! + 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 . +}} +{{! + @template core/add_block_button + + Template for the body of the fake 'add block' block. + + Example context (json): + { + "link" : "/my/index.php?bui_addblock&bui_blockregion=content&sesskey=M3mes", + "escapedlink" : "?bui_addblock&bui_blockregion=content&sesskey=M3mes", + "pageType" : "my-index", + "pageLayout" : "mydashboard" + } + +}} + + {{#str}}addblock{{/str}} + + + +{{#js}} + // Initialise the JS for the modal window which displays the blocks available to add. + require(['core/addblockmodal'], function(addBlockModal) { + addBlockModal.init('{{pageType}}', '{{pageLayout}}'); + }); +{{/js}} diff --git a/lib/templates/full_header.mustache b/lib/templates/full_header.mustache index 108a0a277a2..00f44ae4a86 100644 --- a/lib/templates/full_header.mustache +++ b/lib/templates/full_header.mustache @@ -48,16 +48,10 @@
{{#contextheader}} -
- {{{contextheader}}} -
+
+ {{{contextheader}}} +
{{/contextheader}} - - {{#settingsmenu}} -
- {{{settingsmenu}}} -
- {{/settingsmenu}}
{{#headeractions}}
{{{.}}}
diff --git a/lib/templates/moremenu_children.mustache b/lib/templates/moremenu_children.mustache index be75f0f92c8..05e6166d296 100644 --- a/lib/templates/moremenu_children.mustache +++ b/lib/templates/moremenu_children.mustache @@ -50,12 +50,12 @@ {{^haschildren}}