Feat: Implement Volunteer Badge System for Engagement & Gamification in eHRS
📄 Issue Description
🔍 Overview
To enhance volunteer engagement and motivation in the eHRS application, we need to introduce a badge-based gamification system. This system will reward volunteers based on their participation, consistency, and milestones achieved during medical camps.
The badges will be automatically awarded based on predefined criteria derived from volunteer activity (e.g., number of visits, consecutive participation).
🎯 Objectives
- Encourage consistent participation in medical camps
- Recognize volunteer contributions and milestones
- Improve user retention through gamification
- Provide visual achievements on user profiles and leaderboard
🏅 Badge Definitions & Criteria
| Badge Name | Criteria |
|---|---|
|
|
Completed first camp visit |
|
|
Completed 3 camp visits |
|
|
Completed 5 camp visits |
|
|
Attended 3 consecutive camps |
|
|
Completed 10+ camp visits |
|
|
Completed 6 camp visits |
|
|
Completed 12 camp visits |
|
|
Completed 20 camp visits |
|
|
Completed 36 camp visits |
⚙ ️ Functional Requirements
-
Badge Evaluation Logic
- Automatically evaluate badges based on:
- Total visits count
- Consecutive visits tracking
- Trigger evaluation:
- After each camp participation update
- Automatically evaluate badges based on:
-
Database Changes
- Create a
badgestable:- id, name, description, criteria
- Create a
user_badgestable:- user_id, badge_id, earned_at
- Create a
-
Backend Implementation
- Service to:
- Calculate eligibility
- Assign new badges
- Ensure:
- No duplicate badge assignment
- Service to:
-
API Updates
- Endpoint to fetch:
- User badges
- Badge progress (optional enhancement)
- Endpoint to fetch:
-
Frontend Updates
- Display badges:
- User profile
- Leaderboard (similar to GitLab compliance badges)
- Show:
- Badge name, icon, and description
- Display badges:
🧠 Edge Cases to Handle
- Avoid duplicate badge assignment
- Handle recalculation if past data is updated
- Ensure correct tracking of consecutive visits
- Multiple badges can be awarded at once
🚀 Acceptance Criteria
- Badges are automatically awarded based on criteria
-
Users can view earned badges in profile -
Badges appear in leaderboard -
No duplicate badges assigned -
Consecutive visit logic works correctly -
System performs efficiently with large user data
-
💡 Future Enhancements (Optional)
- Badge progress tracking (e.g., “2 more visits to Gold”)
- AI-based personalized badge suggestions
- Badge rarity levels (Common, Rare, Epic, Legendary)