diff --git a/course/classes/output/activitychooserbutton.php b/course/classes/output/activitychooserbutton.php index 93168d33b19..1255dbc6be4 100644 --- a/course/classes/output/activitychooserbutton.php +++ b/course/classes/output/activitychooserbutton.php @@ -48,7 +48,7 @@ class activitychooserbutton implements templatable, renderable { protected section_info $section, /** @var cm_info|null the course module instance */ protected ?cm_info $mod = null, - /** @var sectionreturn|null the section to return to */ + /** @var int|null the section to return to */ protected ?int $sectionreturn = null, /** @var array|null action_link[] the action links */ protected ?array $actionlinks = [], @@ -73,6 +73,7 @@ class activitychooserbutton implements templatable, renderable { return (object)[ 'sectionnum' => $this->section->section, + 'sectionname' => get_section_name($this->section->course, $this->section), 'sectionreturn' => $this->sectionreturn ?? false, 'modid' => $this->mod ? $this->mod->id : false, 'activityname' => $this->mod ? $this->mod->get_formatted_name() : false, diff --git a/course/lib.php b/course/lib.php index c7b3c203916..43b88281d8e 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1735,7 +1735,7 @@ function move_courses($courseids, $categoryid) { * @see core_courseformat\base::get_section_name() * * @param int|stdClass $courseorid The course to get the section name for (object or just course id) - * @param int|stdClass $section Section object from database or just field course_sections.section + * @param int|stdClass|section_info $section Section object from database or just field course_sections.section * @return string Display name that the course format prefers, e.g. "Week 2" */ function get_section_name($courseorid, $section) { diff --git a/course/templates/activitychooserbutton.mustache b/course/templates/activitychooserbutton.mustache index 3616101f0a5..577875c5a49 100644 --- a/course/templates/activitychooserbutton.mustache +++ b/course/templates/activitychooserbutton.mustache @@ -23,6 +23,7 @@ { "hasactionlinks": false, "sectionnum": 0, + "sectionname": "Section example", "modid": 1, "activityname": "Activity example", "sectionreturn": 0 @@ -44,10 +45,13 @@ data-action="open-addingcontent" {{#modid}} data-beforemod="{{modid}}" + aria-label="{{#str}}insertcontentbefore, core, { "activityname": {{#quote}} {{activityname}} {{/quote}} } {{/str}}" + {{/modid}} + {{^modid}} + aria-label="{{#str}}insertcontentsection, core, { "sectionname": {{#quote}} {{sectionname}} {{/quote}} } {{/str}}" {{/modid}} aria-haspopup="true" aria-expanded="false" - aria-label="{{#str}}insertcontentbefore, core, { "activityname": {{#quote}} {{activityname}} {{/quote}} } {{/str}}" tabindex="0" title="{{#str}}addcontent, core{{/str}}" > diff --git a/course/tests/behat/activity_chooser_plus.feature b/course/tests/behat/activity_chooser_plus.feature index 94827b9276a..a0e40dce831 100644 --- a/course/tests/behat/activity_chooser_plus.feature +++ b/course/tests/behat/activity_chooser_plus.feature @@ -29,6 +29,8 @@ Feature: Use the activity chooser to insert activities anywhere in a section And "Insert content before 'Test Forum'" "button" should not be visible When I hover "Insert content before 'Test Forum'" "button" Then "Insert content before 'Test Forum'" "button" should be visible + And I hover "Insert content in section 'New section'" "button" + Then "Insert content in section 'New section'" "button" should be visible Scenario: The activity chooser can be used to insert modules before existing modules Given I change window size to "large" diff --git a/lang/en/moodle.php b/lang/en/moodle.php index c46594bd97c..3c183288b33 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1182,6 +1182,7 @@ $string['indicator:userforumstracking_help'] = 'This indicator represents whethe $string['info'] = 'Information'; $string['inprogress'] = 'In progress'; $string['insertcontentbefore'] = 'Insert content before \'{$a->activityname}\''; +$string['insertcontentsection'] = 'Insert content in section \'{$a->sectionname}\''; $string['insertresourceoractivitybefore'] = 'Insert an activity or resource before \'{$a->activityname}\''; $string['institution'] = 'Institution'; $string['instudentview'] = 'in student view';