Skip to content

Commit

Permalink
Merge branch 'MDL-71141-master' of git://github.com/ferranrecio/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed Apr 29, 2021
2 parents af1d676 + 6ae566c commit e17333c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
4 changes: 3 additions & 1 deletion course/classes/output/section_format/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ public function export_for_template(\renderer_base $output): stdClass {
$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);
}
Expand Down
8 changes: 7 additions & 1 deletion course/format/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

/**
Expand Down
45 changes: 45 additions & 0 deletions course/tests/behat/frontpage_topic_section.feature
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit e17333c

Please sign in to comment.