Skip to main content
CodePlanet Docs

Weak Topic Detection

AI-powered learning gap identification

CodePlanet's Weak Topic Detection system is an AI-powered feature that automatically identifies areas where you need more practice. Instead of randomly solving problems, you get personalized recommendations based on your actual performance data.

How It Works

The weak topic detection system analyzes three key metrics for each topic:

1. Success Rate

success_rate = correct_attempts / total_attempts

Topics where you have a success rate below your overall average are flagged as potential weak areas.

2. Attempt Volume

We consider how many problems you've attempted in each topic. A topic with only 2 attempts isn't as reliable an indicator as one with 20+ attempts.

3. Recency

Recent performance matters more than old data. A topic you struggled with 6 months ago but have since mastered shouldn't be flagged.

Weakness Score Calculation

Each topic gets a weakness score from 0-100:

weakness_score = (
  (1 - success_rate) * 0.5 +           // 50% weight on failure rate
  recency_factor * 0.3 +                // 30% weight on recent struggles
  consistency_penalty * 0.2             // 20% weight on inconsistency
) * 100

Topics with scores above 60 are considered weak and appear in your dashboard.

The Learning Pipeline

┌──────────────────────┐
│  Problem Submission  │
└──────────┬───────────┘

┌──────────────────────┐
│  Extract Topics      │
│  (from problem tags) │
└──────────┬───────────┘

┌──────────────────────┐
│  Record Attempt      │
│  success/failure     │
└──────────┬───────────┘

┌──────────────────────┐
│  Recalculate Scores  │
│  (database trigger)  │
└──────────┬───────────┘

┌──────────────────────┐
│  Update Dashboard    │
│  (real-time)         │
└──────────────────────┘

Database Schema

The weak topic detection system uses the topic_performance table:

CREATE TABLE topic_performance (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id UUID NOT NULL REFERENCES auth.users(id),
  topic TEXT NOT NULL,
  total_attempts INT DEFAULT 0,
  correct_attempts INT DEFAULT 0,
  last_attempt_at TIMESTAMPTZ,
  weakness_score DECIMAL(5,2) DEFAULT 0,
  created_at TIMESTAMPTZ DEFAULT NOW(),
  updated_at TIMESTAMPTZ DEFAULT NOW(),
  
  CONSTRAINT unique_user_topic UNIQUE (user_id, topic)
);

A PostgreSQL trigger automatically recalculates the weakness score after each submission.

API Endpoints

Get Weak Topics

GET /api/v1/learning/weak-topics
Authorization: Bearer <token>

Response:

{
  "success": true,
  "data": {
    "weakTopics": [
      {
        "topic": "dynamic-programming",
        "weakness_score": 78.5,
        "total_attempts": 15,
        "correct_attempts": 4,
        "success_rate": 0.267,
        "recommended_problems": ["dp-001", "dp-002", "dp-003"]
      }
    ],
    "learningProfile": {
      "strongestTopic": "arrays",
      "overallSuccessRate": 0.72,
      "totalProblemsAttempted": 145
    }
  }
}

Record Attempt

POST /api/v1/learning/weak-topics
Authorization: Bearer <token>
Content-Type: application/json
 
{
  "topics": ["dynamic-programming", "memoization"],
  "isCorrect": false
}

Dashboard Widget

The Weak Topics Widget appears on your dashboard and shows:

  • Your top 5 weakest topics
  • Success rate for each topic
  • Recommended problems to practice
  • One-click navigation to practice

Best Practices

When a topic is flagged as weak, the system suggests problems specifically chosen to help you improve. Prioritize these.

2. Don't Game the System

Attempting easy problems in weak topics doesn't help. The system weighs difficulty — harder problems solved in weak topics improve your score faster.

3. Regular Practice

Consistent practice prevents topics from becoming weak. Even 1-2 problems per week in each topic maintains your skills.

4. Review Failed Attempts

Before moving on from a failed attempt, review the solution and understand the concept. This improves future performance.

Privacy

Your topic performance data is:

  • Only visible to you
  • Protected by Row-Level Security
  • Never shared with other users
  • Used only to improve your learning experience

Limitations

The weak topic detection system has some known limitations:

  1. Minimum Data Required — At least 5 attempts in a topic before reliable scoring
  2. Tag Accuracy — Depends on accurate problem tagging
  3. Learning Style — Doesn't account for different learning paces

Next Steps