Details
-
Type:
Functional Test
-
Status: Open
-
Priority:
Minor
-
Affects Version/s: Moodle 3.10
-
Fix Version/s: None
-
Component/s: Badges
-
Labels:None
Description
Prerequisites
- A moodle site that can send emails
- A site with public access (use ngrok or similar)
- Create a badgr account on badgr.io (US) we will call it the Badgr user account
- An admin and a student available in the system.
OAuth2 setup for OBv2.1
- Login as admin.
- Access to the "Site home" and "Turn editing on".
- Add a label, upload an image there and save changes.
- Right-click over the uploaded image and copy the image address. You'll need to replace "https://471f8462.ngrok.io/m/stable_master/pluginfile.php/41/mod_label/intro/logo.png" of the next command to the copied image URL.
- Register the oAuth2 service in the IMS Global IdentityServer4 executing the following command, replacing "https://471f8462.ngrok.io/" by your server URL. You'll probably need to adapt "https://471f8462.ngrok.io/m/stable_master/" to your Moodle URL:
curl --location --insecure --request POST 'https://dc.imsglobal.org/obauth/connect/register' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '
{
"client_name": "Badge Moodle",
"client_uri": "https://471f8462.ngrok.io/",
"logo_uri": "https://471f8462.ngrok.io/m/stable_master/pluginfile.php/41/mod_label/intro/logo.png",
"tos_uri": "https://471f8462.ngrok.io/",
"policy_uri": "https://471f8462.ngrok.io/",
"software_id": "stablemaster-testing",
"software_version": "2020041700.01",
"redirect_uris": [
"https://471f8462.ngrok.io/m/stable_master/badges/oauth2callback.php"
],
"token_endpoint_auth_method": "client_secret_basic",
"grant_types": [
"authorization_code",
"refresh_token"
],
"response_types": [
"code"
],
"scope": "https://purl.imsglobal.org/spec/ob/v2p1/scope/profile.update https://purl.imsglobal.org/spec/ob/v2p1/scope/profile.readonly https://purl.imsglobal.org/spec/ob/v2p1/scope/assertion.create https://purl.imsglobal.org/spec/ob/v2p1/scope/assertion.readonly offline_access"
}'
- You should get a result like this. Copy the client_id and the client_secret (you'll need them to configure the oAuth2 service)
{
"client_id": "LGC8WEFTxp8",
"client_secret": "3GAfOtFgflA",
"client_id_issued_at": 1587110808,
"client_secret_expires_at": 1618646808,
"client_name": "Badge OU",
"client_uri": "https://471f8462.ngrok.io/",
"logo_uri": "https://471f8462.ngrok.io/m/stable_master-badges/pluginfile.php/41/mod_label/intro/robot-1214536_1920.png",
"tos_uri": "https://471f8462.ngrok.io/",
"policy_uri": "https://471f8462.ngrok.io/",
"software_id": "13dcdc83-fc0d-4c8d-9159-6461da297388",
"software_version": "54dfc83-fc0d-4c8d-9159-6461da297388",
"redirect_uris": [
"https://471f8462.ngrok.io/m/stable_master/badges/oauth2callback.php"
],
"token_endpoint_auth_method": "client_secret_basic",
"grant_types": [
"authorization_code",
"refresh_token"
],
"response_types": [
"code"
],
"scope": "https://purl.imsglobal.org/spec/ob/v2p1/scope/profile.update https://purl.imsglobal.org/spec/ob/v2p1/scope/profile.readonly https://purl.imsglobal.org/spec/ob/v2p1/scope/assertion.create https://purl.imsglobal.org/spec/ob/v2p1/scope/assertion.readonly offline_access"
- Go to "Site administration / Server / OAuth 2 services".
- Create a custom service with the following information:
- Name: "IMS Global"
- Client ID: <previous client_id>
- Client secret: <previous client_secret>
- Enable Authenticate token requests via HTTP headers
- Scopes included in a login request and Scopes included in a login request for offline access: "openid profile email"
- Service base URL: https://dc.imsglobal.org/obauth
- Logo URL: https://dc.imsglobal.org/obauth/icon.jpg
- Save changes.
OBv2.1 setup - Create new backpack
- In Site admin -> Badges -> Manage backpacks
- Create a new backpack with the following details :
- Backpack API URL - https://dc.imsglobal.org/obprovider/ims/ob/v2p1
- Backpack URL - https://dc.imsglobal.org
- API Version - Open Badges v2.1
- OAuth2 services - IMS Global
- Save changes.
- Edit the backpack and set OAuth2 services to IMS Global again
Testing:
- Log in as admin and go to Site administration / Badges / Add a new badge.
- Add a new badge, setting the criteria as Manual issue by role and tick the Teacher and 'Any of the selected roles' options.
- Click the Save button and then the Enable access button.
- Click Recipients and then 'Award badge'. Select the student and award them the badge.
- Change 'Active external backpack' to the IMS Global provider
- Log in as a student, in the user menu (top right), select Preferences then 'Backpack settings' under Badges.
- Enter the Badgr user account email, select 'badgr.io' as the backpack and click the button 'Connect to backpack'.
- Look in your mailbox for a verification email and copy & paste the link to verify your connection to the backpack.
- Back in Moodle, logged in as the student, in the user menu select Preferences then 'Manage badges'.
- Verify that your badge is displayed and click on the badge.
- Click the button 'Add to backpack'.
- Verify that a message 'Added badge to backpack' is displayed.
- Go to https://badgr.io, log in with the Badgr user account and verify that the Moodle badge is displayed correctly (though you may need to be patient and wait a few minutes before the badge is displayed in the Badgr backpack).