Merge branch 'MDL-79059-402-2' of https://github.com/junpataleta/moodle into MOODLE_402_STABLE

This commit is contained in:
Andrew Nicols 2023-08-29 11:36:45 +08:00
commit fbe382e322
No known key found for this signature in database
GPG key ID: 6D1E3157C8CFBF14
3 changed files with 46 additions and 28 deletions

View file

@ -2656,10 +2656,18 @@ class core_renderer extends renderer_base {
$alt = ''; $alt = '';
if ($userpicture->alttext) { if ($userpicture->alttext) {
if (!empty($user->imagealt)) { if (!empty($user->imagealt)) {
$alt = $user->imagealt; $alt = trim($user->imagealt);
} }
} }
// If the user picture is being rendered as a link but without the full name, an empty alt text for the user picture
// would mean that the link displayed will not have any discernible text. This becomes an accessibility issue,
// especially to screen reader users. Use the user's full name by default for the user picture's alt-text if this is
// the case.
if ($userpicture->link && !$userpicture->includefullname && empty($alt)) {
$alt = fullname($user);
}
if (empty($userpicture->size)) { if (empty($userpicture->size)) {
$size = 35; $size = 35;
} else if ($userpicture->size === true or $userpicture->size == 1) { } else if ($userpicture->size === true or $userpicture->size == 1) {

View file

@ -90,7 +90,7 @@ class presets implements templatable, renderable {
*/ */
private function get_presets(renderer_base $output): array { private function get_presets(renderer_base $output): array {
$presets = []; $presets = [];
foreach ($this->presets as $preset) { foreach ($this->presets as $index => $preset) {
$presetname = $preset->name; $presetname = $preset->name;
$userid = $preset instanceof preset ? $preset->get_userid() : $preset->userid; $userid = $preset instanceof preset ? $preset->get_userid() : $preset->userid;
if (!empty($userid)) { if (!empty($userid)) {
@ -120,6 +120,7 @@ class presets implements templatable, renderable {
'description' => $preset->description, 'description' => $preset->description,
'userid' => $userid, 'userid' => $userid,
'actions' => $actions, 'actions' => $actions,
'presetindex' => $index,
]; ];
} }

View file

@ -35,7 +35,8 @@
"description": "Use this preset to collect images", "description": "Use this preset to collect images",
"userid": 0, "userid": 0,
"url": "http://www.example.com", "url": "http://www.example.com",
"actions": [] "actions": [],
"presetindex": 0
}, },
{ {
"id": 2, "id": 2,
@ -45,7 +46,8 @@
"fullname": "Preset saved manually (admin)", "fullname": "Preset saved manually (admin)",
"userid": 2, "userid": 2,
"url": "http://www.example.com", "url": "http://www.example.com",
"actions": [] "actions": [],
"presetindex": 1
} }
] ]
} }
@ -57,23 +59,29 @@
<input type="hidden" name="mode" value="usepreset"> <input type="hidden" name="mode" value="usepreset">
<input type="hidden" name="action" value="select"> <input type="hidden" name="action" value="select">
<fieldset>
<legend class="sr-only">{{#str}}presets, mod_data{{/str}}</legend>
<table id="presets-list" class="generaltable fullwidth"> <table id="presets-list" class="generaltable fullwidth">
<thead> <thead>
<tr> <tr>
<th class="pl-4 border-top-0" scope="col" style="width: 3%"></th> <th class="pl-4 border-top-0" scope="col" style="width: 3%">
<span class="sr-only">{{#str}}select{{/str}}</span>
</th>
<th class="pl-4 border-top-0" scope="col" style="width:30%">{{#str}} name {{/str}}</th> <th class="pl-4 border-top-0" scope="col" style="width:30%">{{#str}} name {{/str}}</th>
<th class="pl-4 border-top-0" scope="col">{{#str}} description {{/str}}</th> <th class="pl-4 border-top-0" scope="col">{{#str}} description {{/str}}</th>
<th class="pl-4 border-top-0" scope="col" style="width: 3%"></th> <th class="pl-4 border-top-0" scope="col" style="width: 3%">
<span class="sr-only">{{#str}}actions{{/str}}</span>
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{#presets}} {{#presets}}
<tr> <tr>
<td class="p-4 border-right"> <td class="p-4 border-right">
<input type="radio" name="fullname" value="{{userid}}/{{shortname}}" data-cmid="{{cmid}}" /> <input type="radio" name="fullname" value="{{userid}}/{{shortname}}" data-cmid="{{cmid}}" aria-labelledby="preset-name-{{presetindex}}" >
</td> </td>
<td class="p-4"> <td class="p-4">
<a href="{{{url}}}">{{fullname}}</a> <a id="preset-name-{{presetindex}}" href="{{{url}}}">{{fullname}}</a>
</td> </td>
<td class="p-4">{{description}}</td> <td class="p-4">{{description}}</td>
<td class="p-4 preset_action_menu"> <td class="p-4 preset_action_menu">
@ -87,6 +95,7 @@
{{/presets}} {{/presets}}
</tbody> </tbody>
</table> </table>
</fieldset>
{{< core/sticky_footer }} {{< core/sticky_footer }}
{{$ stickycontent }} {{$ stickycontent }}