MDL-66357 core_badges: remove mozilla backpack references

Mozilla backpack closed a few months ago. It was moved to Badgr.io
(as OBv1.0) but as we're also supporting Badgr.io OBv2.0, it
makes no sense to leave old references to Mozilla backpack there.
This commit is contained in:
Sara Arjona 2020-03-24 09:55:40 +01:00
parent 1d4fdb0d1c
commit f958f5c19b
18 changed files with 65 additions and 72 deletions

View File

@ -100,10 +100,11 @@ 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'),
1, $choices));
$bp->id, $choices));
$warning = badges_verify_site_backpack();
if (!empty($warning)) {

View File

@ -75,6 +75,10 @@ class core_badges_badgeslib_testcase extends advanced_testcase {
$this->badgeid = $DB->insert_record('badge', $fordb, true);
// Set the default Issuer (because OBv2 needs them).
set_config('badges_defaultissuername', $fordb->issuername);
set_config('badges_defaultissuercontact', $fordb->issuercontact);
// Create a course with activity and auto completion tracking.
$this->course = $this->getDataGenerator()->create_course(array('enablecompletion' => true));
$this->user = $this->getDataGenerator()->create_user();
@ -670,7 +674,7 @@ class core_badges_badgeslib_testcase extends advanced_testcase {
// Get assertion.
$award = reset($awards);
$assertion = new core_badges_assertion($award->uniquehash);
$assertion = new core_badges_assertion($award->uniquehash, OPEN_BADGES_V1);
$testassertion = $this->assertion;
// Make sure JSON strings have the same structure.

View File

@ -16,8 +16,9 @@ Feature: Add badges to the system
And I press "Save changes"
And I follow "Badges"
When I follow "Add a new badge"
Then the field "issuercontact" matches value "testuser@example.com"
And the field "issuername" matches value "Test Badge Site"
And I press "Issuer details"
Then I should see "testuser@example.com"
And I should see "Test Badge Site"
@javascript
Scenario: Accessing the badges
@ -38,8 +39,6 @@ Feature: Add badges to the system
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
| issuername | Test Badge Site |
| issuercontact | testuser@example.com |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
When I press "Create badge"
Then I should see "Edit details"
@ -62,8 +61,6 @@ Feature: Add badges to the system
| Description | Test badge related description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
| issuername | Test Badge Site |
| issuercontact | testuser@example.com |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I wait until the page is ready
@ -77,8 +74,6 @@ Feature: Add badges to the system
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
| issuername | Test Badge Site |
| issuercontact | testuser@example.com |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I follow "Related badges (0)"
@ -101,8 +96,6 @@ Feature: Add badges to the system
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
| issuername | Test Badge Site |
| issuercontact | testuser@example.com |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
When I press "Create badge"
Then I should see "Edit details"
@ -127,8 +120,6 @@ Feature: Add badges to the system
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
| issuername | Test Badge Site |
| issuercontact | testuser@example.com |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
When I press "Create badge"
Then I should see "Test Badge"
@ -161,8 +152,6 @@ Feature: Add badges to the system
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
| issuername | Test Badge Site |
| issuercontact | testuser@example.com |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
Then I should see "Edit details"

View File

@ -25,7 +25,6 @@ Feature: Award badges
And I set the following fields to these values:
| Name | Course Badge 1 |
| Description | Course badge 1 description |
| issuername | Tester of course badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
@ -43,7 +42,6 @@ Feature: Award badges
And I set the following fields to these values:
| Name | Course Badge 2 |
| Description | Course badge 2 description |
| issuername | Tester of course badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
# Set "course badge 1" as criteria
@ -102,8 +100,6 @@ Feature: Award badges
And I set the following fields to these values:
| Name | Profile Badge |
| Description | Test badge description |
| issuername | Test Badge Site |
| issuercontact | testuser@example.com |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Profile completion"
@ -140,7 +136,6 @@ Feature: Award badges
And I set the following fields to these values:
| Name | Site Badge |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
@ -183,7 +178,6 @@ Feature: Award badges
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
| issuername | Tester of course badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
@ -235,7 +229,6 @@ Feature: Award badges
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
| issuername | Tester of course badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Activity completion"
@ -290,7 +283,6 @@ Feature: Award badges
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
| issuername | Tester of course badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Course completion"
@ -340,7 +332,6 @@ Feature: Award badges
And I set the following fields to these values:
| Name | Course Badge 1 |
| Description | Course badge description |
| issuername | Tester of course badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
@ -366,7 +357,6 @@ Feature: Award badges
And I set the following fields to these values:
| Name | Course Badge 2 |
| Description | Course badge description |
| issuername | Tester of course badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
@ -423,7 +413,6 @@ Feature: Award badges
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
| issuername | Tester of course badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"

View File

@ -41,7 +41,6 @@ Feature: Award badges with separate groups
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
| issuername | Tester of course badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"

View File

@ -40,7 +40,6 @@ Feature: Award badges based on activity completion
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
| issuername | Tester of course badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Activity completion"

View File

@ -23,7 +23,6 @@ Feature: Award badges based on cohort
And I set the following fields to these values:
| Name | Site Badge |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Cohort membership"
@ -59,7 +58,6 @@ Feature: Award badges based on cohort
And I set the following fields to these values:
| Name | Site Badge |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Cohort membership"
@ -100,7 +98,6 @@ Feature: Award badges based on cohort
And I set the following fields to these values:
| Name | Site Badge |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Cohort membership"
@ -137,7 +134,6 @@ Feature: Award badges based on cohort
And I set the following fields to these values:
| Name | Site Badge |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Cohort membership"
@ -188,7 +184,6 @@ Feature: Award badges based on cohort
And I set the following fields to these values:
| Name | Site Badge |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Cohort membership"
@ -245,7 +240,6 @@ Feature: Award badges based on cohort
And I set the following fields to these values:
| Name | Site Badge |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Cohort membership"
@ -302,7 +296,6 @@ Feature: Award badges based on cohort
And I set the following fields to these values:
| Name | Site Badge |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Cohort membership"
@ -360,7 +353,6 @@ Feature: Award badges based on cohort
And I set the following fields to these values:
| Name | Site Badge 1 |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Cohort membership"
@ -373,7 +365,6 @@ Feature: Award badges based on cohort
And I set the following fields to these values:
| Name | Site Badge 2 |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Cohort membership"
@ -415,7 +406,6 @@ Feature: Award badges based on cohort
And I set the following fields to these values:
| Name | Site Badge 1 |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Cohort membership"
@ -430,7 +420,6 @@ Feature: Award badges based on cohort
And I set the following fields to these values:
| Name | Site Badge 2 |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Cohort membership"

View File

@ -44,7 +44,6 @@ Feature: Award badges based on competency completion
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
| issuername | Tester of course badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
# Set the competency as a criteria for the badge
@ -89,7 +88,6 @@ Feature: Award badges based on competency completion
And I set the following fields to these values:
| Name | Site Badge |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
# Set the competency as a criteria for the badge
@ -142,7 +140,6 @@ Feature: Award badges based on competency completion
And I set the following fields to these values:
| Name | Site Badge |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
# Set the competency as a criteria for the badge

View File

@ -14,7 +14,6 @@ Feature: Award badges based on user profile field
And I set the following fields to these values:
| Name | Site Badge |
| Description | Site badge description |
| issuername | Tester of site badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Profile completion"

View File

@ -26,7 +26,6 @@ Feature: Test role visibility for the badge administration page
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
| issuername | Tester of course badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
@ -42,7 +41,6 @@ Feature: Test role visibility for the badge administration page
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
| issuername | Tester of course badge |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the following fields to these values:

View File

@ -1,5 +1,9 @@
This files describes API changes in /badges/*,
information provided here is intended especially for developers.
=== 3.9 ===
* BADGE_BACKPACKAPIURL and BADGE_BACKPACKWEBURL are deprecated and should not be used.
=== 3.7 ===
* BADGE_BACKPACKURL is deprecated and should not be used.
* Incorrect term "badge competencies" has been refactored to "alignments" everywhere.

View File

@ -33,23 +33,6 @@ defined('MOODLE_INTERNAL') || die();
function badges_install_default_backpacks() {
global $DB;
$record = new stdClass();
$record->backpackweburl = 'https://backpack.openbadges.org';
$record->backpackapiurl = 'https://backpack.openbadges.org';
$record->apiversion = 1;
$record->sortorder = 0;
$record->password = '';
if (!($bp = $DB->get_record('badge_external_backpack', array('backpackapiurl' => $record->backpackapiurl)))) {
$bpid = $DB->insert_record('badge_external_backpack', $record);
} else {
$bpid = $bp->id;
}
set_config('badges_site_backpack', $bpid);
// All existing backpacks default to V1.
$DB->set_field('badge_backpack', 'externalbackpackid', $bpid);
$record = new stdClass();
$record->backpackapiurl = 'https://api.badgr.io/v2';
$record->backpackweburl = 'https://badgr.io';
@ -57,9 +40,16 @@ function badges_install_default_backpacks() {
$record->sortorder = 1;
$record->password = '';
if (!$DB->record_exists('badge_external_backpack', array('backpackapiurl' => $record->backpackapiurl))) {
$DB->insert_record('badge_external_backpack', $record);
$bp = $DB->get_record('badge_external_backpack', ['backpackapiurl' => $record->backpackapiurl]);
if ($bp) {
$bpid = $bp->id;
} else {
$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);
}

View File

@ -21,7 +21,6 @@ Feature: Enable Block Badges in a course
And I set the following fields to these values:
| id_name | Badge 1 |
| id_description | Badge 1 |
| id_issuername | Teacher 1 |
And I upload "blocks/badges/tests/fixtures/badge.png" file to "Image" filemanager
And I press "Create badge"
And I select "Manual issue by role" from the "Add badge criteria" singleselect
@ -39,7 +38,6 @@ Feature: Enable Block Badges in a course
And I set the following fields to these values:
| id_name | Badge 2 |
| id_description | Badge 2 |
| id_issuername | Teacher 1 |
And I upload "blocks/badges/tests/fixtures/badge.png" file to "Image" filemanager
And I press "Create badge"
And I select "Manual issue by role" from the "Add badge criteria" singleselect

View File

@ -21,7 +21,6 @@ Feature: Enable Block Badges on the dashboard and view awarded badges
And I set the following fields to these values:
| id_name | Badge 1 |
| id_description | Badge 1 |
| id_issuername | Teacher 1 |
And I upload "blocks/badges/tests/fixtures/badge.png" file to "Image" filemanager
And I press "Create badge"
And I select "Manual issue by role" from the "Add badge criteria" singleselect

View File

@ -26,7 +26,6 @@ Feature: Enable Block Badges on the frontpage and view awarded badges
And I set the following fields to these values:
| id_name | Badge 1 |
| id_description | Badge 1 |
| id_issuername | Teacher 1 |
And I upload "blocks/badges/tests/fixtures/badge.png" file to "Image" filemanager
And I press "Create badge"
And I select "Manual issue by role" from the "Add badge criteria" singleselect

View File

@ -96,8 +96,6 @@ define('BADGE_MESSAGE_MONTHLY', 4);
/*
* URL of backpack. Custom ones can be added.
*/
define('BADGE_BACKPACKAPIURL', 'https://backpack.openbadges.org');
define('BADGE_BACKPACKWEBURL', 'https://backpack.openbadges.org');
define('BADGRIO_BACKPACKAPIURL', 'https://api.badgr.io/v2');
define('BADGRIO_BACKPACKWEBURL', 'https://badgr.io');
@ -106,6 +104,12 @@ define('BADGRIO_BACKPACKWEBURL', 'https://badgr.io');
*/
define('BADGE_BACKPACKURL', 'https://backpack.openbadges.org');
/*
* @deprecated since 3.9 (MDL-66357).
*/
define('BADGE_BACKPACKAPIURL', 'https://backpack.openbadges.org');
define('BADGE_BACKPACKWEBURL', 'https://backpack.openbadges.org');
/*
* Open Badges specifications.
*/

View File

@ -2212,5 +2212,40 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2020013000.01);
}
if ($oldversion < 2020040200.01) {
// Remove deprecated Mozilla OpenBadges backpack.
$url = 'https://backpack.openbadges.org';
$bp = $DB->get_record('badge_external_backpack', ['backpackapiurl' => $url]);
if ($bp) {
// Remove connections for users to this backpack.
$sql = "SELECT DISTINCT bb.id
FROM {badge_backpack} bb
LEFT JOIN {badge_external} be ON be. backpackid = bb.externalbackpackid
WHERE bb.externalbackpackid = :backpackid";
$params = ['backpackid' => $bp->id];
$externalbackpacks = $DB->get_fieldset_sql($sql, $params);
if ($externalbackpacks) {
list($sql, $params) = $DB->get_in_or_equal($externalbackpacks);
// Delete user external collections references to this backpack.
$DB->execute("DELETE FROM {badge_external} WHERE backpackid " . $sql, $params);
}
$DB->delete_records('badge_backpack', ['externalbackpackid' => $bp->id]);
// Delete deprecated backpack entry.
$DB->delete_records('badge_external_backpack', ['backpackapiurl' => $url]);
}
// Set active external backpack to Badgr.io.
$url = 'https://api.badgr.io/v2';
if ($bp = $DB->get_record('badge_external_backpack', ['backpackapiurl' => $url])) {
set_config('badges_site_backpack', $bp->id);
} else {
unset_config('badges_site_backpack');
}
upgrade_main_savepoint(true, 2020040200.01);
}
return true;
}

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2020040200.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2020040200.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '3.9dev (Build: 20200402)'; // Human-friendly version name