See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
Contains classes, functions and constants used in badges.
Author: | Yuliya Bozhko <yuliya.bozhko@totaralms.com> |
Copyright: | 2012 onwards Totara Learning Solutions Ltd {@link http://www.totaralms.com/} |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 1258 lines (44 kb) |
Included or required: | 0 times |
Referenced: | 7 times |
Includes or requires: | 1 file badges/lib/bakerlib.php |
badges_notify_badge_award(badge $badge, $userid, $issued, $filepathhash) X-Ref |
Sends notifications to users about awarded badges. param: badge $badge Badge that was issued param: int $userid Recipient ID param: string $issued Unique hash of an issued badge param: string $filepathhash File path hash of an issued badge for attachments |
badges_calculate_message_schedule($schedule) X-Ref |
Caclulates date for the next message digest to badge creators. param: in $schedule Type of message schedule BADGE_MESSAGE_DAILY|BADGE_MESSAGE_WEEKLY|BADGE_MESSAGE_MONTHLY. return: int Timestamp for next cron |
badge_message_from_template($message, $params) X-Ref |
Replaces variables in a message template and returns text ready to be emailed to a user. param: string $message Message body. return: string Message with replaced values |
badges_get_badges($type, $courseid = 0, $sort = '', $dir = '', $page = 0, $perpage = BADGE_PERPAGE, $user = 0) X-Ref |
Get all badges. param: int Type of badges to return param: int Course ID for course badges param: string $sort An SQL field to sort by param: string $dir The sort direction ASC|DESC param: int $page The page or records to return param: int $perpage The number of records to return per page param: int $user User specific search return: array $badge Array of records matching criteria |
badges_get_user_badges($userid, $courseid = 0, $page = 0, $perpage = 0, $search = '', $onlypublic = false) X-Ref |
Get badges for a specific user. param: int $userid User ID param: int $courseid Badges earned by a user in a specific course param: int $page The page or records to return param: int $perpage The number of records to return per page param: string $search A simple string to search for param: bool $onlypublic Return only public badges return: array of badges ordered by decreasing date of issue |
badges_add_course_navigation(navigation_node $coursenode, stdClass $course) X-Ref |
Extends the course administration navigation with the Badges page param: navigation_node $coursenode param: object $course |
badges_award_handle_manual_criteria_review(stdClass $data) X-Ref |
Triggered when badge is manually awarded. param: object $data return: boolean |
badges_process_badge_image(badge $badge, $iconfile) X-Ref |
Process badge image from form data param: badge $badge Badge object param: string $iconfile Original file |
print_badge_image(badge $badge, stdClass $context, $size = 'small') X-Ref |
Print badge image. param: badge $badge Badge object param: stdClass $context param: string $size |
badges_bake($hash, $badgeid, $userid = 0, $pathhash = false) X-Ref |
Bake issued badge. param: string $hash Unique hash of an issued badge. param: int $badgeid ID of the original badge. param: int $userid ID of badge recipient (optional). param: boolean $pathhash Return file pathhash instead of image url (optional). return: string|url Returns either new file path hash or new file URL |
get_backpack_settings($userid, $refresh = false) X-Ref |
Returns external backpack settings and badges from this backpack. This function first checks if badges for the user are cached and tries to retrieve them from the cache. Otherwise, badges are obtained through curl request to the backpack. param: int $userid Backpack user ID. param: boolean $refresh Refresh badges collection in cache. return: null|object Returns null is there is no backpack or object with backpack settings. |
badges_download($userid) X-Ref |
Download all user badges in zip archive. param: int $userid ID of badge owner. |
badges_check_backpack_accessibility() X-Ref |
Checks if badges can be pushed to external backpack. return: string Code of backpack accessibility status. |
badges_user_has_backpack($userid) X-Ref |
Checks if user has external backpack connected. param: int $userid ID of a user. return: bool True|False whether backpack connection exists. |
badges_handle_course_deletion($courseid) X-Ref |
Handles what happens to the course badges when a course is deleted. param: int $courseid course ID. return: void. |
badges_setup_backpack_js() X-Ref |
Loads JS files required for backpack support. return: void |
badges_local_backpack_js($checksite = false) X-Ref |
No js files are required for backpack support. This only exists to directly support the custom V1 backpack api. param: boolean $checksite Call check site function. return: void |
badges_create_site_backpack($data) X-Ref |
Create the backpack with this data. param: stdClass $data The new backpack data. return: boolean |
badges_update_site_backpack($id, $data) X-Ref |
Update the backpack with this id. param: integer $id The backpack to edit param: stdClass $data The new backpack data. return: boolean |
badges_delete_site_backpack($id) X-Ref |
Delete the backpack with this id. param: integer $id The backpack to delete. return: boolean |
badges_open_badges_backpack_api() X-Ref |
Is any backpack enabled that supports open badges V1? return: boolean |
badges_get_site_backpack($id) X-Ref |
Get a site backpacks by id or url. param: int $id The backpack id. return: array(stdClass) |
badges_get_site_backpacks() X-Ref |
List the backpacks at site level. return: array(stdClass) |
badges_get_badge_api_versions() X-Ref |
List the supported badges api versions. return: array(version) |
badges_get_default_issuer() X-Ref |
Get the default issuer for a badge from this site. return: array |
badges_disconnect_user_backpack($userid) X-Ref |
Disconnect from the user backpack by deleting the user preferences. param: integer $userid The user to diconnect. return: boolean |
badges_external_get_mapping($sitebackpackid, $type, $internalid) X-Ref |
Used to remember which objects we connected with a backpack before. param: integer $sitebackpackid The site backpack to connect to. param: string $type The type of this remote object. param: string $internalid The id for this object on the Moodle site. return: mixed The id or false if it doesn't exist. |
badges_external_create_mapping($sitebackpackid, $type, $internalid, $externalid) X-Ref |
Save the info about which objects we connected with a backpack before. param: integer $sitebackpackid The site backpack to connect to. param: string $type The type of this remote object. param: string $internalid The id for this object on the Moodle site. param: string $externalid The id of this object on the remote site. return: boolean |
badges_external_delete_mappings($sitebackpackid) X-Ref |
Delete all external mapping information for a backpack. param: integer $sitebackpackid The site backpack to connect to. return: boolean |
badges_external_delete_mapping($sitebackpackid, $type, $internalid) X-Ref |
Delete a specific external mapping information for a backpack. param: integer $sitebackpackid The site backpack to connect to. param: string $type The type of this remote object. param: string $internalid The id for this object on the Moodle site. return: boolean |
badges_send_verification_email($email, $backpackid, $backpackpassword) X-Ref |
Create and send a verification email to the email address supplied. Since we're not sending this email to a user, email_to_user can't be used but this function borrows largely the code from that process. param: string $email the email address to send the verification email to. param: int $backpackid the id of the backpack to connect to param: string $backpackpassword the user entered password to connect to this backpack return: true if the email was sent successfully, false otherwise. |
badges_list_criteria($enabled = true) X-Ref |
Return all the enabled criteria types for this site. param: boolean $enabled return: array |
badge_award_criteria_competency_has_records_for_competencies($competencyids) X-Ref |
Check if any badge has records for competencies. param: array $competencyids Array of competencies ids. return: boolean Return true if competencies were found in any badge. |
badge_assemble_notification(stdClass $badge) X-Ref |
Creates single message for all notification and sends it out param: object $badge A badge which is notified about. |
badges_verify_site_backpack() X-Ref |
Attempt to authenticate with the site backpack credentials and return an error if the authentication fails. If external backpacks are not enabled, this will not perform any test. return: string |
badges_verify_backpack(int $backpackid) X-Ref |
Attempt to authenticate with a backpack credentials and return an error if the authentication fails. If external backpacks are not enabled or the backpack version is different from OBv2, this will not perform any test. param: int $backpackid Backpack identifier to verify. return: string The result of the verification process. |
badges_get_oauth2_service_options() X-Ref |
Get OAuth2 services for the external backpack. return: array |