Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
badgeslib.php File Reference

Functions

 badge_assemble_notification (stdClass $badge)
 Creates single message for all notification and sends it out.
 
 badge_award_criteria_competency_has_records_for_competencies ($competencyids)
 Check if any badge has records for competencies.
 
 badge_message_from_template ($message, $params)
 Replaces variables in a message template and returns text ready to be emailed to a user.
 
 badges_add_course_navigation (navigation_node $coursenode, stdClass $course)
 Extends the course administration navigation with the Badges page.
 
 badges_award_handle_manual_criteria_review (stdClass $data)
 Triggered when badge is manually awarded.
 
 badges_bake ($hash, $badgeid, $userid=0, $pathhash=false)
 Bake issued badge.
 
 badges_calculate_message_schedule ($schedule)
 Caclulates date for the next message digest to badge creators.
 
 badges_change_sortorder_backpacks (int $backpackid, int $direction)
 Moves the backpack in the list one position up or down.
 
 badges_create_site_backpack ($data)
 Create the site backpack with this data.
 
 badges_delete_site_backpack ($id)
 Delete the backpack with this id.
 
 badges_disconnect_user_backpack ($userid)
 Disconnect from the user backpack by deleting the user preferences.
 
 badges_download ($userid)
 Download all user badges in zip archive.
 
 badges_external_create_mapping ($sitebackpackid, $type, $internalid, $externalid)
 Save the info about which objects we connected with a backpack before.
 
 badges_external_delete_mapping ($sitebackpackid, $type, $internalid)
 Delete a specific external mapping information for a backpack.
 
 badges_external_delete_mappings ($sitebackpackid)
 Delete all external mapping information for a backpack.
 
 badges_external_get_mapping ($sitebackpackid, $type, $internalid, $param='externalid')
 Used to remember which objects we connected with a backpack before.
 
 badges_generate_badgr_open_url ($backpack, $type, $externalid)
 Generate a public badgr URL that conforms to OBv2.
 
 badges_get_badge_api_versions ()
 List the supported badges api versions.
 
 badges_get_badge_by_hash (string $hash)
 Get badge by hash.
 
 badges_get_badges ($type, $courseid=0, $sort='', $dir='', $page=0, $perpage=BADGE_PERPAGE, $user=0)
 Get all badges.
 
 badges_get_default_issuer ()
 Get the default issuer for a badge from this site.
 
 badges_get_site_backpack ($id, int $userid=0)
 Get a site backpacks by id for a particular user or site (if userid is 0)
 
 badges_get_site_backpacks ()
 List the backpacks at site level.
 
 badges_get_site_primary_backpack ()
 Get the primary backpack for the site.
 
 badges_get_user_backpack (?int $userid=0)
 Get the user backpack for the currently logged in user OR the provided user.
 
 badges_get_user_badges ($userid, $courseid=0, $page=0, $perpage=0, $search='', $onlypublic=false)
 Get badges for a specific user.
 
 badges_handle_course_deletion ($courseid)
 Handles what happens to the course badges when a course is deleted.
 
 badges_list_criteria ($enabled=true)
 Return all the enabled criteria types for this site.
 
 badges_notify_badge_award (badge $badge, $userid, $issued, $filepathhash)
 Sends notifications to users about awarded badges.
 
 badges_open_badges_backpack_api (?int $backpackid=null)
 Is any backpack enabled that supports open badges V1?
 
 badges_prepare_badge_for_external (stdClass $badge, stdClass $user)
 Update badge instance to external functions.
 
 badges_process_badge_image (badge $badge, $iconfile)
 Process badge image from form data.
 
 badges_save_backpack_credentials (stdClass $data)
 Create a backpack with the provided details.
 
 badges_save_external_backpack (stdClass $data)
 Perform the actual create/update of external bakpacks.
 
 badges_send_verification_email ($email, $backpackid, $backpackpassword)
 Create and send a verification email to the email address supplied.
 
 badges_update_site_backpack ($id, $data)
 Update the backpack with this id.
 
 badges_user_has_backpack ($userid)
 Checks if user has external backpack connected.
 
 badges_verify_backpack (int $backpackid)
 Attempt to authenticate with a backpack credentials and return an error if the authentication fails.
 
 badges_verify_site_backpack ()
 Attempt to authenticate with the site backpack credentials and return an error if the authentication fails.
 
 get_backpack_settings ($userid, $refresh=false)
 Returns external backpack settings and badges from this backpack.
 
 print_badge_image (badge $badge, stdClass $context, $size='small')
 Print badge image.
 

Variables

const BACKPACK_MOVE_DOWN 1
 
const BACKPACK_MOVE_UP -1
 
const BADGE_BACKPACKAPIURL 'https://backpack.openbadges.org'
 
const BADGE_BACKPACKWEBURL 'https://backpack.openbadges.org'
 
const BADGE_CRITERIA_AGGREGATION_ALL 1
 
const BADGE_CRITERIA_AGGREGATION_ANY 2
 
const BADGE_MESSAGE_ALWAYS 1
 
const BADGE_MESSAGE_DAILY 2
 
const BADGE_MESSAGE_MONTHLY 4
 
const BADGE_MESSAGE_NEVER 0
 
const BADGE_MESSAGE_WEEKLY 3
 
const BADGE_PERPAGE 50
 
const BADGE_STATUS_ACTIVE 1
 
const BADGE_STATUS_ACTIVE_LOCKED 3
 
const BADGE_STATUS_ARCHIVED 4
 
const BADGE_STATUS_INACTIVE 0
 
const BADGE_STATUS_INACTIVE_LOCKED 2
 
const BADGE_TYPE_COURSE 2
 
const BADGE_TYPE_SITE 1
 
const BADGRIO_BACKPACKAPIURL 'https://api.badgr.io/v2'
 
const BADGRIO_BACKPACKWEBURL 'https://badgr.io'
 
const OPEN_BADGES_V1 1
 
const OPEN_BADGES_V2 2
 
const OPEN_BADGES_V2_CONTEXT 'https://w3id.org/openbadges/v2'
 
const OPEN_BADGES_V2_TYPE_ASSERTION 'Assertion'
 
const OPEN_BADGES_V2_TYPE_AUTHOR 'Author'
 
const OPEN_BADGES_V2_TYPE_BADGE 'BadgeClass'
 
const OPEN_BADGES_V2_TYPE_ENDORSEMENT 'Endorsement'
 
const OPEN_BADGES_V2_TYPE_ISSUER 'Issuer'
 
const OPEN_BADGES_V2P1 2.1