mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-70911 core_badges: Remove $CFG->badges_site_backpack
The $CFG->badges_site_backpack setting has been completely removed because it's not required anymore. From now, the primary site backpack will be the first one in the "Manage backpacks" list (so, the one with lower sortorder value).
This commit is contained in:
parent
066e998400
commit
49c1d41a60
13 changed files with 74 additions and 56 deletions
|
@ -78,7 +78,8 @@ class backpack extends external_backpack {
|
|||
}
|
||||
$mform->addElement('select', 'externalbackpackid', get_string('backpackprovider', 'badges'), $choices);
|
||||
$mform->setType('externalbackpackid', PARAM_INT);
|
||||
$mform->setDefault('externalbackpackid', $CFG->badges_site_backpack);
|
||||
$defaultbackpack = badges_get_site_primary_backpack();
|
||||
$mform->setDefault('externalbackpackid', $defaultbackpack->id);
|
||||
$mform->hideIf('password', 'externalbackpackid', 'in', $restrictedoptions);
|
||||
$mform->hideIf('backpackemail', 'externalbackpackid', 'in', $restrictedoptions);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class external_backpacks_page implements \renderable {
|
|||
* @return stdClass
|
||||
*/
|
||||
public function export_for_template(\renderer_base $output) {
|
||||
global $CFG, $PAGE;
|
||||
global $PAGE;
|
||||
|
||||
$PAGE->requires->js_call_amd('core_badges/backpackactions', 'init');
|
||||
|
||||
|
@ -71,7 +71,6 @@ class external_backpacks_page implements \renderable {
|
|||
$exporter = new backpack_exporter($backpack);
|
||||
$backpack = $exporter->export($output);
|
||||
$backpack->cantest = ($backpack->apiversion == OPEN_BADGES_V2);
|
||||
$backpack->iscurrent = ($backpack->id == $CFG->badges_site_backpack);
|
||||
$backpack->canmoveup = $rownumber > 0;
|
||||
$backpack->canmovedown = $rownumber < $rowcount - 1;
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{{#str}}backpackweburl, core_badges{{/str}}</th>
|
||||
<th scope="col">{{#str}}sitebackpack, core_badges{{/str}}</th>
|
||||
<th scope="col">{{#str}}order{{/str}}</th>
|
||||
<th scope="col">{{#str}}actions, core_badges{{/str}}</th>
|
||||
</tr>
|
||||
|
@ -55,7 +54,6 @@
|
|||
{{#backpacks}}
|
||||
<tr data-backpackurl="{{{backpackweburl}}}">
|
||||
<td> {{{backpackweburl}}} </td>
|
||||
<td> {{#sitebackpack}}Yes{{/sitebackpack}} </td>
|
||||
<td>
|
||||
{{#canmoveup}}
|
||||
<a href="{{baseurl}}?id={{id}}&action=moveup">{{#pix}}t/up, core,{{#str}}moveup{{/str}}{{/pix}}</a>
|
||||
|
@ -72,11 +70,11 @@
|
|||
</td>
|
||||
<td>
|
||||
<a href="{{baseurl}}?id={{id}}&action=edit">{{#pix}}t/edit, core,{{#str}}editsettings{{/str}}{{/pix}}</a>
|
||||
{{^iscurrent}}
|
||||
{{^sitebackpack}}
|
||||
<a href="{{baseurl}}?id={{id}}&action=delete" role="button" data-action="deletebackpack">
|
||||
{{#pix}}t/delete, core,{{#str}}delete{{/str}}{{/pix}}
|
||||
</a>
|
||||
{{/iscurrent}}
|
||||
{{/sitebackpack}}
|
||||
{{#cantest}}
|
||||
<a href="{{baseurl}}?id={{id}}&action=test">{{#pix}}t/check, core,{{#str}}testsettings, core_badges{{/str}}{{/pix}}</a>
|
||||
{{/cantest}}
|
||||
|
|
|
@ -1196,6 +1196,7 @@ class core_badges_badgeslib_testcase extends advanced_testcase {
|
|||
'apiversion' => 2,
|
||||
'backpackapiurl' => 'https://api.ca.badgr.io/v2',
|
||||
'backpackweburl' => 'https://ca.badgr.io',
|
||||
'sortorder' => 2,
|
||||
];
|
||||
|
||||
// Given a complete set of unique data, a new backpack and auth records should exist in the tables.
|
||||
|
@ -1204,10 +1205,13 @@ class core_badges_badgeslib_testcase extends advanced_testcase {
|
|||
$backpack1 = badges_save_external_backpack((object) $data);
|
||||
$data['backpackweburl'] = 'https://eu.badgr.io';
|
||||
$data['backpackapiurl'] = 'https://api.eu.badgr.io/v2';
|
||||
$data['apiversion'] = 2.1;
|
||||
$data['apiversion'] = '2.1';
|
||||
$data['sortorder'] = 3;
|
||||
$backpack2 = badges_save_external_backpack((object) $data);
|
||||
|
||||
set_config('badges_site_backpack', $backpack2);
|
||||
// Move backpack2 to the first position to set it as primary site backpack.
|
||||
$this->move_backpack_to_first_position($backpack2);
|
||||
|
||||
// The default response should check the default site backpack api version.
|
||||
$this->assertEquals(2.1, badges_open_badges_backpack_api());
|
||||
// Check the api version for the other backpack created.
|
||||
|
@ -1308,6 +1312,7 @@ class core_badges_badgeslib_testcase extends advanced_testcase {
|
|||
'apiversion' => '2',
|
||||
'backpackapiurl' => 'https://api.ca.badgr.io/v2',
|
||||
'backpackweburl' => 'https://ca.badgr.io',
|
||||
'sortorder' => '2',
|
||||
];
|
||||
if ($withauth) {
|
||||
$data = array_merge($data, [
|
||||
|
@ -1317,7 +1322,13 @@ class core_badges_badgeslib_testcase extends advanced_testcase {
|
|||
}
|
||||
$backpack = badges_save_external_backpack((object) $data);
|
||||
|
||||
set_config('badges_site_backpack', $backpack);
|
||||
// Check the backpack created is not the primary one.
|
||||
$sitebackpack = badges_get_site_primary_backpack();
|
||||
$this->assertNotEquals($backpack, $sitebackpack->id);
|
||||
|
||||
// Move backpack to the first position to set it as primary site backpack.
|
||||
$this->move_backpack_to_first_position($backpack);
|
||||
|
||||
$sitebackpack = badges_get_site_primary_backpack();
|
||||
$this->assertEquals($backpack, $sitebackpack->id);
|
||||
|
||||
|
@ -1512,4 +1523,17 @@ class core_badges_badgeslib_testcase extends advanced_testcase {
|
|||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the backpack to the first position, to set it as primary site backpack.
|
||||
*
|
||||
* @param int $backpackid The backpack identifier.
|
||||
*/
|
||||
private function move_backpack_to_first_position(int $backpackid): void {
|
||||
$backpack = badges_get_site_backpack($backpackid);
|
||||
while ($backpack->sortorder > 1) {
|
||||
badges_change_sortorder_backpacks($backpackid, BACKPACK_MOVE_UP);
|
||||
$backpack = badges_get_site_backpack($backpackid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,10 +43,8 @@ Feature: Backpack badges
|
|||
And I set the following fields to these values:
|
||||
| External backpack connection | 1 |
|
||||
And I press "Save changes"
|
||||
And I navigate to "Badges > Backpack settings" in site administration
|
||||
And I set the following fields to these values:
|
||||
| Active external backpack | https://dc.imsglobal.org |
|
||||
And I press "Save changes"
|
||||
And I navigate to "Badges > Manage backpacks" in site administration
|
||||
And I click on "Move up" "link" in the "https://dc.imsglobal.org" "table_row"
|
||||
And I navigate to "Badges > Add a new badge" in site administration
|
||||
And I set the following fields to these values:
|
||||
| Name | Test badge verify backpack |
|
||||
|
@ -82,10 +80,8 @@ Feature: Backpack badges
|
|||
And I set the following fields to these values:
|
||||
| External backpack connection | 1 |
|
||||
And I press "Save changes"
|
||||
And I navigate to "Badges > Backpack settings" in site administration
|
||||
And I set the following fields to these values:
|
||||
| Active external backpack | https://dc.imsglobal.org |
|
||||
And I press "Save changes"
|
||||
And I navigate to "Badges > Manage backpacks" in site administration
|
||||
And I click on "Move up" "link" in the "https://dc.imsglobal.org" "table_row"
|
||||
And I navigate to "Badges > Add a new badge" in site administration
|
||||
And I set the following fields to these values:
|
||||
| Name | Test badge verify backpack |
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
This files describes API changes in /badges/*,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 3.11 ===
|
||||
* $CFG->badges_site_backpack setting has been completely removed because it's not required anymore. From now, the primary
|
||||
site backpack will be the first one in the "Manage backpacks" list (so, the one with lower sortorder value).
|
||||
|
||||
=== 3.10 ===
|
||||
* Users can now specify a backpack that differs from the site backpack. In order to do this, connection details need to
|
||||
be set in 'Manage backpacks' with OR without auth details.
|
||||
|
|
|
@ -47,9 +47,6 @@ function badges_install_default_backpacks() {
|
|||
$bpid = $DB->insert_record('badge_external_backpack', $record);
|
||||
}
|
||||
|
||||
set_config('badges_site_backpack', $bpid);
|
||||
|
||||
// Set external backpack to v2.
|
||||
$DB->set_field('badge_backpack', 'externalbackpackid', $bpid);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue