Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

Communicate with backpacks.

Author: Tung Thai <Tung.ThaiDuc@nashtechglobal.com>
Copyright: 2020 Tung Thai based on Totara Learning Solutions Ltd {@link http://www.totaralms.com/} dode
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 280 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

backpack_api2p1:: (9 methods):
  __construct()
  get_issuer()
  get_api_base_url()
  define_mappings()
  disconnect_backpack()
  curl_request()
  get_stored_token()
  get_clientid()
  put_assertions()


Class: backpack_api2p1  - X-Ref

To process badges with backpack and control api request and this class using for Open Badge API v2.1 methods.

__construct($externalbackpack)   X-Ref
backpack_api2p1 constructor.

param: object $externalbackpack object

get_issuer()   X-Ref
Initialises or returns the OAuth2 issuer associated to this backpack.

return: issuer

get_api_base_url()   X-Ref
Gets the apiBase url associated to this backpack.

return: string

define_mappings()   X-Ref
Define the mappings supported by this usage and api version.


disconnect_backpack($backpack)   X-Ref
Disconnect the backpack from this user.

return: bool
param: object $backpack to disconnect.

curl_request($action, $postdata = null)   X-Ref
Make an api request.

return: mixed
param: string $action The api function.
param: string $postdata The body of the api request.

get_stored_token($externalbackpackid)   X-Ref
Get token.

return: oauth2\badge_backpack_oauth2|false|stdClass|null
param: int $externalbackpackid ID of external backpack.

get_clientid($issuerid)   X-Ref
Get client id.

param: int $issuerid id of Oauth2 service.

put_assertions($hash)   X-Ref
Export a badge to the backpack site.

return: array
param: string $hash of badge issued.