Skip to content

Commit 8f11f77

Browse files
committed
Merge branch 'MDL-65787-37' of git://github.com/sarjona/moodle into MOODLE_37_STABLE
2 parents 2b63da7 + b31ec4d commit 8f11f77

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

badges/classes/form/collections.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,25 @@ public function definition() {
7979
$hasgroups = false;
8080
if (!empty($groups)) {
8181
foreach ($groups as $group) {
82-
// Assertions or badges.
8382
$count = 0;
84-
83+
// Handle attributes based on backpack's supported version.
8584
if ($sitebackpack->apiversion == OPEN_BADGES_V2) {
85+
// OpenBadges v2 data attributes.
8686
if (empty($group->published)) {
8787
// Only public collections.
8888
continue;
8989
}
90-
}
91-
if (!empty($group->assertions)) {
90+
91+
// Get the number of badges associated with this collection from the assertions array returned.
9292
$count = count($group->assertions);
93-
}
94-
if (!empty($group->badges)) {
95-
$count = count($group->badges);
96-
}
97-
if (!empty($group->groupId)) {
93+
} else {
94+
// OpenBadges v1 data attributes.
9895
$group->entityId = $group->groupId;
96+
97+
// Get the number of badges associated with this collection. In that case, the number is returned directly.
98+
$count = $group->badges;
9999
}
100+
100101
if (!$hasgroups) {
101102
$mform->addElement('static', 'selectgroup', '', get_string('selectgroup_start', 'badges'));
102103
}

0 commit comments

Comments
 (0)