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 = '';
if ($userpicture->alttext) {
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)) {
$size = 35;
} 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 {
$presets = [];
foreach ($this->presets as $preset) {
foreach ($this->presets as $index => $preset) {
$presetname = $preset->name;
$userid = $preset instanceof preset ? $preset->get_userid() : $preset->userid;
if (!empty($userid)) {
@ -120,6 +120,7 @@ class presets implements templatable, renderable {
'description' => $preset->description,
'userid' => $userid,
'actions' => $actions,
'presetindex' => $index,
];
}

View file

@ -35,7 +35,8 @@
"description": "Use this preset to collect images",
"userid": 0,
"url": "http://www.example.com",
"actions": []
"actions": [],
"presetindex": 0
},
{
"id": 2,
@ -45,7 +46,8 @@
"fullname": "Preset saved manually (admin)",
"userid": 2,
"url": "http://www.example.com",
"actions": []
"actions": [],
"presetindex": 1
}
]
}
@ -57,36 +59,43 @@
<input type="hidden" name="mode" value="usepreset">
<input type="hidden" name="action" value="select">
<table id="presets-list" class="generaltable fullwidth">
<thead>
<fieldset>
<legend class="sr-only">{{#str}}presets, mod_data{{/str}}</legend>
<table id="presets-list" class="generaltable fullwidth">
<thead>
<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">{{#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>
</thead>
<tbody>
</thead>
<tbody>
{{#presets}}
<tr>
<td class="p-4 border-right">
<input type="radio" name="fullname" value="{{userid}}/{{shortname}}" data-cmid="{{cmid}}" />
</td>
<td class="p-4">
<a href="{{{url}}}">{{fullname}}</a>
</td>
<td class="p-4">{{description}}</td>
<td class="p-4 preset_action_menu">
{{#actions}}
<div class="float-right">
{{>core/action_menu}}
</div>
{{/actions}}
</td>
</tr>
<tr>
<td class="p-4 border-right">
<input type="radio" name="fullname" value="{{userid}}/{{shortname}}" data-cmid="{{cmid}}" aria-labelledby="preset-name-{{presetindex}}" >
</td>
<td class="p-4">
<a id="preset-name-{{presetindex}}" href="{{{url}}}">{{fullname}}</a>
</td>
<td class="p-4">{{description}}</td>
<td class="p-4 preset_action_menu">
{{#actions}}
<div class="float-right">
{{>core/action_menu}}
</div>
{{/actions}}
</td>
</tr>
{{/presets}}
</tbody>
</table>
</tbody>
</table>
</fieldset>
{{< core/sticky_footer }}
{{$ stickycontent }}