Skip to content

Add Achievement System to Progress Tracker - #381

Merged
DeFiVC merged 1 commit into
ChainLearnOfficial:mainfrom
rhemy-arc:rhemy-arc
Aug 31, 2026
Merged

Add Achievement System to Progress Tracker#381
DeFiVC merged 1 commit into
ChainLearnOfficial:mainfrom
rhemy-arc:rhemy-arc

Conversation

@rhemy-arc

Copy link
Copy Markdown
Contributor

Here's a comprehensive PR message for the achievement system implementation:

Add Achievement System to Progress Tracker
Summary
Implements a gamification achievement system that tracks learner milestones to drive engagement and motivate continued learning. The system awards achievements for key learning milestones and makes them queryable via on-chain functions.

Changes

  1. New Data Structures (types.rs):

Added Achievement struct with fields: achievement_type, earned_at, and optional course_id
Added AchievementType enum with values: FirstCourse, PerfectScore, SpeedLearner, CourseMaster, PerfectCourse
Extended ProgressTrackerDataKey enum with: Achievements(Address) and AchievementEarned(Address, AchievementType)
2. Achievement Functions (lib.rs):

earn_achievement(): Internal function that checks for duplicates before awarding achievements
get_achievements(): Public query function to retrieve all achievements for a learner
has_achievement(): Public query to check if a learner has earned a specific achievement type
3. Achievement Triggers:

FirstCourse: Awarded when eligible_for_credential becomes true (course completion)
PerfectScore: Awarded when submitting a quiz with 100% score
CourseMaster: Awarded when completing 5+ courses (checks via get_learner_stats)
4. Events:

Added achievement_earned event emitted when any achievement is earned
Key Features
✅ Achievements are tracked - Each achievement is stored with timestamp and optional course context ✅ Achievements are queryable - get_achievements() returns chronological list, has_achievement() checks specific types ✅ Achievements emit events - achievement_earned events notify indexers in real-time ✅ Achievement types are extensible - Enum-based design allows easy addition of new achievement types

Technical Details
Achievements are stored in two keys: list of all achievements per learner, and deduplication map
Internal earn_achievement() prevents duplicate awards for same achievement type
Achievements automatically trigger when relevant milestones are reached (no manual claiming needed)
Achievement data is persisted with TTL extensions for long-term storage
Testing Considerations
FirstCourse achievement triggers when credential eligibility is reached
PerfectScore achievement triggers on quiz submissions with score=100
CourseMaster achievement triggers when 5+ courses completed
Events are emitted for indexer consumption
Query functions return empty lists for learners with no achievements
Future Extensions
The system is designed to be easily extended with:

Additional achievement types (e.g., PerfectCourse for 100% completion)
SpeedLearner achievement (requires tracking course completion timestamps)
Achievement badges or visual representations in frontend
Achievement-based rewards or leaderboards

Closes #258
Closes #257
Closes #256
Closes #255

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@rhemy-arc Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@DeFiVC
DeFiVC merged commit 8caa928 into ChainLearnOfficial:main Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

. Add learner achievement tracking . Add course enrollment limit . Add admin transfer delay . Add contract initialization verification

3 participants