MDL-81575 core_courseformat: fix interactive section visibility badge

This commit is contained in:
ferranrecio 2024-04-17 13:19:49 +02:00 committed by Jun Pataleta
parent 49b666b670
commit 0e70a88d03
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
2 changed files with 22 additions and 1 deletions

View File

@ -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),

View File

@ -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"