Overview
The UserMastery model is the core of the adaptive learning system. It tracks user performance at multiple levels:- Topic-level mastery - Overall proficiency in a topic (e.g., “DBMS”)
- Concept-level mastery - Fine-grained tracking of individual concepts within topics
- Learning velocity - Rate of improvement over time
- Adaptive difficulty - Dynamic adjustment based on performance
Architecture
Data Storage Strategy
The system uses a hybrid storage approach:- Relational fields for aggregated metrics (fast queries)
- JSON fields for detailed concept-level data (flexible schema)
- Fast topic-level queries (“What’s my DBMS mastery?”)
- Detailed concept analysis (“Which ACID properties am I weak on?”)
- Efficient API responses (minimal joins required)
Mastery Score Fields
Primary Mastery Metrics
mastery_level (Float, 0-1)
The overall mastery score for a topic, calculated as a weighted combination:< 0.3- Beginner level0.3 - 0.7- Intermediate level> 0.7- Advanced level
semantic_avg (Float, 0-1)
Exponential Moving Average (EMA) of semantic similarity scores between user answers and expected answers.keyword_avg (Float, 0-1)
Exponential Moving Average (EMA) of keyword coverage scores.Why 70/30 Weighting?
Semantic understanding is prioritized over keyword matching because:- Deep comprehension matters more than memorization
- Users can explain concepts in different words
- Prevents gaming the system with keyword stuffing
- Keywords still ensure technical accuracy
Statistics Fields
questions_attempted (Integer)
Total number of questions answered for this topic. Use cases:- Determine if user has enough data for reliable mastery estimates
- Track engagement per topic
- Identify topics that need more practice
correct_count (Integer)
Number of questions withkeyword_score > 0.6.
correct_count / questions_attempted
avg_response_time (Float)
Exponential Moving Average of response times in seconds.- Identify topics requiring more thinking time
- Detect mastery (faster responses on familiar topics)
- Flag potential comprehension issues (very fast but wrong answers)
Learning Velocity
mastery_velocity (Float)
The rate of change in mastery level, calculated after each answer:- Positive → Improving (learning effectively)
- Near zero → Plateauing (may need new strategies)
- Negative → Declining (forgetting or struggling)
+0.05- Good progress+0.15- Rapid learning-0.03- Slight decline0.00- Stagnation
- Adaptive difficulty: Increase difficulty on positive velocity
- Stagnation detection: Recommend resources when velocity near zero
- Early warning: Flag negative velocity for intervention
last_mastery (Float)
The previous mastery level before the most recent update. Use: Historical tracking and velocity calculation validationAdaptive Difficulty System
current_difficulty (String)
Current difficulty level for question generation:"easy", "medium", or "hard".
Default: "medium"
consecutive_good (Integer)
Count of consecutive high-scoring answers (combined score > 0.7).consecutive_poor (Integer)
Count of consecutive low-scoring answers (combined score < 0.4).Difficulty Adjustment Logic
Concept-Level Tracking
concept_masteries (Text/JSON)
The primary field for storing complete concept-level mastery data. Structure:| Field | Type | Description |
|---|---|---|
mastery_level | Float | Concept mastery score (0-1) |
attempts | Integer | Times this concept was sampled in questions |
times_mentioned | Integer | Times user mentioned this concept |
times_missed_when_sampled | Integer | Times user failed to mention when asked |
last_seen | Float | Unix timestamp of last question |
stagnation_count | Integer | Consecutive attempts without improvement |
is_weak | Boolean | True if mastery < 0.5 and multiple misses |
is_strong | Boolean | True if mastery > 0.7 consistently |
priority_score | Float | Sampling priority (higher = more likely to be asked) |
Helper Methods
get_concept_masteries()
Parses JSON and returns concept dictionary.set_concept_masteries(concept_dict)
Serializes and saves concept dictionary.Legacy Concept Fields
These fields are derived fromconcept_masteries for backward compatibility:
missing_concepts (Text/JSON)
JSON array of weak concept names.weak_concepts (Text/JSON)
Same asmissing_concepts - list of concepts with low mastery.
strong_concepts (Text/JSON)
JSON array of strong concept names.concept_stagnation (Text/JSON)
Mapping of concept names to stagnation counts.concept_masteries directly. These legacy fields exist for API compatibility.
How Mastery is Calculated
Mastery Update Flow
When a user answers a question:Advanced Update in AdaptiveController
TheAdaptiveInterviewController performs more sophisticated updates:
- Weakness (low mastery → high priority)
- Miss frequency (often missed → high priority)
- Stagnation (not improving → high priority)
- Recency (long time since last seen → higher priority)
- Velocity (negative velocity → increase priority)
Concept Mastery Tracking
ConceptMastery Class
Fromadaptive_state.py, each concept is tracked with:
Recording Attempts
Priority Score Calculation
Database Operations
Creating Mastery Record
Updating After Answer
Querying Mastery Data
API Response Format
Integration with Adaptive System
The mastery tracking integrates with the adaptive interview system:- Question Generation: Uses
current_difficultyand weak concepts - Concept Sampling: Prioritizes concepts with high
priority_score - Session Planning: Focuses on topics with low
mastery_level - Feedback Generation: Uses
mastery_velocityto provide insights - Progress Tracking: Monitors
mastery_velocityover time
Example: Concept Sampling
Best Practices
- Always check for None values before calculations
- Use transactions when updating multiple records
- Validate scores are in 0-1 range before saving
- Log velocity changes for debugging learning plateaus
- Persist concept data frequently to avoid data loss
- Monitor stagnation counts to trigger interventions
Related Documentation
- Database Schema - Complete database structure
- Adaptive Learning - How mastery tracking powers adaptive learning
- Interview Endpoints - Mastery and interview endpoints