28
28
require_once ($ CFG ->libdir . '/badgeslib.php ' );
29
29
require_once ($ CFG ->dirroot . '/badges/renderer.php ' );
30
30
31
+ use core_badges \local \backpack \ob \exporter_base ;
32
+
31
33
/**
32
34
* Class that represents badge assertion.
33
35
*
@@ -116,6 +118,13 @@ public function get_assertion_hash() {
116
118
* @return array Badge assertion.
117
119
*/
118
120
public function get_badge_assertion ($ issued = true , $ usesalt = true ) {
121
+ $ assertionexporter = exporter_base::create_assertion_exporter_from_hash (
122
+ $ this ->_data ->uniquehash ,
123
+ exporter_base::convert_apiversion (OPEN_BADGES_V2 ),
124
+ );
125
+ return $ assertionexporter ->export ();
126
+
127
+ /*
119
128
global $CFG;
120
129
$assertion = array();
121
130
if ($this->_data) {
@@ -163,6 +172,7 @@ public function get_badge_assertion($issued = true, $usesalt = true) {
163
172
$this->embed_data_badge_version2($assertion, OPEN_BADGES_V2_TYPE_ASSERTION);
164
173
}
165
174
return $assertion;
175
+ */
166
176
}
167
177
168
178
/**
@@ -172,6 +182,14 @@ public function get_badge_assertion($issued = true, $usesalt = true) {
172
182
* @return array Badge Class information.
173
183
*/
174
184
public function get_badge_class ($ issued = true ) {
185
+ // TODO: Should the image be added with the data:image/png;base64, prefix?
186
+ $ badgeexporter = exporter_base::create_badge_exporter_from_id (
187
+ $ this ->get_badge_id (),
188
+ exporter_base::convert_apiversion (OPEN_BADGES_V2 ),
189
+ );
190
+ return $ badgeexporter ->export ();
191
+ /*
192
+ // TODO: This badge contains less information, for instance, version or language are not present).
175
193
$class = [];
176
194
if ($this->_data) {
177
195
if (empty($this->_data->courseid)) {
@@ -214,6 +232,7 @@ public function get_badge_class($issued = true) {
214
232
}
215
233
}
216
234
return $class;
235
+ */
217
236
}
218
237
219
238
/**
@@ -222,11 +241,11 @@ public function get_badge_class($issued = true) {
222
241
* @return array Issuer information.
223
242
*/
224
243
public function get_issuer () {
225
- $ badge = new badge ( $ this -> get_badge_id ());
226
- $ issuer = $ badge -> get_badge_issuer ();
227
-
228
- $ this -> embed_data_badge_version2 ( $ issuer , OPEN_BADGES_V2_TYPE_ISSUER );
229
- return $ issuer ;
244
+ $ issuerexporter = exporter_base:: create_issuer_exporter_from_id (
245
+ $ this -> get_badge_id (),
246
+ exporter_base:: convert_apiversion ( OPEN_BADGES_V2 ),
247
+ );
248
+ return $ issuerexporter -> export () ;
230
249
}
231
250
232
251
/**
0 commit comments