Skip to content

Commit

Permalink
Merge branch 'MDL-67451-master' of git://github.com/sarjona/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
snake committed Dec 10, 2019
2 parents 80c13fe + d03d110 commit b424815
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion badges/assertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@

$hash = required_param('b', PARAM_ALPHANUM); // Issued badge unique hash for badge assertion.
$action = optional_param('action', null, PARAM_BOOL); // Generates badge class if true.
$obversion = optional_param('obversion', OPEN_BADGES_V1, PARAM_INT); // For control format OB specification version.
// OB specification version. If it's not defined, the site will be used as default.
$obversion = optional_param('obversion', badges_open_badges_backpack_api(), PARAM_INT);

$assertion = new core_badges_assertion($hash, $obversion);

Expand Down
6 changes: 5 additions & 1 deletion badges/classes/output/issued_badge.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class issued_badge implements renderable {
/** @var badge class */
public $badgeid = 0;

/** @var unique hash identifying the issued badge */
public $hash;

/**
* Initializes the badge to display
*
Expand All @@ -62,7 +65,8 @@ class issued_badge implements renderable {
public function __construct($hash) {
global $DB;

$assertion = new \core_badges_assertion($hash);
$this->hash = $hash;
$assertion = new \core_badges_assertion($hash, badges_open_badges_backpack_api());
$this->issued = $assertion->get_badge_assertion();
$this->badgeclass = $assertion->get_badge_class();

Expand Down
6 changes: 3 additions & 3 deletions badges/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,13 @@ protected function render_issued_badge(\core_badges\output\issued_badge $ibadge)

if ($USER->id == $userinfo->id && !empty($CFG->enablebadges)) {
$output .= $this->output->single_button(
new moodle_url('/badges/badge.php', array('hash' => $issued['uid'], 'bake' => true)),
new moodle_url('/badges/badge.php', array('hash' => $ibadge->hash, 'bake' => true)),
get_string('download'),
'POST');
if (!empty($CFG->badges_allowexternalbackpack) && ($expiration > $now) && badges_user_has_backpack($USER->id)) {

if (badges_open_badges_backpack_api() == OPEN_BADGES_V1) {
$assertion = new moodle_url('/badges/assertion.php', array('b' => $issued['uid']));
$assertion = new moodle_url('/badges/assertion.php', array('b' => $ibadge->hash));
$action = new component_action('click', 'addtobackpack', array('assertion' => $assertion->out(false)));
$attributes = array(
'type' => 'button',
Expand All @@ -354,7 +354,7 @@ protected function render_issued_badge(\core_badges\output\issued_badge $ibadge)
$this->output->add_action_handler($action, 'addbutton');
$output .= $tobackpack;
} else {
$assertion = new moodle_url('/badges/backpack-add.php', array('hash' => $issued['uid']));
$assertion = new moodle_url('/badges/backpack-add.php', array('hash' => $ibadge->hash));
$attributes = ['class' => 'btn btn-secondary m-1', 'role' => 'button'];
$tobackpack = html_writer::link($assertion, get_string('addtobackpack', 'badges'), $attributes);
$output .= $tobackpack;
Expand Down

0 comments on commit b424815

Please sign in to comment.