diff --git a/public/course/format/classes/output/local/overview/activityname.php b/public/course/format/classes/output/local/overview/activityname.php index 9d3ab8c9c8e..103f7595315 100644 --- a/public/course/format/classes/output/local/overview/activityname.php +++ b/public/course/format/classes/output/local/overview/activityname.php @@ -76,7 +76,7 @@ class activityname implements externable, named_templatable, renderable { 'stealth' => $cm->is_stealth(), 'nogroupserror' => $this->nogroupserror, ]; - if ($format->uses_sections()) { + if ($format->uses_sections() && $section->uservisible) { $result->sectiontitle = $format->get_section_name($section); } return $result; diff --git a/public/course/tests/behat/course_overview.feature b/public/course/tests/behat/course_overview.feature index e64d498cea8..043b44a911d 100644 --- a/public/course/tests/behat/course_overview.feature +++ b/public/course/tests/behat/course_overview.feature @@ -349,3 +349,18 @@ Feature: Users can access the course activities overview page And I am on the "Course 1" "course > activities > assign" page logged in as "student1" And I should not see "-" in the "Test assignment name" "table_row" And I should see "-" in the "Not gradable" "table_row" + + @javascript + Scenario: Hidden section name is not shown in the activity overview for students + Given I log in as "teacher1" + And I am on "Course 1" course homepage with editing mode on + And I hide section "1" + # Make stealth the activity to guarantee the students can see it. + And I open "Test assignment name" actions menu + And I choose "Availability > Make available but don't show on course page" in the open action menu + # Teacher should see the section name. + When I am on the "Course 1" "course > activities > assign" page + Then I should see "Section 1" in the "Test assignment name" "table_row" + # Student should not see the section name. + But I am on the "Course 1" "course > activities > assign" page logged in as "student1" + And I should not see "Section 1" in the "Test assignment name" "table_row"