From e6445c5bd9c888518c11368f4e4c3474ee11e78b Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 23 Sep 2019 11:21:10 +0800 Subject: [PATCH] MDL-65315 badges: Update the class and issuer OBv2.0 url --- badges/classes/assertion.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/badges/classes/assertion.php b/badges/classes/assertion.php index 95250198498..872495eab84 100644 --- a/badges/classes/assertion.php +++ b/badges/classes/assertion.php @@ -127,7 +127,12 @@ class core_badges_assertion { $hash = $this->_data->uniquehash; $email = empty($this->_data->backpackemail) ? $this->_data->email : $this->_data->backpackemail; $assertionurl = new moodle_url('/badges/assertion.php', array('b' => $hash, 'obversion' => $this->_obversion)); - $classurl = new moodle_url('/badges/assertion.php', array('b' => $hash, 'action' => 1)); + + 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)); + } // Required. $assertion['uid'] = $hash; @@ -193,7 +198,11 @@ class core_badges_assertion { $class['image'] = 'data:image/png;base64,' . $imagedata; $class['criteria'] = $this->_url->out(false); // Currently issued badge URL. if ($issued) { - $issuerurl = new moodle_url('/badges/assertion.php', array('b' => $this->_data->uniquehash, 'action' => 0)); + if ($this->_obversion == OPEN_BADGES_V2) { + $issuerurl = new moodle_url('/badges/badge_json.php', array('id' => $this->get_badge_id(), 'action' => 0)); + } else { + $issuerurl = new moodle_url('/badges/assertion.php', array('b' => $this->_data->uniquehash, 'action' => 0)); + } $class['issuer'] = $issuerurl->out(false); } $this->embed_data_badge_version2($class, OPEN_BADGES_V2_TYPE_BADGE); @@ -329,10 +338,10 @@ class core_badges_assertion { $hash = $this->_data->uniquehash; $assertionsurl = new moodle_url('/badges/assertion.php', array('b' => $hash, 'obversion' => $this->_obversion)); $classurl = new moodle_url( - '/badges/assertion.php', - array('b' => $hash, 'action' => 1, 'obversion' => $this->_obversion) + '/badges/badge_json.php', + array('id' => $this->get_badge_id()) ); - $issuerurl = new moodle_url('/badges/assertion.php', array('b' => $this->_data->uniquehash, 'action' => 0, + $issuerurl = new moodle_url('/badges/badge_json.php', array('id' => $this->get_badge_id(), 'action' => 0, 'obversion' => $this->_obversion)); // For assertion. if ($type == OPEN_BADGES_V2_TYPE_ASSERTION) {