mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
MDL-84940 block_section_links: omit subsections
This commit is contained in:
parent
d15172627c
commit
65f0345ec7
@ -111,7 +111,7 @@ class block_section_links extends block_base {
|
||||
$showsectionname = !empty($config->showsectionname) ? true : false;
|
||||
|
||||
// Prepare an array of sections to create links for.
|
||||
$sections = array();
|
||||
$sections = [];
|
||||
$canviewhidden = has_capability('moodle/course:update', $context);
|
||||
$coursesections = $courseformat->get_sections();
|
||||
$coursesectionscount = count($coursesections);
|
||||
@ -121,12 +121,16 @@ class block_section_links extends block_base {
|
||||
continue;
|
||||
}
|
||||
$section = $coursesections[$i];
|
||||
// Delegated sections (like subsections) are not listed in the block.
|
||||
if ($section->get_component_instance() !== null) {
|
||||
continue;
|
||||
}
|
||||
if ($section->section && ($section->visible || $canviewhidden)) {
|
||||
$sections[$i] = (object)array(
|
||||
$sections[$i] = (object) [
|
||||
'section' => $section->section,
|
||||
'visible' => $section->visible,
|
||||
'highlight' => false
|
||||
);
|
||||
];
|
||||
if ($courseformat->is_section_current($section)) {
|
||||
$sections[$i]->highlight = true;
|
||||
$sectiontojumpto = $section->section;
|
||||
|
@ -60,3 +60,17 @@ Feature: The section links block allows users to quickly navigate around a moodl
|
||||
And I should see "5" in the "Section links" "block"
|
||||
When I follow "5"
|
||||
Then I should see "Test assignment 1"
|
||||
|
||||
Scenario: Subsections numbers are not displayed in the Section links block
|
||||
Given I enable "subsection" "mod" plugin
|
||||
And the following "activity" exists:
|
||||
| activity | subsection |
|
||||
| name | Subsection1 |
|
||||
| course | C1 |
|
||||
| idnumber | subsection1 |
|
||||
| section | 1 |
|
||||
And the following "blocks" exist:
|
||||
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
|
||||
| section_links | Course | C1 | course-view-* | side-pre |
|
||||
When I am on "Course 1" course homepage
|
||||
Then "21" "link" should not exist in the "Section links" "block"
|
||||
|
@ -44,3 +44,14 @@ Feature: The Section links block can be configured to display section name in ad
|
||||
And I should see "7" in the "Section links" "block"
|
||||
And I follow "7"
|
||||
And I should see "First assignment"
|
||||
|
||||
Scenario: Subsections names are not displayed in the Section links block
|
||||
Given I enable "subsection" "mod" plugin
|
||||
And the following "activity" exists:
|
||||
| activity | subsection |
|
||||
| name | Subsection1 |
|
||||
| course | C1 |
|
||||
| idnumber | subsection1 |
|
||||
| section | 1 |
|
||||
When I am on the "Course 1" course page logged in as student1
|
||||
Then I should not see "Subsection1" in the "Section links" "block"
|
||||
|
Loading…
x
Reference in New Issue
Block a user