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