Merge branch 'MDL-70913-310' of git://github.com/sarjona/moodle into MOODLE_310_STABLE

This commit is contained in:
Eloy Lafuente (stronk7)
2021-03-01 14:22:23 +01:00
4 changed files with 23 additions and 7 deletions
+4 -2
View File
@@ -1145,6 +1145,7 @@ class core_badges_badgeslib_testcase extends advanced_testcase {
$data['password'] = 'test';
if ($isadmin || $updatetest) {
$this->setAdminUser();
$lastmax = $DB->get_field_sql('SELECT MAX(sortorder) FROM {badge_external_backpack}');
$backpack = badges_create_site_backpack((object) $data);
}
@@ -1156,8 +1157,9 @@ class core_badges_badgeslib_testcase extends advanced_testcase {
badges_update_site_backpack($backpack, (object)$data);
}
$record = $DB->get_record('badge_external_backpack', ['id' => $backpack]);
$this->assertEquals($record->backpackweburl, $data['backpackweburl']);
$this->assertEquals($record->backpackapiurl, $data['backpackapiurl']);
$this->assertEquals($data['backpackweburl'], $record->backpackweburl);
$this->assertEquals($data['backpackapiurl'], $record->backpackapiurl);
$this->assertEquals($lastmax + 1, $record->sortorder);
$record = $DB->get_record('badge_backpack', ['userid' => 0]);
$this->assertNotEmpty($record);
} else {
+5 -4
View File
@@ -772,8 +772,9 @@ function badges_create_site_backpack($data) {
$context = context_system::instance();
require_capability('moodle/badges:manageglobalsettings', $context);
$count = $DB->count_records('badge_external_backpack');
$data->sortorder = $count;
$max = $DB->get_field_sql('SELECT MAX(sortorder) FROM {badge_external_backpack}');
$data->sortorder = $max + 1;
return badges_save_external_backpack($data);
}
@@ -983,7 +984,7 @@ function badges_get_site_primary_backpack() {
function badges_get_site_backpacks() {
global $DB, $CFG;
$all = $DB->get_records('badge_external_backpack');
$all = $DB->get_records('badge_external_backpack', null, 'sortorder ASC');
foreach ($all as $key => $bp) {
if ($bp->id == $CFG->badges_site_backpack) {
@@ -1379,4 +1380,4 @@ function badges_generate_badgr_open_url($backpack, $type, $externalid) {
return "{$url->get_scheme()}://{$url->get_host()}/public/{$entity}s/$externalid";
}
}
}
+13
View File
@@ -3023,5 +3023,18 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2020110901.03);
}
if ($oldversion < 2020110901.08) {
// Get all the external backpacks and update the sortorder column, to avoid repeated/wrong values. As sortorder was not
// used since now, the id column will be the criteria to follow for re-ordering them with a valid value.
$i = 1;
$records = $DB->get_records('badge_external_backpack', null, 'id ASC');
foreach ($records as $record) {
$record->sortorder = $i++;
$DB->update_record('badge_external_backpack', $record);
}
upgrade_main_savepoint(true, 2020110901.08);
}
return true;
}
+1 -1
View File
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2020110901.07; // 20201109 = branching date YYYYMMDD - do not modify!
$version = 2020110901.08; // 20201109 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '3.10.1+ (Build: 20210226)';// Human-friendly version name