# Progress System ## ๐ŸŽฏ Core Philosophy **FUNDAMENTAL RULE**: Every piece of content is a trackable progress item with strict validation and type safety. ## ๐Ÿ—๏ธ Pedagogical Flow ``` 1. DISCOVERY โ†’ 2. MASTERY โ†’ 3. APPLICATION (passive) (active) (context) ``` ### Flow Rules (NON-NEGOTIABLE) - โŒ **NO Flashcards on undiscovered words** - Must discover first - โŒ **NO Text exercises on unmastered vocabulary** - Must master first - โœ… **Always check prerequisites before ANY exercise** - โœ… **Form vocabulary lists on-the-fly** from next exercise content ## ๐Ÿ“ฆ Progress Item Types & Weights | Type | Weight | Prerequisites | |------|--------|---------------| | vocabulary-discovery | 1 | None | | vocabulary-mastery | 1 | Must be discovered | | phrase | 6 | Vocabulary mastered | | dialog | 12 | Vocabulary mastered | | text | 15 | Vocabulary mastered | | audio | 12 | Vocabulary mastered | | image | 6 | Vocabulary discovered | | grammar | 6 | Vocabulary discovered | **Total for 1 vocabulary word** = 2 points (1 discovery + 1 mastery) ## ๐Ÿ“ˆ Progress Calculation ### Chapter Analysis When loading a chapter: 1. **Scans ALL content** (vocabulary, phrases, dialogs, texts, etc.) 2. **Creates progress items** for each piece 3. **Calculates total weight** (sum of all item weights) 4. **Stores item registry** for tracking **Example Chapter:** - 171 vocabulary words โ†’ 342 points (171ร—2: discovery + mastery) - 75 phrases โ†’ 450 points (75ร—6) - 6 dialogs โ†’ 72 points (6ร—12) - 3 lessons โ†’ 45 points (3ร—15) - **TOTAL: 909 points** ### Progress Formula ```javascript percentage = (completedWeight / totalWeight) ร— 100 // Example: // - Discovered 50 words = 50 points // - Mastered 20 words = 20 points // - Completed 3 phrases = 18 points (3ร—6) // - Completed 1 dialog = 12 points // Total completed = 100 points // Progress = (100 / 909) ร— 100 = 11% ``` ### Breakdown Display ```javascript { percentage: 11, completedWeight: 100, totalWeight: 909, breakdown: { 'vocabulary-discovery': { count: 50, weight: 50 }, 'vocabulary-mastery': { count: 20, weight: 20 }, 'phrase': { count: 3, weight: 18 }, 'dialog': { count: 1, weight: 12 } } } ``` ## ๐ŸŽฏ Smart Vocabulary Prerequisites ### OLD Approach (Wrong) Force all 171 words upfront based on arbitrary percentages. ### NEW Approach (Correct) Analyze next content โ†’ extract words โ†’ check user status โ†’ force only needed words. ### Example Flow ```javascript // Next exercise: Dialog "Academic Conference" // Words in dialog: methodology, hypothesis, analysis, paradigm, framework // User status check: // - methodology: never seen โ†’ Discovery needed // - hypothesis: discovered, not mastered โ†’ Mastery needed // - analysis: mastered โ†’ Skip // - paradigm: never seen โ†’ Discovery needed // - framework: discovered, not mastered โ†’ Mastery needed // Smart system creates: // 1. Discovery module: [methodology, paradigm] (2 words) // 2. Mastery module: [hypothesis, framework] (2 words) // 3. Then allow dialog exercise ``` ### Benefits - **Targeted Learning** - Only learn words actually needed - **Context-Driven** - Vocabulary tied to real content usage - **Efficient Progress** - No time wasted on irrelevant words - **Better Retention** - Words learned in context of upcoming usage - **Smart Adaptation** - UI accurately reflects what's happening ## ๐Ÿ”ง Key Components ### 1. ProgressItemInterface Abstract base with strict validation for all progress items. **Location**: `src/DRS/interfaces/ProgressItemInterface.js` **Methods**: - `validate()` - Validate item data - `serialize()` - Convert to JSON - `getWeight()` - Return item weight - `canComplete(state)` - Check prerequisites ### 2. ProgressTracker Manages state, marks completion, saves progress. **Location**: `src/DRS/services/ProgressTracker.js` **Key Methods**: - `markWordDiscovered(word, metadata)` - `markWordMastered(word, metadata)` - `markContentCompleted(type, id, metadata)` - `getProgress(chapterId)` - `saveProgress(bookId, chapterId)` - `loadProgress(bookId, chapterId)` ### 3. PrerequisiteEngine Checks prerequisites and enforces pedagogical flow. **Location**: `src/DRS/services/PrerequisiteEngine.js` **Key Methods**: - `canComplete(itemType, itemId, context)` - `getUnmetPrerequisites(itemType, itemId)` - `enforcePrerequisites(exerciseConfig)` ### 4. ContentDependencyAnalyzer Analyzes content and extracts vocabulary dependencies. **Location**: `src/DRS/services/ContentDependencyAnalyzer.js` **Key Methods**: - `analyzeContentDependencies(nextContent, vocabularyModule)` - `extractWordsFromContent(content)` - `findMissingWords(wordsInContent, vocabularyWords)` ## ๐Ÿ“Š UI Integration ### Progress Display ``` Chapter Progress: 11% (100/909 points) โœ… Vocabulary Discovery: 50/171 words (50pts) โœ… Vocabulary Mastery: 20/171 words (20pts) โœ… Phrases: 3/75 (18pts) โœ… Dialogs: 1/6 (12pts) โฌœ Texts: 0/3 (0/45pts) ``` ### Smart Guide Updates ``` ๐Ÿ” Analyzing next exercise: Dialog "Academic Conference" ๐Ÿ“š 4 words needed (2 discovery, 2 mastery) ๐ŸŽฏ Starting Vocabulary Discovery for: methodology, paradigm ``` ## โœ… Validation Checklist **Before ANY exercise can run:** - [ ] Prerequisites analyzed for next specific content - [ ] Missing words identified - [ ] Discovery forced for never-seen words - [ ] Mastery forced for seen-but-not-mastered words - [ ] Progress item created with correct weight - [ ] Completion properly tracked and saved - [ ] Total progress recalculated **If ANY step fails โ†’ Clear error message, app stops gracefully** ## ๐Ÿšจ Error Prevention ### Compile-Time (Startup) - Interface validation via ImplementationValidator - Method implementation checks - Weight configuration validation ### Runtime - Prerequisite enforcement before exercises - State consistency checks - Progress calculation validation ### Visual Feedback - Red screen for missing implementations - Clear prerequisite errors - Progress breakdown always visible ## ๐Ÿ” Debug Commands ```javascript // Get current progress window.app.getCore().progressTracker.getProgress('chapter-1') // Check if word discovered window.app.getCore().progressTracker.isWordDiscovered('methodology') // Check if word mastered window.app.getCore().progressTracker.isWordMastered('hypothesis') // Check prerequisites window.app.getCore().prerequisiteEngine.canComplete('dialog', 'dialog-3') // Get unmet prerequisites window.app.getCore().prerequisiteEngine.getUnmetPrerequisites('text', 'lesson-1') ``` ## ๐Ÿ“‹ Adding New Progress Item Types 1. Create new class extending `ProgressItemInterface` 2. Implement all 4 required methods 3. Add weight to `WEIGHTS` constant 4. Add to `ImplementationValidator` 5. Update `ProgressTracker` tracking methods 6. Update UI components 7. Test with validation ## ๐Ÿงช Testing Progress System ```javascript // Test progress calculation const tracker = window.app.getCore().progressTracker; // Mark some progress await tracker.markWordDiscovered('test', {}); await tracker.markWordMastered('test', {}); // Check progress const progress = tracker.getProgress('chapter-1'); console.log(progress); // Should show updated percentage and breakdown ``` ## ๐Ÿ“– Further Reading - `docs/interfaces.md` - Interface system details - `docs/creating-new-module.md` - Module creation guide - `README.md` - Project overview