Skip to content

Commit

Permalink
Merge branch 'MDL-73153-311' of https://github.com/sarjona/moodle int…
Browse files Browse the repository at this point in the history
…o MOODLE_311_STABLE
  • Loading branch information
junpataleta committed Dec 6, 2021
2 parents 6cd7435 + 9a21803 commit 2027f40
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions badges/renderer.php
Expand Up @@ -24,6 +24,8 @@
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
*/

defined('MOODLE_INTERNAL') || die();

require_once($CFG->libdir . '/badgeslib.php');
require_once($CFG->libdir . '/tablelib.php');

Expand All @@ -47,7 +49,14 @@ public function print_badges_list($badges, $userid, $profile = false, $external
$bname = s($badge->name);
}
if (!empty($badge->image)) {
$imageurl = $badge->image;
if (is_object($badge->image)) {
if (!empty($badge->image->caption)) {
$badge->imagecaption = $badge->image->caption;
}
$imageurl = $badge->image->id;
} else {
$imageurl = $badge->image;
}
}
if (isset($badge->assertion->badge->name)) {
$bname = s($badge->assertion->badge->name);
Expand Down Expand Up @@ -508,7 +517,14 @@ protected function render_external_badge(\core_badges\output\external_badge $iba
if (isset($issued->imageUrl)) {
$issued->image = $issued->imageUrl;
}
$output .= html_writer::empty_tag('img', array('src' => $issued->image, 'width' => '100'));
if (is_object($issued->image)) {
if (!empty($issued->image->caption)) {
$issued->imagecaption = $issued->image->caption;
}
$issued->image = $issued->image->id;
}
$imagecaption = $issued->imagecaption ?? '';
$output .= html_writer::empty_tag('img', ['src' => $issued->image, 'width' => '100', 'alt' => $imagecaption]);
if (isset($assertion->expires)) {
$expiration = is_numeric($assertion->expires) ? $assertion->expires : strtotime($assertion->expires);
if ($expiration < $today) {
Expand Down

0 comments on commit 2027f40

Please sign in to comment.