Differences Between: [Versions 310 and 311] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
Badge assertion library.
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: | 952 lines (33 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
badge:: (34 methods):
__construct()
get_context()
get_aggregation_methods()
get_accepted_criteria()
save()
make_clone()
is_active()
get_status_name()
set_status()
is_locked()
has_awards()
get_awards()
is_issued()
issue()
review_all_criteria()
get_criteria_completions()
has_criteria()
get_criteria()
get_aggregation_method()
can_expire()
calculate_expiry()
has_manual_award_criteria()
delete()
add_related_badges()
delete_related_badge()
has_related()
get_related_badges()
save_alignment()
delete_alignment()
get_alignments()
save_endorsement()
get_endorsement()
markdown_badge_criteria()
get_badge_issuer()
__construct($badgeid) X-Ref |
Constructs with badge details. param: int $badgeid badge ID. |
get_context() X-Ref |
Use to get context instance of a badge. return: context instance. |
get_aggregation_methods() X-Ref |
Return array of aggregation methods return: array |
get_accepted_criteria() X-Ref |
Return array of accepted criteria types for this badge return: array |
save() X-Ref |
Save/update badge information in 'badge' table only. Cannot be used for updating awards and criteria settings. return: boolean Returns true on success. |
make_clone() X-Ref |
Creates and saves a clone of badge with all its properties. Clone is not active by default and has 'Copy of' attached to its name. return: int ID of new badge. |
is_active() X-Ref |
Checks if badges is active. Used in badge award. return: boolean A status indicating badge is active |
get_status_name() X-Ref |
Use to get the name of badge status. return: string |
set_status($status = 0) X-Ref |
Use to set badge status. Only active badges can be earned/awarded/issued. param: int $status Status from BADGE_STATUS constants |
is_locked() X-Ref |
Checks if badges is locked. Used in badge award and editing. return: boolean A status indicating badge is locked |
has_awards() X-Ref |
Checks if badge has been awarded to users. Used in badge editing. return: boolean A status indicating badge has been awarded at least once |
get_awards() X-Ref |
Gets list of users who have earned an instance of this badge. return: array An array of objects with information about badge awards. |
is_issued($userid) X-Ref |
Indicates whether badge has already been issued to a user. param: int $userid User to check return: boolean |
issue($userid, $nobake = false) X-Ref |
Issue a badge to user. param: int $userid User who earned the badge param: boolean $nobake Not baking actual badges (for testing purposes) |
review_all_criteria() X-Ref |
Reviews all badge criteria and checks if badge can be instantly awarded. return: int Number of awards |
get_criteria_completions($userid) X-Ref |
Gets an array of completed criteria from 'badge_criteria_met' table. param: int $userid Completions for a user return: array Records of criteria completions |
has_criteria() X-Ref |
Checks if badges has award criteria set up. return: boolean A status indicating badge has at least one criterion |
get_criteria() X-Ref |
Returns badge award criteria return: array An array of badge criteria |
get_aggregation_method($criteriatype = 0) X-Ref |
Get aggregation method for badge criteria param: int $criteriatype If none supplied, get overall aggregation method (optional) return: int One of BADGE_CRITERIA_AGGREGATION_ALL or BADGE_CRITERIA_AGGREGATION_ANY |
can_expire() X-Ref |
Checks if badge has expiry period or date set up. return: boolean A status indicating badge can expire |
calculate_expiry($timestamp) X-Ref |
Calculates badge expiry date based on either expirydate or expiryperiod. param: int $timestamp Time of badge issue return: int A timestamp |
has_manual_award_criteria() X-Ref |
Checks if badge has manual award criteria set. return: boolean A status indicating badge can be awarded manually |
delete($archive = true) X-Ref |
Fully deletes the badge or marks it as archived. param: boolean $archive Achive a badge without actual deleting of any data. |
add_related_badges($relatedids) X-Ref |
Add multiple related badges. param: array $relatedids Id of badges. |
delete_related_badge($relatedid) X-Ref |
Delete an related badge. param: int $relatedid Id related badge. return: boolean A status for delete an related badge. |
has_related() X-Ref |
Checks if badge has related badges. return: boolean A status related badge. |
get_related_badges($activeonly = false) X-Ref |
Get related badges of badge. param: boolean $activeonly Do not get the inactive badges when is true. return: array Related badges information. |
save_alignment($alignment, $alignmentid = 0) X-Ref |
Insert/update alignment information of badge. param: stdClass $alignment Data of a alignment. param: int $alignmentid ID alignment. return: bool|int A status/ID when insert or update data. |
delete_alignment($alignmentid) X-Ref |
Delete a alignment of badge. param: int $alignmentid ID alignment. return: boolean A status for delete a alignment. |
get_alignments() X-Ref |
Get alignments of badge. return: array List content alignments. |
save_endorsement($endorsement) X-Ref |
Insert/update Endorsement information of badge. param: stdClass $endorsement Data of an endorsement. return: bool|int A status/ID when insert or update data. |
get_endorsement() X-Ref |
Get endorsement of badge. return: array|stdClass Endorsement information. |
markdown_badge_criteria() X-Ref |
Markdown language support for criteria. return: string $output Markdown content to output. |
get_badge_issuer(?int $obversion = null) X-Ref |
Define issuer information by format Open Badges specification version 2. param: int $obversion OB version to use. return: array Issuer informations of the badge. |