MDL-69002 core_badges: performance update to set default sitebackpack

This commit is contained in:
Peter Dias 2020-06-10 12:24:11 +08:00 committed by Sara Arjona
parent 92219c8ffd
commit 5c0d795bce

View File

@ -59,8 +59,12 @@ if (($hassiteconfig || has_any_capability(array(
$backpacks = badges_get_site_backpacks();
$choices = array();
$defaultchoice = 0;
foreach ($backpacks as $backpack) {
$choices[$backpack->id] = $backpack->backpackweburl;
if ($backpack->backpackweburl == BADGRIO_BACKPACKWEBURL) {
$defaultchoice = $backpack->id;
}
}
$globalsettings->add(new admin_setting_configcheckbox('badges_allowcoursebadges',
@ -100,11 +104,10 @@ if (($hassiteconfig || has_any_capability(array(
new lang_string('allowexternalbackpack', 'badges'),
new lang_string('allowexternalbackpack_desc', 'badges'), 1));
$bp = $DB->get_record('badge_external_backpack', ['backpackweburl' => BADGRIO_BACKPACKWEBURL]);
$backpacksettings->add(new admin_setting_configselect('badges_site_backpack',
new lang_string('sitebackpack', 'badges'),
new lang_string('sitebackpack_help', 'badges'),
$bp->id, $choices));
$defaultchoice, $choices));
$ADMIN->add('badges', $backpacksettings);