Skip to content

Commit

Permalink
Merge branch 'MDL-70963-master' of git://github.com/sarjona/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Mar 29, 2021
2 parents 91bd628 + 51ec496 commit 67b2e62
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion badges/assertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
} else { // Revoked badge.
header("HTTP/1.0 410 Gone");
$assertion = array();
if ($obversion == OPEN_BADGES_V2) {
if ($obversion >= OPEN_BADGES_V2) {
$assertionurl = new moodle_url('/badges/assertion.php', array('b' => $hash));
$assertion['id'] = $assertionurl->out();
}
Expand Down
4 changes: 2 additions & 2 deletions badges/classes/assertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function get_badge_assertion($issued = true, $usesalt = true) {
$email = empty($this->_data->backpackemail) ? $this->_data->email : $this->_data->backpackemail;
$assertionurl = new moodle_url('/badges/assertion.php', array('b' => $hash, 'obversion' => $this->_obversion));

if ($this->_obversion == OPEN_BADGES_V2) {
if ($this->_obversion >= OPEN_BADGES_V2) {
$classurl = new moodle_url('/badges/badge_json.php', array('id' => $this->get_badge_id()));
} else {
$classurl = new moodle_url('/badges/assertion.php', array('b' => $hash, 'action' => 1));
Expand Down Expand Up @@ -325,7 +325,7 @@ public function get_alignments() {
*/
protected function embed_data_badge_version2 (&$json, $type = OPEN_BADGES_V2_TYPE_ASSERTION) {
// Specification Version 2.0.
if ($this->_obversion == OPEN_BADGES_V2) {
if ($this->_obversion >= OPEN_BADGES_V2) {
$badge = new badge($this->_data->id);
if (empty($this->_data->courseid)) {
$context = context_system::instance();
Expand Down
12 changes: 11 additions & 1 deletion badges/tests/badgeslib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

use core_badges\helper;

class core_badges_badgeslib_testcase extends advanced_testcase {
class badgeslib_test extends advanced_testcase {
protected $badgeid;
protected $course;
protected $user;
Expand Down Expand Up @@ -698,6 +698,16 @@ public function test_badges_assertion() {
$this->assertStringMatchesFormat($testassertion2->badge, json_encode($assertion2->get_badge_assertion()));
$this->assertStringMatchesFormat($testassertion2->class, json_encode($assertion2->get_badge_class()));
$this->assertStringMatchesFormat($testassertion2->issuer, json_encode($assertion2->get_issuer()));

// Test Openbadge specification version 2.1. It has the same format as OBv2.0.
// Get assertion version 2.1.
$award = reset($awards);
$assertion2 = new core_badges_assertion($award->uniquehash, OPEN_BADGES_V2P1);

// Make sure JSON strings have the same structure.
$this->assertStringMatchesFormat($testassertion2->badge, json_encode($assertion2->get_badge_assertion()));
$this->assertStringMatchesFormat($testassertion2->class, json_encode($assertion2->get_badge_class()));
$this->assertStringMatchesFormat($testassertion2->issuer, json_encode($assertion2->get_issuer()));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion badges/tests/events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @copyright 2015 onwards Simey Lameze <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_badges_events_testcase extends core_badges_badgeslib_testcase {
class events_test extends badgeslib_test {

/**
* Test badge awarded event.
Expand Down

0 comments on commit 67b2e62

Please sign in to comment.