From c4c00f4e695ce9e5d8586cefa65fb9aee965917f Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Tue, 13 Jul 2021 15:47:23 +0800 Subject: [PATCH] MDL-71912 mod_choice: Small alteration to show responses. Depending on whether the secondary navigation is shown or not will determine if the link to the responses is shown on the view.php page. Co-authored-by: Sujith Haridasan --- mod/choice/report.php | 4 ++- .../tests/behat/include_inactive.feature | 32 ++++++++----------- .../tests/behat/multiple_options.feature | 4 +-- .../tests/behat/remove_choice_options.feature | 6 ++-- mod/choice/view.php | 6 ++-- 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/mod/choice/report.php b/mod/choice/report.php index 664a0e28da0..4cb1d18550a 100644 --- a/mod/choice/report.php +++ b/mod/choice/report.php @@ -68,7 +68,9 @@ $PAGE->set_title(format_string($choice->name).": $strresponses"); $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); - echo $OUTPUT->heading(format_string($choice->name), 2, null); + if (!$PAGE->has_secondary_navigation()) { + echo $OUTPUT->heading(format_string($choice->name), 2, null); + } /// Check to see if groups are being used in this choice $groupmode = groups_get_activity_groupmode($cm); if ($groupmode) { diff --git a/mod/choice/tests/behat/include_inactive.feature b/mod/choice/tests/behat/include_inactive.feature index b69b54ee329..2adf7113099 100644 --- a/mod/choice/tests/behat/include_inactive.feature +++ b/mod/choice/tests/behat/include_inactive.feature @@ -48,10 +48,9 @@ Feature: Include responses from inactive users | student1 | C1 | student | 1 | When I log in as "teacher1" And I am on "Course 1" course homepage - And I follow "Choice name" - Then I should see "View 3 responses" - And I follow "View 3 responses" - And I should see "Student 1" + And I click on "Choice name" "link" in the "region-main" "region" + And I navigate to "Responses" in current page administration + Then I should see "Student 1" And I should see "Student 2" And I should see "Student 3" And I log out @@ -60,9 +59,8 @@ Feature: Include responses from inactive users | student2 | C1 | student | 2145830400 | When I log in as "teacher1" And I am on "Course 1" course homepage - And I follow "Choice name" - Then I should see "View 3 responses" - And I follow "View 3 responses" + And I click on "Choice name" "link" in the "region-main" "region" + Then I navigate to "Responses" in current page administration And I should see "Student 1" And I should see "Student 2" And I should see "Student 3" @@ -72,9 +70,8 @@ Feature: Include responses from inactive users | student3 | C1 | student | 1425168000 | When I log in as "teacher1" And I am on "Course 1" course homepage - And I follow "Choice name" - Then I should see "View 3 responses" - And I follow "View 3 responses" + And I click on "Choice name" "link" in the "region-main" "region" + Then I navigate to "Responses" in current page administration And I should see "Student 1" And I should see "Student 2" And I should see "Student 3" @@ -107,9 +104,8 @@ Feature: Include responses from inactive users | student1 | C1 | student | 1 | When I log in as "teacher1" And I am on "Course 1" course homepage - And I follow "Choice name" - Then I should see "View 2 responses" - And I follow "View 2 responses" + And I click on "Choice name" "link" in the "region-main" "region" + Then I navigate to "Responses" in current page administration And I should not see "Student 1" And I should see "Student 2" And I should see "Student 3" @@ -119,9 +115,8 @@ Feature: Include responses from inactive users | student2 | C1 | student | 2145830400 | When I log in as "teacher1" And I am on "Course 1" course homepage - And I follow "Choice name" - Then I should see "View 1 responses" - And I follow "View 1 responses" + And I click on "Choice name" "link" in the "region-main" "region" + Then I navigate to "Responses" in current page administration And I should not see "Student 1" And I should not see "Student 2" And I should see "Student 3" @@ -131,9 +126,8 @@ Feature: Include responses from inactive users | student3 | C1 | student | 1425168000 | When I log in as "teacher1" And I am on "Course 1" course homepage - And I follow "Choice name" - Then I should see "View 0 responses" - And I follow "View 0 responses" + And I click on "Choice name" "link" in the "region-main" "region" + Then I navigate to "Responses" in current page administration And I should not see "Student 1" And I should not see "Student 2" And I should not see "Student 3" diff --git a/mod/choice/tests/behat/multiple_options.feature b/mod/choice/tests/behat/multiple_options.feature index 3d4ae67ce56..befa5e18798 100644 --- a/mod/choice/tests/behat/multiple_options.feature +++ b/mod/choice/tests/behat/multiple_options.feature @@ -72,7 +72,7 @@ Feature: Multiple option choice response And I log in as "teacher1" And I am on "Course 1" course homepage And I follow "Choice name" - And I follow "View 1 responses" + And I navigate to "Responses" in current page administration Then I should see "Option 1 (Full)" And I should see "Limit: 1" And I am on "Course 1" course homepage with editing mode on @@ -83,6 +83,6 @@ Feature: Multiple option choice response And I press "Save and return to course" And I am on "Course 1" course homepage And I follow "Choice name" - And I follow "View 1 responses" + And I navigate to "Responses" in current page administration Then I should not see "Limit: 1" And I log out diff --git a/mod/choice/tests/behat/remove_choice_options.feature b/mod/choice/tests/behat/remove_choice_options.feature index 1e9fdebdc9b..407a48ebf9e 100644 --- a/mod/choice/tests/behat/remove_choice_options.feature +++ b/mod/choice/tests/behat/remove_choice_options.feature @@ -35,9 +35,9 @@ Feature: Update a choice activity removing options And I log out When I log in as "teacher1" And I am on "Course 1" course homepage - And I follow "Choice name" - And I should see "View 2 responses" + And I click on "Choice name" "link" in the "region-main" "region" And I navigate to "Settings" in current page administration And I set the field "option[2]" to "" And I press "Save and display" - Then I should see "View 1 responses" + Then I navigate to "Responses" in current page administration + And I should see "1" in the "Number of responses" "table_row" diff --git a/mod/choice/view.php b/mod/choice/view.php index 271a6b1bf2b..7a5a9f25d0b 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -98,7 +98,9 @@ if (data_submitted() && !empty($action) && confirm_sesskey()) { choice_view($choice, $course, $cm, $context); echo $OUTPUT->header(); -echo $OUTPUT->heading(format_string($choice->name), 2, null); +if (!$PAGE->has_secondary_navigation()) { + echo $OUTPUT->heading(format_string($choice->name), 2, null); +} // Render the activity information. $completiondetails = \core_completion\cm_completion_details::get_instance($cm, $USER->id); @@ -132,7 +134,7 @@ $onlyactive = $choice->includeinactive ? false : true; $allresponses = choice_get_response_data($choice, $cm, $groupmode, $onlyactive); // Big function, approx 6 SQL calls per user. -if (has_capability('mod/choice:readresponses', $context)) { +if (has_capability('mod/choice:readresponses', $context) && !$PAGE->has_secondary_navigation()) { choice_show_reportlink($allresponses, $cm); }