Skip to content

Latest commit

 

History

History
283 lines (222 loc) · 8.8 KB

File metadata and controls

283 lines (222 loc) · 8.8 KB

🎮 Gamification System

Welcome to CodeQuest - the enhanced coding platform with a comprehensive gamification system! This system transforms learning to code into an engaging, rewarding experience with XP, levels, achievements, and collaborative features.

🚀 Features Overview

1. XP & Level System

  • Experience Points (XP): Earn XP for various activities
  • Level Progression: Level up as you gain XP
  • Progress Tracking: Visual progress bars and level indicators
  • Streak System: Maintain daily activity streaks for bonus rewards

2. Achievements & Badges

  • Achievements: Unlock achievements for reaching milestones
  • Badges: Collect rare badges based on your performance
  • Progress Tracking: See your progress toward unlocking achievements
  • Categories: Milestone, streak, contest, collaboration achievements

3. Daily Challenges

  • Daily Problems: New coding challenge every day
  • Bonus XP: Early completion rewards
  • Streak Bonuses: Maintain daily challenge streaks
  • Difficulty Variety: Easy, medium, and hard challenges

4. Collaborative Features

  • Code Reviews: Review and rate other users' submissions
  • Mentorship: Request help from experienced coders
  • Study Groups: Create and join study groups
  • Group Sessions: Schedule collaborative coding sessions

5. Leaderboards

  • Global Rankings: See how you rank against other users
  • Multiple Timeframes: All-time, weekly, and monthly rankings
  • Visual Rankings: Top 3 users highlighted with special styling
  • Statistics: View platform-wide statistics and records

🛠️ Installation & Setup

1. Database Migration

Run the gamification migration to set up the required tables:

cd server
node run_gamification_migration.js

2. Start the Server

The gamification system is automatically integrated into the main server:

cd server
npm start

3. Frontend Integration

The gamification components are automatically included in the React app:

cd client
npm start

📊 XP Rewards System

Activity Rewards

  • Problem Solved: 50 XP
  • Daily Challenge: 50-75 XP (with bonus)
  • Code Review: 10 XP
  • Study Group Created: 50 XP
  • Study Group Joined: 10 XP
  • Achievement Unlocked: Varies (25-500 XP)
  • Badge Earned: 25-250 XP (based on rarity)

Level Progression

  • Level 1: 0 XP
  • Level 2: 100 XP
  • Level 3: 250 XP
  • Level 4: 475 XP
  • Level 5: 812 XP
  • And so on... (exponential growth)

🏆 Achievement System

Milestone Achievements

  • First Steps: Solve your first problem (50 XP)
  • Problem Solver: Solve 10 problems (100 XP)
  • Code Master: Solve 50 problems (250 XP)
  • Algorithm Expert: Solve 100 problems (500 XP)

Streak Achievements

  • Streak Master: Maintain 7-day activity streak (200 XP)

Contest Achievements

  • Contest Champion: Win your first contest (300 XP)

Collaboration Achievements

  • Helper: Help 5 users with code reviews (150 XP)
  • Mentor: Become a mentor to 3 users (400 XP)
  • Study Group Leader: Create and lead a study group (200 XP)

Challenge Achievements

  • Daily Challenger: Complete 5 daily challenges (300 XP)

🎯 Badge System

Rarity Levels

  • Common: 25 XP reward
  • Rare: 50 XP reward
  • Epic: 100 XP reward
  • Legendary: 250 XP reward

Available Badges

  • Newcomer: Welcome to the platform
  • Quick Learner: Level up within your first week
  • Consistent: Maintain activity for 30 days
  • Problem Crusher: Solve problems in 5 different languages
  • Speed Demon: Solve a problem in under 5 minutes
  • Perfect Score: Get 100% on a contest
  • Community Pillar: Receive 50 helpful votes on reviews
  • Code Guru: Reach level 50

🤝 Collaborative Features

Code Reviews

  • Submit reviews on other users' code submissions
  • Rate submissions from 1-5 stars
  • Earn XP for helpful reviews
  • Vote on review helpfulness

Mentorship System

  • Request help from experienced coders
  • Specify problem areas and request messages
  • Track mentorship request status
  • Complete mentorship sessions

Study Groups

  • Create public or private study groups
  • Set maximum member limits
  • Schedule group coding sessions
  • Collaborate on specific problems

📱 User Interface

Dashboard Integration

The gamified dashboard is automatically integrated into the main dashboard, showing:

  • Current level and XP progress
  • Daily challenges
  • Recent achievements
  • Activity streaks
  • Quick access to all gamification features

Navigation Updates

New navigation items include:

  • Dashboard: Enhanced with gamification features
  • Leaderboard: Gamified rankings and statistics
  • Profile: XP and achievement tracking

🔧 API Endpoints

Gamification Routes

All endpoints are prefixed with /api/gamification:

  • GET /stats - Get user gamification stats
  • GET /leaderboard - Get global leaderboard
  • GET /achievements - Get user achievements
  • GET /badges - Get user badges
  • GET /daily-challenge - Get current daily challenge
  • POST /daily-challenge/:id/complete - Complete daily challenge
  • GET /xp-history - Get XP transaction history

Collaborative Features

  • POST /code-reviews - Submit code review
  • GET /submissions/:id/reviews - Get submission reviews
  • POST /mentorship/request - Request mentorship
  • POST /study-groups - Create study group
  • GET /study-groups - Get study groups

🎨 Customization

XP Rewards

Modify reward amounts in gamificationService.js:

// Example: Change problem solved reward
const PROBLEM_SOLVED_XP = 75; // Default: 50

Achievement Requirements

Update achievement thresholds in the migration file:

-- Example: Change "Code Master" requirement
UPDATE achievements 
SET requirement_value = 75 
WHERE name = 'Code Master';

Level Progression

Modify the XP calculation function:

calculateXPForLevel(level) {
  // Custom formula here
  return Math.floor(100 * Math.pow(1.8, level - 1));
}

🚀 Getting Started

For Users

  1. Login/Register: Create an account to start earning XP
  2. Solve Problems: Earn XP for each solved problem
  3. Daily Challenges: Complete daily challenges for bonus XP
  4. Join Study Groups: Collaborate with other coders
  5. Review Code: Help others and earn XP
  6. Track Progress: Monitor your level and achievements

For Developers

  1. Run Migration: Set up the database schema
  2. Start Services: Launch the backend and frontend
  3. Test Features: Verify all gamification features work
  4. Customize: Adjust XP rewards and achievement requirements
  5. Monitor: Track user engagement and system performance

📈 Analytics & Insights

The gamification system provides valuable insights:

  • User Engagement: Track daily active users and retention
  • Learning Progress: Monitor problem-solving patterns
  • Collaboration Metrics: Measure community interaction
  • Achievement Distribution: Understand user motivation

🔮 Future Enhancements

Potential additions to the gamification system:

  • Seasonal Events: Special challenges and rewards
  • Team Competitions: Group-based contests
  • Skill Trees: Specialized learning paths
  • Social Features: Friend systems and challenges
  • Mobile App: Dedicated mobile experience
  • AI Recommendations: Personalized challenge suggestions

🐛 Troubleshooting

Common Issues

  1. XP not updating: Check database connection and service logs
  2. Achievements not unlocking: Verify achievement requirements and user progress
  3. Daily challenges not appearing: Check challenge creation and date logic
  4. Leaderboard not loading: Verify database queries and user data

Debug Mode

Enable debug logging in the gamification service:

// In gamificationService.js
const DEBUG = true;

if (DEBUG) {
  console.log('XP transaction:', { userId, xpAmount, transactionType });
}

📚 Additional Resources

  • Database Schema: See server/database/migrations/002_gamification_system.sql
  • Service Implementation: Review server/services/gamificationService.js
  • API Routes: Check server/routes/gamification.js
  • Frontend Components: Explore client/src/components/GamifiedDashboard.tsx

🤝 Contributing

To contribute to the gamification system:

  1. Fork the repository
  2. Create a feature branch
  3. Implement your changes
  4. Add tests and documentation
  5. Submit a pull request

📄 License

This gamification system is part of the competitive programming platform and follows the same license terms.


Happy Coding! 🎉

Transform your learning journey with gamification and make coding fun, engaging, and rewarding!