MDL-70829 course: Mark up decorative images properly

* Decorative images should have an empty alt text and there's no need
to set a presentation role.
* Accessibility Behat tests added to cover the changes:
  - block_starredcourses uses the core_course/no-courses template
  - core_completion tests changes in core_course/activity instance and
    core_course/editdefaultcompletion
This commit is contained in:
Jun Pataleta 2024-03-18 20:55:31 +08:00
parent eb38033024
commit 91837d0553
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
7 changed files with 61 additions and 6 deletions

View File

@ -0,0 +1,42 @@
@block_starredcourses
Feature: Starred courses
In order for me to quickly navigate to my favourite courses
As a user
I must be able to add them to the Starred courses block
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| shortname | fullname |
| C1 | Course 1 |
| C2 | Course 2 |
| C3 | Course 3 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student1 | C2 | student |
| student1 | C3 | student |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| starredcourses | User | student1 | my-index | content |
@accessibility @javascript
Scenario: User has no starred courses
Given I log in as "student1"
Then I should see "No starred courses"
And the page should meet accessibility standards
@accessibility @javascript
Scenario: User has starred courses
Given I am on the "My courses" page logged in as "student1"
And I click on "Actions for course Course 1" "button"
And I click on "Star for Course 1" "link"
And I click on "Actions for course Course 3" "button"
And I click on "Star for Course 3" "link"
When I follow "Dashboard"
Then the page should meet accessibility standards
And I should see "Course 1" in the "Starred courses" "block"
And I should see "Course 3" in the "Starred courses" "block"
But I should not see "Course 2" in the "Starred courses" "block"

View File

@ -78,3 +78,10 @@ Feature: Allow teachers to bulk edit activity completion rules in a course.
And I should see "With conditions" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' row ')][.//*[text() = 'Test assignment two']]" "xpath_element"
And I should see "Passing grade" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' row ')][.//*[text() = 'Test assignment two']]" "xpath_element"
And I should not see "Completion expected on" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' row ')][.//*[text() = 'Test assignment two']]" "xpath_element"
@accessibility
Scenario: Evaluate the accessibility of the bulk edit activity completion page
Given I am on the "Course 1" course page logged in as "teacher1"
When I navigate to "Course completion" in current page administration
And I set the field "Course completion tertiary navigation" to "Bulk edit activity completion"
And the page should meet accessibility standards

View File

@ -228,3 +228,10 @@ Feature: Allow teachers to edit the default activity completion rules in a cours
When I navigate to "Course completion" in current page administration
And I set the field "Course completion tertiary navigation" to "Default activity completion"
Then "Quiz" "text" should appear before "Text and media area" "text"
@accessibility
Scenario: Evaluate the accessibility of the default activity completion page
Given I am on the "Course 1" course page logged in as "teacher1"
When I navigate to "Course completion" in current page administration
And I set the field "Course completion tertiary navigation" to "Default activity completion"
And the page should meet accessibility standards

View File

@ -378,7 +378,7 @@ class core_course_renderer extends plugin_renderer_base {
$altname = get_accesshide(' ' . $cm->modfullname);
$name = html_writer::empty_tag('img', array('src' => $cm->get_icon_url(),
'class' => 'iconlarge activityicon', 'alt' => ' ', 'role' => 'presentation')) .
'class' => 'iconlarge activityicon', 'alt' => '')) .
html_writer::tag('span', ' '.$cm->get_formatted_name() . $altname, array('class' => 'instancename'));
$formattedinfo = \core_availability\info::format_info($cm->availableinfo, $cm->get_course());
return html_writer::div($name, 'activityinstance-error') .

View File

@ -42,7 +42,7 @@
<input type="checkbox" id="selectactivity_{{cmid}}" class="mr-1" name="cmid[]" data-section="{{sectionnumber}}" value="{{cmid}}" aria-label="{{#str}}checkactivity, completion, {{{modname}}}{{/str}}">
{{/canmanage}}
<a href="{{url}}">
<img src="{{icon}}" class="iconlarge activityicon" alt=" " role="presentation" />
<img src="{{icon}}" class="iconlarge activityicon" alt="">
<span class="instancename">{{{modname}}}</span>
</a>
</div>

View File

@ -38,7 +38,7 @@
<div class="row mb-1">
{{#modules}}
<div class="col-sm-2">
<img src="{{icon}}" class="mr-1 mb-1" alt=" " role="presentation" />
<img src="{{icon}}" class="mr-1 mb-1" alt="">
<span>{{{formattedname}}}</span>
</div>
{{/modules}}

View File

@ -28,10 +28,9 @@
<div class="text-xs-center text-center mt-3" data-region="empty-message">
<img class="empty-placeholder-image-lg mt-1"
src="{{nocoursesimg}}"
alt="{{$nocoursestring}}{{#str}} nocourses, core {{/str}}{{/nocoursestring}}"
role="presentation">
alt="">
<p class="text-muted mt-3">{{$nocoursestring}}{{#str}} nocourses, core {{/str}}{{/nocoursestring}}</p>
{{#newcourseurl}}
<a href="{{{newcourseurl}}}" class="nocourseslink">{{#str}} createnewcourse, core {{/str}}</a>
{{/newcourseurl}}
</div>
</div>