Skip to main content
CodePlanet Docs

Challenges System

Progressive skill development

CodePlanet's challenges system provides structured, skill-based challenges that help users progress through their coding journey while earning meaningful recognition.

🎯 Challenge Philosophy

Unlike traditional platforms with trivial achievements, CodePlanet challenges are designed to:

  • Demonstrate Real Skills: Each challenge requires actual programming competency
  • Progressive Difficulty: Challenges increase in complexity naturally
  • Practical Application: Focus on real-world problem-solving
  • Meaningful Recognition: Certificates that employers value

🏗️ Challenge Architecture

Challenge Types

1. Platform Challenges

Actions within the CodePlanet platform:

  • Complete learning modules
  • Visit specific pages and features
  • Engage with community features
  • Configure profile and settings

2. Coding Challenges

Programming problems from various sources:

  • Codeforces Problems: Curated competitive programming problems
  • Custom Problems: Platform-created challenges
  • Interview Questions: Real technical interview problems
  • Project Challenges: Build complete applications

3. Learning Challenges

Educational milestones:

  • Complete course sections
  • Pass knowledge checks
  • Demonstrate understanding through practical application
  • Peer review participation

4. Consistency Challenges

Habit-building activities:

  • Daily problem solving streaks
  • Regular learning sessions
  • Community engagement
  • Portfolio updates

Challenge Difficulty Levels

LevelDescriptionExamplesTime Estimate
EasyBasic skill demonstrationSolve 5 easy problems2-5 hours
MediumIntermediate competencyComplete learning path10-25 hours
HardAdvanced problem-solvingSolve 20 medium problems30-60 hours
ExpertMastery levelSystem design project80-150 hours

📊 Challenge Tracking System

Progress Monitoring

// Challenge progress tracking
class ChallengeTracker {
  constructor(userId) {
    this.userId = userId
    this.challenges = new Map()
    this.progressListeners = new Set()
  }
  
  async updateChallenge(challengeId, status) {
    const challenge = this.challenges.get(challengeId)
    if (challenge) {
      challenge.status = status
      challenge.completedAt = status === 'completed' ? new Date() : null
      
      // Notify listeners
      this.progressListeners.forEach(listener => 
        listener(challengeId, challenge)
      )
      
      // Persist to database
      await this.saveProgress(challengeId, challenge)
    }
  }
  
  getProgress(certificationId) {
    const certificationChallenges = this.getCertificationChallenges(certificationId)
    const completed = certificationChallenges.filter(c => c.status === 'completed').length
    return {
      total: certificationChallenges.length,
      completed,
      percentage: (completed / certificationChallenges.length) * 100
    }
  }
}

Real-time Updates

// WebSocket-based progress updates
const useChallengeProgress = (certificationId) => {
  const [progress, setProgress] = useState({ completed: 0, total: 0 })
  const [challenges, setChallenges] = useState([])
  
  useEffect(() => {
    const ws = new WebSocket(`wss://api.codeplanet.live/challenges/${certificationId}`)
    
    ws.onmessage = (event) => {
      const update = JSON.parse(event.data)
      setProgress(update.progress)
      setChallenges(update.challenges)
    }
    
    return () => ws.close()
  }, [certificationId])
  
  return { progress, challenges }
}

🎨 User Interface Components

Challenge Dashboard

function ChallengeDashboard({ certifications }) {
  return (
    <div className="challenge-dashboard">
      <div className="dashboard-header">
        <h2>Your Certifications</h2>
        <p>Track your progress and earn valuable credentials</p>
      </div>
      
      <div className="certifications-grid">
        {certifications.map(cert => (
          <CertificationCard 
            key={cert.id}
            certification={cert}
            onClick={() => openCertificationDetails(cert.id)}
          />
        ))}
      </div>
    </div>
  )
}

Individual Challenge Display

function ChallengeCard({ challenge, onComplete }) {
  const [isStarting, setIsStarting] = useState(false)
  
  const handleStart = async () => {
    setIsStarting(true)
    try {
      // Open challenge in new tab
      window.open(challenge.url, '_blank')
      
      // Track challenge start
      await challengeService.startChallenge(challenge.id)
    } catch (error) {
      console.error('Failed to start challenge:', error)
    } finally {
      setIsStarting(false)
    }
  }
  
  return (
    <div className={`challenge-card ${challenge.status}`}>
      <div className="challenge-content">
        <div className="challenge-header">
          <h3>{challenge.title}</h3>
          <Badge variant={challenge.difficulty}>
            {challenge.difficulty}
          </Badge>
        </div>
        
        <p className="challenge-description">
          {challenge.description}
        </p>
        
        <div className="challenge-meta">
          <span className="estimated-time">
            🕐 {challenge.estimatedTime} hours
          </span>
          {challenge.type && (
            <Badge variant="secondary">{challenge.type}</Badge>
          )}
        </div>
      </div>
      
      <div className="challenge-actions">
        {challenge.status === 'completed' ? (
          <div className="completed-indicator">
            <CheckCircleIcon className="completed-icon" />
            <span>Completed</span>
          </div>
        ) : (
          <Button 
            onClick={handleStart}
            disabled={isStarting}
            className="start-challenge-btn"
          >
            {isStarting ? 'Starting...' : 'Start Challenge'}
          </Button>
        )}
      </div>
    </div>
  )
}

🔧 Backend Implementation

Challenge Validation Service

class ChallengeValidator:
    def __init__(self):
        self.validators = {
            'codeforces': self._validate_codeforces,
            'platform': self._validate_platform,
            'learning': self._validate_learning,
            'streak': self._validate_streak
        }
    
    async def validate_challenge(self, user_id: str, challenge_id: str) -> bool:
        challenge = await self.get_challenge(challenge_id)
        validator = self.validators.get(challenge.type)
        
        if not validator:
            raise ValueError(f"Unknown challenge type: {challenge.type}")
        
        return await validator(user_id, challenge)
    
    async def _validate_codeforces(self, user_id: str, challenge) -> bool:
        user_handle = await self.get_user_codeforces_handle(user_id)
        if not user_handle:
            return False
        
        problem_id = challenge.metadata['problem_id']
        return await self.codeforces_api.check_problem_solved(
            user_handle, problem_id
        )
    
    async def _validate_platform(self, user_id: str, challenge) -> bool:
        # Check platform activity logs
        activity = await self.activity_service.get_user_activity(
            user_id, 
            challenge.metadata['activity_type'],
            challenge.metadata.get('required_count', 1)
        )
        return len(activity) >= challenge.metadata.get('required_count', 1)

Challenge Completion API

@app.post("/api/challenges/{challenge_id}/complete")
async def complete_challenge(
    challenge_id: str,
    user: AuthenticatedUser,
    background_tasks: BackgroundTasks
):
    # Validate challenge completion
    is_valid = await challenge_validator.validate_challenge(
        user.id, challenge_id
    )
    
    if not is_valid:
        raise HTTPException(
            status_code=400,
            detail="Challenge requirements not met"
        )
    
    # Mark challenge as completed
    await challenge_service.mark_completed(user.id, challenge_id)
    
    # Check if certification is earned
    background_tasks.add_task(
        check_certification_completion,
        user.id,
        challenge_id
    )
    
    return {"success": True, "message": "Challenge completed!"}

📈 Analytics and Insights

Progress Analytics

class ChallengeAnalytics:
    def __init__(self):
        self.metrics = {
            'completion_rates': {},
            'time_to_completion': {},
            'drop_off_points': {},
            'user_engagement': {}
        }
    
    async def track_challenge_start(self, user_id: str, challenge_id: str):
        await self.db.insert({
            'user_id': user_id,
            'challenge_id': challenge_id,
            'started_at': datetime.utcnow(),
            'status': 'started'
        })
    
    async def track_challenge_completion(self, user_id: str, challenge_id: str, time_spent: int):
        await self.db.update({
            'user_id': user_id,
            'challenge_id': challenge_id,
            'completed_at': datetime.utcnow(),
            'time_spent': time_spent,
            'status': 'completed'
        })
        
        # Update analytics
        self._update_completion_metrics(challenge_id)
        self._update_time_metrics(challenge_id, time_spent)

User Progress Visualization

function ProgressVisualization({ certification }) {
  const progress = useCertificationProgress(certification.id)
  
  return (
    <div className="progress-visualization">
      <div className="progress-overview">
        <ProgressRing percentage={progress.percentage} />
        <div className="progress-stats">
          <h3>{certification.name}</h3>
          <p>{progress.completed}/{progress.total} challenges completed</p>
          <p>Estimated time remaining: {progress.estimatedTimeRemaining} hours</p>
        </div>
      </div>
      
      <div className="challenge-timeline">
        {progress.challenges.map((challenge, index) => (
          <ChallengeTimelineItem
            key={challenge.id}
            challenge={challenge}
            isCurrent={index === progress.currentChallenge}
          />
        ))}
      </div>
    </div>
  )
}

🛡️ Security and Validation

Challenge Integrity

class ChallengeSecurity:
    def __init__(self):
        self.validation_rules = {
            'minimum_time': 300,  # 5 minutes minimum
            'maximum_attempts': 10,
            'rate_limiting': True
        }
    
    async def validate_completion_integrity(self, user_id: str, challenge_id: str) -> bool:
        # Check for suspicious completion patterns
        recent_completions = await self.get_recent_completions(user_id, timeframe=3600)
        if len(recent_completions) > self.validation_rules['maximum_attempts']:
            return False
        
        # Verify minimum time spent
        challenge_time = await self.get_challenge_time(user_id, challenge_id)
        if challenge_time < self.validation_rules['minimum_time']:
            return False
        
        # Check for automated patterns
        if await self.detect_automation(user_id):
            return False
        
        return True

Anti-Cheat Measures

  • Time-based validation: Minimum time requirements for completion
  • Pattern detection: Identify automated or copied solutions
  • Rate limiting: Prevent rapid completion of multiple challenges
  • Peer review: Manual verification for high-value challenges

🚀 Future Enhancements

Planned Features

  • Adaptive Challenges: AI-generated personalized challenges
  • Team Challenges: Collaborative problem-solving activities
  • Live Coding Challenges: Real-time competitive programming
  • Mentor Challenges: Guided learning with expert feedback
  • Industry Challenges: Real-world project simulations

Integration Opportunities

  • GitHub Integration: Automatic challenge completion tracking
  • LinkedIn Integration: Professional achievement sharing
  • Recruiter Access: Direct access for hiring partners
  • University Partnerships: Academic credit integration

The challenges system is designed to be engaging, educational, and genuinely valuable for career advancement in software development.