This document describes the enhanced scoring module with gamified progression and unlock mechanics for the diagnosis quiz tool.
The enhanced system combines comprehensive scoring with gamification elements to create an engaging learning experience. It tracks user progress, awards achievements, provides adaptive difficulty recommendations, and maintains detailed performance analytics.
The UserProgress class is the core of the progression system, tracking:
- XP and Levels: Exponential XP scaling with level progression
- Achievements: 24+ achievements across 11 categories
- Streak Tracking: Consecutive correct diagnoses with multipliers
- Specialty Proficiency: Category-specific skill levels (1-10)
- Performance Analytics: Detailed metrics and trend analysis
- Unlock System: Progressive content unlocking based on performance
class UserProgress:
"""Main progression tracking class"""
class Achievement:
"""Achievement definition"""
class SpecialtyProficiency:
"""Category-specific skill tracking"""
class StreakData:
"""Streak tracking with multipliers"""The enhanced Scoring class integrates with the progression system:
- XP Calculation: Based on accuracy, speed, and difficulty
- Clinical Accuracy Scoring: Partial credit for specifiers
- Progression Integration: Automatic updates to user progress
- Achievement Awards: Session-based achievement checking
- Performance Reports: Detailed analytics with recommendations
Base XP = Score × 10
Accuracy Bonus =
- 50% for perfect accuracy (100%)
- 25% for excellent accuracy (90-99%)
- 10% for good accuracy (80-89%)
Time Bonus =
- 20% for <30 seconds per question
- 10% for <60 seconds per question
Difficulty Bonus =
- 15% for advanced cases with 80%+ accuracy
- 25% for expert cases with 70%+ accuracy
Total XP = (Base XP + Accuracy Bonus + Time Bonus + Difficulty Bonus) × Streak Multiplier
- Progression: Level-based achievements
- Skill: Accuracy and competence achievements
- Specialty: Category mastery achievements
- Speed: Quick diagnosis achievements
- Streak: Consecutive correct diagnoses
- Advanced: Complex scenario achievements
- Exploration: Variety-based achievements
- Consistency: Regular practice achievements
- Time-based: Time-specific achievements
- Endurance: Long session achievements
- Resilience: Recovery-based achievements
- Bronze: Basic achievements (10-75 XP)
- Silver: Intermediate achievements (75-150 XP)
- Gold: Advanced achievements (150-250 XP)
-
Beginner (Level 1+)
- Classic textbook presentations
- Low differential complexity
- No time pressure
-
Intermediate (Level 5+)
- Atypical features and comorbidities
- Moderate differential complexity
- Time limits introduced
-
Advanced (Level 15+)
- Complex cases with multiple comorbidities
- High differential complexity
- Challenging time limits
-
Expert (Level 30+)
- Highly atypical presentations
- Very high differential complexity
- Strict time limits
The system recommends appropriate difficulty based on:
- Recent performance accuracy
- Average completion time
- Current unlocked difficulties
- User preferences
if recent_accuracy >= 90 and avg_time < 120:
recommend highest unlocked difficulty
elif recent_accuracy >= 75:
recommend intermediate or advanced
elif recent_accuracy >= 60:
recommend intermediate
else:
recommend beginner- Mood Disorders
- Psychotic Disorders
- Anxiety Disorders
- Personality Disorders
- Substance Use Disorders
- Neurodevelopmental Disorders
- Trauma & Stressor-Related
- Eating Disorders
- Obsessive-Compulsive
- Somatic Symptom
- Sleep-Wake Disorders
- Sexual Dysfunctions
- Gender Dysphoria
- Disruptive Impulse Control
- Neurocognitive Disorders
Level = min(10, int(accuracy / 10) + 1)
Accuracy = (correct_cases / total_cases) × 100- 1-2 correct: 1.0x multiplier
- 3-4 correct: 1.1x multiplier
- 5-9 correct: 1.25x multiplier
- 10-14 correct: 1.5x multiplier
- 15-19 correct: 1.75x multiplier
- 20+ correct: 2.0x multiplier
Streaks persist across days but reset if more than 24 hours pass between correct diagnoses.
The system supports partial credit for diagnosis specifiers:
# Example: Major Depressive Disorder with anxious distress, moderate, recurrent
specifiers = {
'with anxious distress': 0.15,
'moderate': 0.10,
'recurrent': 0.05
}
# Scoring:
# - 70% for correct main diagnosis
# - 30% for correct specifiers (weighted by importance)- Overall accuracy and trends
- Category-specific performance
- Difficulty-specific performance
- Time efficiency analysis
- Improvement trends
- Strength and weakness identification
The system generates comprehensive reports including:
- Session summaries
- Progression status
- Achievement progress
- Performance recommendations
- Unlock status
from modules.scoring import Scoring
from modules.progression import UserProgress
# Create progression system
user_progress = UserProgress("user123", "DrSmith")
# Create scoring with progression
scoring = Scoring(scoring_mode=ScoringMode.PARTIAL, user_progress=user_progress)
# Start quiz session
scoring.start_quiz_session(quiz_data)
# Record answers
scoring.record_answer(1, "MDD", 45.0)
# Calculate scores and update progression
stats = scoring.calculate_scores()
# Get progression report
report = scoring.get_session_progression_report()# With specifiers
specifiers = {
'with anxious distress': 0.15,
'moderate': 0.10,
'recurrent': 0.05
}
score, feedback = scoring.calculate_clinical_accuracy_score(
"Major Depressive Disorder with anxious distress, moderate",
"Major Depressive Disorder",
specifiers
)# Get comprehensive report
report = user_progress.generate_performance_report()
# Get XP breakdown
xp_breakdown = user_progress.get_xp_breakdown()
# Get unlock recommendations
recommendations = user_progress.get_unlock_recommendations()Both UserProgress and Scoring classes support serialization:
# Save user progress
data = user_progress.to_dict()
with open('user_progress.json', 'w') as f:
json.dump(data, f)
# Load user progress
user_progress = UserProgress("user123", "DrSmith")
with open('user_progress.json', 'r') as f:
data = json.load(f)
user_progress.from_dict(data)Achievements are defined in data/achievements.json with:
- Achievement definitions
- Requirements and rewards
- Badge types and categories
- Icon assignments
Difficulty tiers are defined in data/difficulty_tiers.json with:
- Tier characteristics
- Level requirements
- XP ranges
- Unlock conditions
Comprehensive tests are provided:
test_progression_integration.py: Integration teststest_progression_features.py: Feature-specific tests
python3 test_progression_integration.py
python3 test_progression_features.pyThe enhanced scoring system maintains full backward compatibility:
- Existing scoring modes (STRICT, LENIENT, PARTIAL) work unchanged
- All existing methods and properties preserved
- Progression system is optional (can be disabled)
- No breaking changes to existing API
- Leaderboards: Global and category-specific rankings
- Social Features: Achievement sharing and comparison
- Learning Paths: Guided progression through specialties
- Adaptive Learning: AI-powered difficulty adjustment
- Detailed Analytics: Advanced performance insights
- Custom Achievements: User-defined achievement goals
The system is designed for easy extension:
- New achievement types can be added
- Custom difficulty algorithms supported
- Additional specialty categories easily integrated
- Flexible XP calculation formulas
The enhanced scoring and progression system provides a comprehensive gamification framework that enhances the learning experience while maintaining educational rigor. The system balances engagement with clinical accuracy, encouraging both speed and precision in diagnostic skills development.