diff --git a/mod/feedback/classes/navigation/views/secondary.php b/mod/feedback/classes/navigation/views/secondary.php index e61d5aef411..4922a2db72b 100644 --- a/mod/feedback/classes/navigation/views/secondary.php +++ b/mod/feedback/classes/navigation/views/secondary.php @@ -34,50 +34,14 @@ class secondary extends core_secondary { protected function get_default_module_mapping(): array { $basenodes = parent::get_default_module_mapping(); $basenodes[self::TYPE_CUSTOM] += [ - 'templatenode' => 12, - 'mapcourse' => 13, - 'feedbackanalysis' => 14, - 'responses' => 15, - 'nonrespondents' => 15.1 + 'questionnode' => 2, + 'templatenode' => 3, + 'responses' => 4, + 'nonrespondents' => 4.1, + 'feedbackanalysis' => 5, + 'mapcourse' => 12, ]; return $basenodes; } - - /** - * Custom module construct for feedback - * - * @param settings_navigation $settingsnav The settings navigation object related to the module page - * @param navigation_node|null $rootnode The node where the module navigation nodes should be added into as children. - * If not explicitly defined, the nodes will be added to the secondary root - * node by default. - */ - protected function load_module_navigation(settings_navigation $settingsnav, ?navigation_node $rootnode = null): void { - $rootnode = $rootnode ?? $this; - $mainnode = $settingsnav->find('modulesettings', self::TYPE_SETTING); - $nodes = $this->get_default_module_mapping(); - - if ($mainnode) { - $url = new \moodle_url('/mod/' . $this->page->activityname . '/view.php', ['id' => $this->page->cm->id]); - $setactive = $url->compare($this->page->url, URL_MATCH_BASE); - $node = $rootnode->add(get_string('modulename', 'feedback'), $url, null, null, 'modulepage'); - if ($setactive) { - $node->make_active(); - } - - // Add the initial nodes. - $nodesordered = $this->get_leaf_nodes($mainnode, $nodes); - $this->add_ordered_nodes($nodesordered, $rootnode); - - // Reorder the existing nodes in settings so the active node scan can pick it up. - $existingnode = $settingsnav->find('questionnode', self::TYPE_CUSTOM); - if ($existingnode) { - $node->add_node($existingnode); - $nodes[self::TYPE_CUSTOM] += ['questionnode' => 3]; - } - // We have finished inserting the initial structure. - // Populate the menu with the rest of the nodes available. - $this->load_remaining_nodes($mainnode, $nodes, $rootnode); - } - } } diff --git a/mod/feedback/import.php b/mod/feedback/import.php index 78c19674be9..ff22f90cf4f 100644 --- a/mod/feedback/import.php +++ b/mod/feedback/import.php @@ -39,6 +39,7 @@ if ($action !== false) { $url->param('action', $action); } $PAGE->set_url($url); +navigation_node::override_active_url(new moodle_url('/mod/feedback/edit.php')); if (! $cm = get_coursemodule_from_id('feedback', $id)) { throw new \moodle_exception('invalidcoursemodule'); diff --git a/mod/feedback/lib.php b/mod/feedback/lib.php index 34259d7f375..4726a354998 100644 --- a/mod/feedback/lib.php +++ b/mod/feedback/lib.php @@ -2822,16 +2822,9 @@ function feedback_extend_settings_navigation(settings_navigation $settings, navi } if (has_capability('mod/feedback:edititems', $context)) { - $questionnode = $feedbacknode->add(get_string('questions', 'feedback'), null, + $feedbacknode->add(get_string('questions', 'feedback'), + new moodle_url('/mod/feedback/edit.php', ['id' => $settings->get_page()->cm->id]), navigation_node::TYPE_CUSTOM, null, 'questionnode'); - $questionnode->add(get_string('edit_items', 'feedback'), - new moodle_url('/mod/feedback/edit.php', ['id' => $settings->get_page()->cm->id])); - - $questionnode->add(get_string('export_questions', 'feedback'), - new moodle_url('/mod/feedback/export.php', ['id' => $settings->get_page()->cm->id, 'action' => 'exportfile'])); - - $questionnode->add(get_string('import_questions', 'feedback'), - new moodle_url('/mod/feedback/import.php', ['id' => $settings->get_page()->cm->id])); $feedbacknode->add(get_string('templates', 'feedback'), new moodle_url('/mod/feedback/manage_templates.php', ['id' => $settings->get_page()->cm->id, 'mode' => 'manage']), diff --git a/mod/feedback/manage_templates.php b/mod/feedback/manage_templates.php index 35ced395453..b7f8543f341 100644 --- a/mod/feedback/manage_templates.php +++ b/mod/feedback/manage_templates.php @@ -44,11 +44,6 @@ if ($mode) { $params += ['mode' => $mode]; } $url = new moodle_url('/mod/feedback/manage_templates.php', $params); -if ($mode == 'manage') { - navigation_node::override_active_url($url); -} else { - navigation_node::override_active_url(new moodle_url('/mod/feedback/view.php', $params)); -} $PAGE->set_url($url); $actionbar = new \mod_feedback\output\edit_action_bar($cm->id, $url); diff --git a/mod/feedback/tests/behat/anonymous.feature b/mod/feedback/tests/behat/anonymous.feature index 3e928c4af8e..6b51733df17 100644 --- a/mod/feedback/tests/behat/anonymous.feature +++ b/mod/feedback/tests/behat/anonymous.feature @@ -29,7 +29,7 @@ Feature: Anonymous feedback When I log in as "manager" And I am on site homepage And I follow "Site feedback" - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Multiple choice" question to the feedback with: | Question | Do you like our site? | | Label | multichoice2 | @@ -156,7 +156,7 @@ Feature: Anonymous feedback Scenario: Anonymous feedback in a course # Teacher can not When I am on the "Course feedback" "feedback activity" page logged in as teacher - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Multiple choice" question to the feedback with: | Question | Do you like this course? | | Label | multichoice1 | diff --git a/mod/feedback/tests/behat/coursemapping.feature b/mod/feedback/tests/behat/coursemapping.feature index 5cdd2c7f5c2..daa0157cc64 100644 --- a/mod/feedback/tests/behat/coursemapping.feature +++ b/mod/feedback/tests/behat/coursemapping.feature @@ -43,7 +43,7 @@ Feature: Mapping courses in a feedback When I log in as "manager" And I am on site homepage And I follow "Course feedback" - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Information" question to the feedback with: | Question | this is an information question | | Label | info | @@ -132,7 +132,7 @@ Feature: Mapping courses in a feedback And I log in as "manager" And I am on site homepage And I follow "Course feedback" - And I follow "Mapped courses" + And I navigate to "Mapped courses" in current page administration And I set the field "Courses" to "Course 2, Course 3" And I press "Save changes" And I should see "Course mapping has been changed" diff --git a/mod/feedback/tests/behat/export_import.feature b/mod/feedback/tests/behat/export_import.feature index a01851b13ad..d417a4393b5 100644 --- a/mod/feedback/tests/behat/export_import.feature +++ b/mod/feedback/tests/behat/export_import.feature @@ -23,7 +23,7 @@ Feature: Exporting and importing feedbacks Scenario: Export sample feedback and compare with the fixture When I am on the "Learning experience" "feedback activity" page logged in as teacher - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And "Export questions" "link" should not exist in the ".tertiary-navigation" "css_element" And I add a "Information" question to the feedback with: | Question | this is an information question | @@ -73,7 +73,7 @@ Feature: Exporting and importing feedbacks @javascript @_file_upload Scenario: Import feedback deleting old items When I am on the "Learning experience" "feedback activity" page logged in as teacher - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Numeric answer" question to the feedback with: | Question | Existing question | | Label | numeric | @@ -96,7 +96,7 @@ Feature: Exporting and importing feedbacks @javascript @_file_upload Scenario: Import feedback appending new items When I am on the "Learning experience" "feedback activity" page logged in as teacher - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Numeric answer" question to the feedback with: | Question | Existing question | | Label | numeric | diff --git a/mod/feedback/tests/behat/feedback_activity_completion.feature b/mod/feedback/tests/behat/feedback_activity_completion.feature index cc3a3a3523a..50de075f47c 100644 --- a/mod/feedback/tests/behat/feedback_activity_completion.feature +++ b/mod/feedback/tests/behat/feedback_activity_completion.feature @@ -26,7 +26,7 @@ Feature: View activity completion in the feedback activity | completionview | 1 | | completionsubmit | 1 | And I am on the "Music history" "feedback activity" page logged in as teacher1 - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Multiple choice" question to the feedback with: | Question | What is your favourite instrument | | Label | instrument1 | diff --git a/mod/feedback/tests/behat/multichoice.feature b/mod/feedback/tests/behat/multichoice.feature index b2b1c4c8b7c..efb30b675d9 100644 --- a/mod/feedback/tests/behat/multichoice.feature +++ b/mod/feedback/tests/behat/multichoice.feature @@ -22,7 +22,7 @@ Feature: Testing multichoice questions in feedback | activity | name | course | idnumber | | feedback | Learning experience | C1 | feedback0 | And I am on the "Learning experience" "feedback activity" page logged in as teacher1 - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration @javascript Scenario: Non-rated single-answer multiple choice questions in feedback @@ -150,7 +150,7 @@ Feature: Testing multichoice questions in feedback And I should see "1 (100.00 %)" in the "option i" "table_row" # Change the settings so we don't analyse empty submits And I am on the "Learning experience" "feedback activity" page - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I open the action menu in "//div[contains(@class, 'feedback_itemlist') and contains(.,'multichoice1')]" "xpath_element" And I choose "Edit question" in the open action menu And I set the field "Omit empty submits in analysis" to "Yes" @@ -290,7 +290,7 @@ Feature: Testing multichoice questions in feedback And I should see "1 (100.00 %)" in the "option i" "table_row" # Change the settings so we don't analyse empty submits And I am on the "Learning experience" "feedback activity" page - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I open the action menu in "//div[contains(@class, 'feedback_itemlist') and contains(.,'multichoice1')]" "xpath_element" And I choose "Edit question" in the open action menu And I set the field "Omit empty submits in analysis" to "Yes" @@ -409,7 +409,7 @@ Feature: Testing multichoice questions in feedback And I should see "1 (100.00 %)" in the "option i" "table_row" # Change the settings so we don't analyse empty submits And I am on the "Learning experience" "feedback activity" page - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I open the action menu in "//div[contains(@class, 'feedback_itemlist') and contains(.,'multichoice1')]" "xpath_element" And I choose "Edit question" in the open action menu And I set the field "Omit empty submits in analysis" to "Yes" diff --git a/mod/feedback/tests/behat/multipleattempt.feature b/mod/feedback/tests/behat/multipleattempt.feature index 1dda2499184..8c933412a25 100644 --- a/mod/feedback/tests/behat/multipleattempt.feature +++ b/mod/feedback/tests/behat/multipleattempt.feature @@ -27,7 +27,7 @@ Feature: Non anonymous feedback with multiple submissions When I log in as "teacher" And I am on "Course 1" course homepage And I follow "Course feedback" - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Short text answer" question to the feedback with: | Question | first | | Label | shorttext1 | diff --git a/mod/feedback/tests/behat/non_anonymous.feature b/mod/feedback/tests/behat/non_anonymous.feature index c5fecc45bd8..813c8bba606 100644 --- a/mod/feedback/tests/behat/non_anonymous.feature +++ b/mod/feedback/tests/behat/non_anonymous.feature @@ -27,7 +27,7 @@ Feature: Non anonymous feedback | feedback | Site feedback | Acceptance test site | feedback0 | 2 | 1 | 1 | | feedback | Course feedback | C1 | feedback1 | 2 | 1 | 0 | When I am on the "Site feedback" "feedback activity" page logged in as manager - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Multiple choice" question to the feedback with: | Question | Do you like our site? | | Label | multichoice2 | @@ -91,7 +91,7 @@ Feature: Non anonymous feedback @javascript Scenario: Non anonymous feedback in a course When I am on the "Course feedback" "feedback activity" page logged in as teacher - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Multiple choice" question to the feedback with: | Question | Do you like this course? | | Label | multichoice1 | diff --git a/mod/feedback/tests/behat/preview_questions.feature b/mod/feedback/tests/behat/preview_questions.feature index ac9b7fa5d6b..6fdb33bf589 100644 --- a/mod/feedback/tests/behat/preview_questions.feature +++ b/mod/feedback/tests/behat/preview_questions.feature @@ -22,7 +22,7 @@ Feature: Preview feedback questions | activity | name | course | idnumber | | feedback | Music history | C1 | feedback0 | And I am on the "Music history" "feedback activity" page logged in as editingteacher - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Multiple choice" question to the feedback with: | Question | What is your favourite instrument | | Label | instrument1 | diff --git a/mod/feedback/tests/behat/question_types.feature b/mod/feedback/tests/behat/question_types.feature index 7bf219fe720..078113449f4 100644 --- a/mod/feedback/tests/behat/question_types.feature +++ b/mod/feedback/tests/behat/question_types.feature @@ -23,7 +23,7 @@ Feature: Test creating different types of feedback questions for anonymous feedb | activity | name | course | idnumber | | feedback | Learning experience | C1 | feedback0 | When I am on the "Learning experience" "feedback activity" page logged in as teacher1 - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Information" question to the feedback with: | Question | this is an information question | | Label | info | diff --git a/mod/feedback/tests/behat/question_types_non_anon.feature b/mod/feedback/tests/behat/question_types_non_anon.feature index c9bf90ba5d7..8e169c6c315 100644 --- a/mod/feedback/tests/behat/question_types_non_anon.feature +++ b/mod/feedback/tests/behat/question_types_non_anon.feature @@ -23,7 +23,7 @@ Feature: Test creating different types of feedback questions for non-anonymous f | activity | name | course | idnumber | anonymous | | feedback | Learning experience | C1 | feedback0 | 2 | When I am on the "Learning experience" "feedback activity" page logged in as teacher1 - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Information" question to the feedback with: | Question | this is an information question | | Label | info | diff --git a/mod/feedback/tests/behat/show_nonrespondents.feature b/mod/feedback/tests/behat/show_nonrespondents.feature index 00902ed44c2..aefaef9e770 100644 --- a/mod/feedback/tests/behat/show_nonrespondents.feature +++ b/mod/feedback/tests/behat/show_nonrespondents.feature @@ -43,7 +43,7 @@ Feature: Show users who have not responded to the feedback survey | Record user names | User's name will be logged and shown with answers | | Access restrictions | Grouping: GX1 | And I am on the Frogs "feedback activity" page - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Short text answer" question to the feedback with: | Question | Y/N? | And I log out diff --git a/mod/feedback/tests/behat/templates.feature b/mod/feedback/tests/behat/templates.feature index 5965efc78b4..e8633d9b30c 100644 --- a/mod/feedback/tests/behat/templates.feature +++ b/mod/feedback/tests/behat/templates.feature @@ -26,7 +26,7 @@ Feature: Saving, using and deleting feedback templates | feedback | Another feedback in course 1 | C1 | feedback2 | | feedback | Learning experience course 2 | C2 | feedback3 | And I am on the "Learning experience course 1" "feedback activity" page logged in as teacher - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Multiple choice" question to the feedback with: | Question | this is a multiple choice 1 | | Label | multichoice1 | @@ -38,7 +38,7 @@ Feature: Saving, using and deleting feedback templates Scenario: Teacher can save template and re-use it in the same course only # Go to feedback templates and make sure none exist yet When I am on the "Learning experience course 1" "feedback activity" page logged in as teacher - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I select "Use a template" from the "jump" singleselect Then I should see "No templates available yet" And "Use a template" "field" should not exist @@ -55,7 +55,7 @@ Feature: Saving, using and deleting feedback templates And I should see "My first template" # Create a feedback from this template in the same course And I am on the "Another feedback in course 1" "feedback activity" page - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I select "Use a template" from the "jump" singleselect And I follow "My first template" And I should see "this is a multiple choice 1" @@ -64,7 +64,7 @@ Feature: Saving, using and deleting feedback templates And I should see "this is a multiple choice 1" # Make sure this template is not available in another course And I am on the "Learning experience course 2" "feedback activity" page - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I select "Use a template" from the "jump" singleselect And I should see "No templates available yet" And I log out @@ -73,7 +73,7 @@ Feature: Saving, using and deleting feedback templates Scenario: Teacher can append template to existing questions or remove them # Save feedback as a course template When I am on the "Learning experience course 1" "feedback activity" page logged in as teacher - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I press "Save as new template" And I should see "Save as new template" in the ".modal-title" "css_element" And I should see "Name" in the ".modal-body" "css_element" @@ -82,7 +82,7 @@ Feature: Saving, using and deleting feedback templates And I press "Save as new template" # Add questions to another feedback And I am on the "Another feedback in course 1" "feedback activity" page - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I add a "Multiple choice" question to the feedback with: | Question | What is your favourite subject | | Label | subjectchoice | @@ -108,14 +108,14 @@ Feature: Saving, using and deleting feedback templates @javascript Scenario: Manager can save template as public and it will be available in any course When I am on the "Learning experience course 1" "feedback activity" page logged in as manager - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I press "Save as new template" And I set the field "Name" to "My first template" And I set the field "Public" to "1" And I click on "Save" "button" in the ".modal-dialog" "css_element" And I log out And I am on the "Learning experience course 2" "feedback activity" page logged in as teacher - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I select "Use a template" from the "jump" singleselect And I follow "My first template" And I should see "this is a multiple choice 1" @@ -129,7 +129,7 @@ Feature: Saving, using and deleting feedback templates Scenario: Teacher can delete course templates but can not delete public templates # Save feedback as both public and course template When I am on the "Learning experience course 1" "feedback activity" page logged in as manager - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I press "Save as new template" And I set the field "Name" to "My public template" And I set the field "Public" to "1" @@ -140,7 +140,7 @@ Feature: Saving, using and deleting feedback templates And I log out # Login as teacher and try to delete templates And I am on the "Another feedback in course 1" "feedback activity" page logged in as teacher - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I select "Use a template" from the "jump" singleselect And I follow "My public template" Then I should not see "Delete" @@ -158,7 +158,7 @@ Feature: Saving, using and deleting feedback templates Scenario: Manager can delete both course and public templates # Save feedback as both public and course template When I am on the "Learning experience course 1" "feedback activity" page logged in as manager - And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And I navigate to "Questions" in current page administration And I press "Save as new template" And I set the field "Name" to "My public template" And I set the field "Public" to "1" diff --git a/mod/feedback/use_templ.php b/mod/feedback/use_templ.php index 02eedbe6107..c835721c6cb 100644 --- a/mod/feedback/use_templ.php +++ b/mod/feedback/use_templ.php @@ -55,12 +55,6 @@ $params += ($mode ? ['mode' => $mode] : []); $activeurl = new moodle_url('/mod/feedback/manage_templates.php', $params); $PAGE->set_url($activeurl); -if ($mode == 'manage') { - navigation_node::override_active_url($activeurl); -} else { - navigation_node::override_active_url(new moodle_url('/mod/feedback/view.php', $params)); -} - $PAGE->set_heading($course->fullname); $PAGE->set_title($feedback->name); $PAGE->activityheader->set_attrs([