MDL-84941 course: fix activity button label on end of section.
Where the button is rendered after all section content, we should fix the ARIA label attribute to refer to the current section rather than non-existing subsequent activity.
This commit is contained in:
@@ -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,
|
||||
|
||||
+1
-1
@@ -1730,7 +1730,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) {
|
||||
|
||||
@@ -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}}"
|
||||
>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1178,6 +1178,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';
|
||||
|
||||
Reference in New Issue
Block a user