badgr_badge
Introduction
Badgr Badge is a bridge between Drupal and the badgr.com API service. It allows site administrators to connect their Badgr account, import issuers and badges, and award digital badges to site users through a Badgr Backpack integration.
Open Badges are verifiable digital credentials that represent skills, achievements, or certifications. A Badgr Backpack is a user's personal collection of earned badges on badgr.com, which can be shared on LinkedIn, websites, and social media.
Features
- Connect to a badgr.com account using email and password authentication.
- Import all issuers and badges from badgr.com into Drupal as content.
- Award badges to authenticated users via an AJAX "Add to Backpack" button.
- Automatic token refresh when access tokens expire.
- Prevents duplicate badge awards (checks if user already earned the badge).
- Provides a ready-to-use Views listing page at
/badgr-badges.
Requirements
- Drupal 10 or 11
- Node module (Drupal core)
- File module (Drupal core)
- A badgr.com account with at least one issuer and badge created.
Installation
Install as you would normally install a contributed Drupal module. See: https://www.drupal.org/node/1897420 for further information.
What this module creates
Content types
On installation, this module creates three content types:
1. Badgr Account (badgr_account)
Stores the connection to a badgr.com account. Typically only one node of this type is needed.
Fields:
- Badgr Access Token OAuth access token for API calls.
- Badgr Refresh Token ”Used to refresh expired access tokens.
- Badgr Email The email address of the badgr.com account.
- Badgr Identifier Internal identifier (set to 1 for the primary account).
2. Badgr Issuer (badgr_issuer)
Represents an issuing organization from badgr.com. Issuers are the entities that create and award badges.
Fields:
- Body Description of the issuer.
- Badge Account Reference to the parent Badgr Account node.
- Badges Reference References to all badges belonging to this issuer.
- Issuer Contact Email Contact email for the issuer.
- Issuer Entity ID The unique entity ID from badgr.com.
- Issuer Image Logo/image of the issuer.
- Issuer Website URL The issuer's website.
3. Badgr Badges (badgr_badges)
Represents a badge class (a type of badge that can be awarded).
Fields:
- Body Description of the badge.
- Badge Account Reference to the parent Badgr Account node.
- Badge Earning Criteria Text describing how to earn the badge.
- Badge Earning URL URL with criteria details.
- Badge Entity ID The unique entity ID from badgr.com.
- Badge Image The badge image/icon.
Views
The module creates one view:
Badgr Badges (badgr_badges) available at /badgr-badges
This page displays all imported badges in teaser view mode. Each badge teaser includes an "Add to Backpack" AJAX button that allows logged-in users to earn the badge.
Permissions
- Administer Badgr Badge Access the Badgr configuration form and import badges. Typically assigned to administrators.
- Create Badgr Badge Allows users to create badge content manually.
Configuration and usage
Step 1: Create a badgr.com account
If you do not already have one, create a free account at badgr.com. Then:
- Create at least one Issuer (your organization).
- Create one or more Badge Classes under that issuer.
Step 2: Connect your Badgr account
- Go to Administration > Configuration > System > Badgr Configuration (
/admin/config/system/badgr-badge). - Enter the Badgr Email and Badgr Password for your badgr.com account.
- Click Save configuration.
- If the credentials are valid, a Badgr Account node is automatically created with the access and refresh tokens.
Step 3: Import badges
- After saving valid credentials, an Import badges button appears on the same configuration page.
- Click Import badges.
- The module fetches all issuers and badge classes from your badgr.com account and creates corresponding Drupal content nodes:
- One Badgr Issuer node per issuer (with logo, description, and email).
- One Badgr Badges node per badge class (with image, criteria, and description).
- Check Administration > Content (
/admin/content) to see the imported content. - You can re-import at any time. Existing nodes are updated; new ones are created.
Step 4: Display badges to users
Visit /badgr-badges to see the badge listing page. This is a Views page that shows all imported badges in teaser view mode.
Each badge teaser includes:
- The badge title and description.
- An "Add to Backpack" AJAX button.
You can also embed the badge view as a block, or create your own views using the Badgr Badges content type.
Step 5: Award badges (Add to Backpack)
When a logged-in user clicks "Add to Backpack" on a badge teaser:
- The module checks if the user has already earned this badge (using their Drupal account email).
- If not, it calls the Badgr Assertions API to award the badge.
- The user sees a success message: "Congratulations! Your [Badge Name] Badge is added to your Badgr backpack."
- If already awarded: "Your [Badge Name] Badge is already added to your Badgr backpack."
- The badge then appears in the user's Backpack at badgr.com and can be shared publicly.
Note: The user's Drupal account must have a valid email address, as this is used to identify the recipient on badgr.com.
Troubleshooting
- "There was a problem fetching the Issuers" Your access token may have expired. Go to the config form, re-enter your password, and save again.
-
Badges not appearing on
/badgr-badgesMake sure you clicked "Import badges" after saving your credentials. - "Add to Backpack" does nothing Ensure the badge node has a valid Badge Entity ID and is linked to a Badgr Account with valid tokens.