MDL-65787 badges: fix warning count() with PHP 7.2

This commit is contained in:
Sara Arjona 2019-05-29 15:09:39 +02:00
parent 29c395187f
commit 4221e36b16

View File

@ -79,24 +79,25 @@ class collections extends moodleform {
$hasgroups = false;
if (!empty($groups)) {
foreach ($groups as $group) {
// Assertions or badges.
$count = 0;
// Handle attributes based on backpack's supported version.
if ($sitebackpack->apiversion == OPEN_BADGES_V2) {
// OpenBadges v2 data attributes.
if (empty($group->published)) {
// Only public collections.
continue;
}
}
if (!empty($group->assertions)) {
// Get the number of badges associated with this collection from the assertions array returned.
$count = count($group->assertions);
}
if (!empty($group->badges)) {
$count = count($group->badges);
}
if (!empty($group->groupId)) {
} else {
// OpenBadges v1 data attributes.
$group->entityId = $group->groupId;
// Get the number of badges associated with this collection. In that case, the number is returned directly.
$count = $group->badges;
}
if (!$hasgroups) {
$mform->addElement('static', 'selectgroup', '', get_string('selectgroup_start', 'badges'));
}