MDL-71141 course: fix frontpage section warning

This commit is contained in:
Ferran Recio
2021-04-12 12:41:10 +02:00
parent 18aafd0ed4
commit 6ae566c55d
3 changed files with 55 additions and 2 deletions
@@ -89,7 +89,9 @@ class header implements renderable, templatable {
$data->ishidden = true;
}
if (!$format->show_editor() && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE && empty($data->issinglesection)) {
$coursedisplay = $course->coursedisplay ?? COURSE_DISPLAY_SINGLEPAGE;
if (!$format->show_editor() && $coursedisplay == COURSE_DISPLAY_MULTIPAGE && empty($data->issinglesection)) {
$data->url = course_get_url($course, $section->section);
$data->name = get_section_name($course, $section);
}
+7 -1
View File
@@ -53,7 +53,13 @@ class format_site extends course_format {
* @return Display name that the course format prefers, e.g. "Topic 2"
*/
function get_section_name($section) {
return get_string('site');
$section = $this->get_section($section);
if ((string)$section->name !== '') {
// Return the name the user set.
return format_string($section->name, true, array('context' => context_course::instance($this->courseid)));
} else {
return get_string('site');
}
}
/**
@@ -0,0 +1,45 @@
@core @core_course
Feature: Front page topic section
In order to show a display activities in the frontpage
As an admin
I need to edit the frontpage topic section
Background:
Given the following config values are set as admin:
| numsections | 1 |
Scenario: Activities should appear in frontpage
Given the following "activities" exist:
| activity | course | section | name | intro | idnumber |
| assign | Acceptance test site | 1 | Frontpage assignment | Assignment description | assign0 |
When I log in as "admin"
And I am on site homepage
Then I should see "Frontpage assignment" in the "region-main" "region"
@javascript
Scenario: Topic name does appears in frontpage
Given the following "activities" exist:
| activity | course | section | name | intro | idnumber |
| assign | Acceptance test site | 1 | Frontpage assignment | Assignment description | assign0 |
And I log in as "admin"
And I am on site homepage
And I navigate to "Turn editing on" in current page administration
And I click on "Edit summary" "link" in the "region-main" "region"
And I click on "Custom" "checkbox"
And I set the field "New value for Section name" to "New section name"
When I press "Save changes"
And I should see "New section name" in the "region-main" "region"
Then I navigate to "Turn editing off" in current page administration
And I should see "New section name" in the "region-main" "region"
@javascript
Scenario: Topic description appears in the frontpage
Given I log in as "admin"
And I am on site homepage
And I navigate to "Turn editing on" in current page administration
And I click on "Edit summary" "link" in the "region-main" "region"
And I set the field "Summary" to "New section description"
When I press "Save changes"
And I should see "New section description" in the "region-main" "region"
Then I navigate to "Turn editing off" in current page administration
And I should see "New section description" in the "region-main" "region"