diff --git a/blocks/section_links/lang/en/block_section_links.php b/blocks/section_links/lang/en/block_section_links.php index adb679bac4b..ebdcd6d647b 100644 --- a/blocks/section_links/lang/en/block_section_links.php +++ b/blocks/section_links/lang/en/block_section_links.php @@ -35,5 +35,5 @@ $string['numsections2_help'] = 'Once the number of sections in the course reache $string['pluginname'] = 'Section links'; $string['section_links:addinstance'] = 'Add a new section links block'; $string['showsectionname'] = 'Display section name'; -$string['showsectionname_help'] = 'Display section name in addition to section number'; +$string['showsectionname_help'] = 'If set to "yes", only the section name is shown, if set to "no", only the section number is shown.'; $string['privacy:metadata'] = 'The Section links block only shows data stored in other locations.'; diff --git a/blocks/section_links/renderer.php b/blocks/section_links/renderer.php index 632a37a2ccb..4b625a0851a 100644 --- a/blocks/section_links/renderer.php +++ b/blocks/section_links/renderer.php @@ -43,16 +43,17 @@ class block_section_links_renderer extends plugin_renderer_base { */ public function render_section_links(stdClass $course, array $sections, $jumptosection = false, $showsectionname = false) { $olparams = $showsectionname ? ['class' => 'unlist'] : ['class' => 'inline-list']; + $liparams = $showsectionname ? ['class' => 'mb-2'] : []; $html = html_writer::start_tag('ol', $olparams); foreach ($sections as $section) { $attributes = array(); if (!$section->visible) { $attributes['class'] = 'dimmed'; } - $html .= html_writer::start_tag('li'); + $html .= html_writer::start_tag('li', $liparams); $sectiontext = $section->section; if ($showsectionname) { - $sectiontext .= ': ' . $section->name; + $sectiontext = $section->name; } if ($section->highlight) { $sectiontext = html_writer::tag('strong', $sectiontext); diff --git a/blocks/section_links/settings.php b/blocks/section_links/settings.php index ef18237c5d0..cf7f5bf223b 100644 --- a/blocks/section_links/settings.php +++ b/blocks/section_links/settings.php @@ -49,8 +49,10 @@ if ($ADMIN->fulltree) { $selected[$i][1], $increments)); } - $settings->add(new admin_setting_configcheckbox('block_section_links/showsectionname', + $settings->add( + new admin_setting_configcheckbox('block_section_links/showsectionname', get_string('showsectionname', 'block_section_links'), get_string('showsectionname_help', 'block_section_links'), - 0)); -} \ No newline at end of file + 1), + ); +} diff --git a/blocks/section_links/tests/behat/block_section_links_course.feature b/blocks/section_links/tests/behat/block_section_links_course.feature index d495dedeca6..76cad1c464b 100644 --- a/blocks/section_links/tests/behat/block_section_links_course.feature +++ b/blocks/section_links/tests/behat/block_section_links_course.feature @@ -17,22 +17,21 @@ Feature: The section links block allows users to quickly navigate around a moodl And the following "activities" exist: | activity | name | intro | course | section | idnumber | assignsubmission_file_enabled | | assign | Test assignment 1 | Offline text | C1 | 5 | assign1 | 0 | + And the following config values are set as admin: + | showsectionname | 0 | block_section_links | + | unaddableblocks | | theme_boost | And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on Scenario: Add the section links block to a course. - Given the following config values are set as admin: - | unaddableblocks | | theme_boost| - And I add the "Section links" block + Given I add the "Section links" block And I turn editing mode off And I should see "5" in the "Section links" "block" When I follow "5" Then I should see "Test assignment 1" Scenario: Add the section links block to a course and limit the sections displayed. - Given the following config values are set as admin: - | unaddableblocks | | theme_boost| - And I add the "Section links" block + Given I add the "Section links" block And I configure the "Section links" block And I set the following fields to these values: | config_numsections1 | 5 | @@ -46,9 +45,7 @@ Feature: The section links block allows users to quickly navigate around a moodl Then I should see "Test assignment 1" Scenario: Add the section links block to a course and limit the sections displayed using the alternative number of sections. - Given the following config values are set as admin: - | unaddableblocks | | theme_boost| - And I add the "Section links" block + Given I add the "Section links" block And I configure the "Section links" block And I set the following fields to these values: | config_numsections1 | 5 | diff --git a/blocks/section_links/tests/behat/show_section_name.feature b/blocks/section_links/tests/behat/show_section_name.feature index e78fb49efcd..de80fdbbceb 100644 --- a/blocks/section_links/tests/behat/show_section_name.feature +++ b/blocks/section_links/tests/behat/show_section_name.feature @@ -29,8 +29,9 @@ Feature: The Section links block can be configured to display section name in ad Scenario: Student can see section name under the Section links block When I am on the "Course 1" course page logged in as student1 - Then I should see "7: Section 7" in the "Section links" "block" - And I follow "7: Section 7" + Then I should see "Section 7" in the "Section links" "block" + And I should not see "7: Section 7" in the "Section links" "block" + And I follow "Section 7" And I should see "First assignment" Scenario: Teacher can configure existing Section links block to display section number or section name @@ -41,6 +42,7 @@ Feature: The Section links block can be configured to display section name in ad | Display section name | No | And I click on "Save changes" "button" Then I should not see "7: Section 7" in the "Section links" "block" + And I should not see "Section 7" in the "Section links" "block" And I should see "7" in the "Section links" "block" And I follow "7" And I should see "First assignment" diff --git a/course/tests/behat/course_controls.feature b/course/tests/behat/course_controls.feature index ca761481434..9fe14b83f39 100644 --- a/course/tests/behat/course_controls.feature +++ b/course/tests/behat/course_controls.feature @@ -70,7 +70,8 @@ Feature: Course activity controls works as expected And I am on the "C1 > Section 1" "course > section" page And "section" should not exist And the following config values are set as admin: - | unaddableblocks | | theme_boost| + | showsectionname | 0 | block_section_links | + | unaddableblocks | | theme_boost | And I add the "Section links" block And "section" should not exist And I should see "1 2 3 4 5" in the "Section links" "block" @@ -135,7 +136,8 @@ Feature: Course activity controls works as expected And I show section "1" And section "1" should be visible And the following config values are set as admin: - | unaddableblocks | | theme_boost| + | showsectionname | 0 | block_section_links | + | unaddableblocks | | theme_boost | And I add the "Section links" block And I should see "1 2 3 4 5" in the "Section links" "block" And I click on "2" "link" in the "Section links" "block"