diff --git a/course/format/classes/output/local/content/section/visibility.php b/course/format/classes/output/local/content/section/visibility.php index 0d0cc6ba370..ecac3a61ab0 100644 --- a/course/format/classes/output/local/content/section/visibility.php +++ b/course/format/classes/output/local/content/section/visibility.php @@ -104,7 +104,15 @@ class visibility implements named_templatable, renderable { private function get_option_data(string $name, string $action): array { $baseurl = course_get_url($this->section->course, $this->section); $baseurl->param('sesskey', sesskey()); - $baseurl->param($action, $this->section->section); + $baseurl->param($name, $this->section->section); + + // The section page is not yet fully reactive and it needs to use the old non-ajax links. + $pagesectionid = $this->format->get_sectionid(); + if ($this->section->id == $pagesectionid) { + $baseurl->param('sectionid', $pagesectionid); + $action = ''; + } + return [ 'description' => get_string("availability_{$name}_help", 'core_courseformat'), 'icon' => $this->get_icon($name), diff --git a/course/format/tests/behat/section_visibility.feature b/course/format/tests/behat/section_visibility.feature index 316f895d11c..5574b975ae8 100644 --- a/course/format/tests/behat/section_visibility.feature +++ b/course/format/tests/behat/section_visibility.feature @@ -81,3 +81,16 @@ Feature: Varify section visibility interface And I log out And I am on the "C2" "Course" page logged in as "teacher1" And I should see "Hidden from students" in the "Section 1" "section" + + @javascript + Scenario: The visibility badge can show a hidden section in a the section page + Given I hide section "1" + When I am on the "C1 > Section 1" "course > section" page + And I click on "Hidden from students" "button" in the "[data-region='sectionbadges']" "css_element" + And I should see "Show on course page" in the "[data-region='sectionbadges']" "css_element" + And I should see "Hide on course page" in the "[data-region='sectionbadges']" "css_element" + And I click on "Show on course page" "link" in the "[data-region='sectionbadges']" "css_element" + Then I should not see "Hidden from students" in the "[data-region='sectionbadges']" "css_element" + And I open the action menu in "page-header" "region" + And I choose "Hide" in the open action menu + And I should see "Hidden from students" in the "[data-region='sectionbadges']" "css_element"