Skip to content

Commit

Permalink
MDL-71912 mod_choice: Small alteration to show responses.
Browse files Browse the repository at this point in the history
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 <sujith@moodle.com>
  • Loading branch information
abgreeve and sharidas committed Nov 9, 2021
1 parent b72fa5f commit c4c00f4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 27 deletions.
4 changes: 3 additions & 1 deletion mod/choice/report.php
Expand Up @@ -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) {
Expand Down
32 changes: 13 additions & 19 deletions mod/choice/tests/behat/include_inactive.feature
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions mod/choice/tests/behat/multiple_options.feature
Expand Up @@ -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
Expand All @@ -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
6 changes: 3 additions & 3 deletions mod/choice/tests/behat/remove_choice_options.feature
Expand Up @@ -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"
6 changes: 4 additions & 2 deletions mod/choice/view.php
Expand Up @@ -98,7 +98,9 @@
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);
Expand Down Expand Up @@ -132,7 +134,7 @@
$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);
}

Expand Down

0 comments on commit c4c00f4

Please sign in to comment.