Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 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: 306 lines (10 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.

param: object $backpack to disconnect.
return: bool

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

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

get_stored_token($externalbackpackid)   X-Ref
Get token.

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

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.

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