moodle/badges/backpack.js
Damyon Wiese 7444ba743f MDL-63262 badges: More changes for badgr.io
This commit combines several changes:
* Show authentication errors.
* Show more detailed authentication errors
* When the site backpack is different to the user backpack, show a warning
* Do not duplicate the apiversion and backpackurls in each user backpack.
* Do not support different issuer information for each badge with Open Badges v2.
* Add obversion to assertion url
* Combine separate badges upgrade steps and bump the version number.
* Don't show private collections.
* Push the larger image size to backpacks (512x512).
* BADGE_BACKPACKURL is deprecated
* Don't use property alignments, only alignment
2019-05-03 15:00:01 +08:00

53 lines
1.6 KiB
JavaScript

/**
* Push badges to backpack.
* @deprecated since 3.7
*/
function addtobackpack(event, args) {
var badgetable = Y.one('#issued-badge-table');
var errordiv = Y.one('#addtobackpack-error');
var errortext = M.util.get_string('error:backpackproblem', 'badges');
var errorhtml = '<div id="addtobackpack-error" class="box boxaligncenter notifyproblem">' + errortext + '</div>';
if (typeof OpenBadges !== 'undefined') {
OpenBadges.issue([args.assertion], function(errors, successes) { });
} else {
// Add error div if it doesn't exist yet.
if (!errordiv) {
var badgerror = Y.Node.create(errorhtml);
badgetable.insert(badgerror, 'before');
}
}
}
/**
* Check if website is externally accessible from the backpack.
* @deprecated since 3.7
*/
function check_site_access() {
var add = Y.one('#check_connection');
var callback = {
method: "GET",
on: {
success: function(id, o) {
var data = Y.JSON.parse(o.responseText);
if (data.code == 'http-unreachable') {
add.setHTML(data.response);
add.removeClass('hide');
}
M.util.js_complete('badge/backpack::check_site_access');
},
failure: function() {
M.util.js_complete('badge/backpack::check_site_access');
}
}
};
Y.use('io-base', function(Y) {
M.util.js_pending('badge/backpack::check_site_access');
Y.io('ajax.php', callback);
});
return false;
}