mirror of
https://github.com/moodle/moodle.git
synced 2025-05-31 21:19:49 +02:00
MDL-82555 block_section_links: Add section title only setting.
This commit is contained in:
parent
89d76fdc25
commit
64f7cf32e5
@ -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.';
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
1),
|
||||
);
|
||||
}
|
||||
|
@ -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 |
|
||||
|
@ -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"
|
||||
|
@ -70,7 +70,8 @@ Feature: Course activity controls works as expected
|
||||
And I am on the "C1 > Section 1" "course > section" page
|
||||
And <belowpage> "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 <belowpage> "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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user