Skip to content

Commit

Permalink
Fixed: Badge preview URL from course context
Browse files Browse the repository at this point in the history
  • Loading branch information
davidherney committed Jun 5, 2024
1 parent 3a2fb99 commit a1b456f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions classes/output/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

require_once($CFG->dirroot . '/lib/badgeslib.php');

use context_course;
use renderable;
use renderer_base;
use templatable;
Expand Down Expand Up @@ -255,9 +256,16 @@ public function export_for_template(renderer_base $output) {

if ($badge->status == '3') {

if ($badge->courseid) {
$instancecontext = \context_course::instance($badge->courseid);
$source = $instancecontext->id;
} else {
$source = SITEID;
}

$badge->url = urldecode((string)(new \moodle_url('/badges/badge.php', ['hash' => $badge->uniquehash])));
$badge->thumbnail = \moodle_url::make_pluginfile_url(SITEID,
'badges', 'badgeimage', $badge->id, '/', 'f3', false);
$badge->thumbnail = \moodle_url::make_pluginfile_url($source,
'badges', 'badgeimage', $badge->id, '/', 'f3', false);

$badges[] = $badge;
}
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

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

$plugin->version = 2021031216.02; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2021031216.03; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2019052002; // Requires this Moodle version.
$plugin->component = 'block_ludifica'; // Full name of the plugin (used for diagnostics).

0 comments on commit a1b456f

Please sign in to comment.