Skip to content

Latest commit

 

History

History
181 lines (138 loc) · 5.6 KB

File metadata and controls

181 lines (138 loc) · 5.6 KB

Framework Lesson Validation - Implementation Guide

Overview

Framework lessons (Flask, Django, Spring Boot, Kafka, pandas, etc.) cannot be executed in the platform without installing heavy dependencies. Instead, we provide syntax-only validation with clear user messaging.

172 Python Framework Lessons Breakdown:

  • 146 Realistic Simulations (84.9%): Full implementations that simulate framework behavior and teach concepts

    • Django: 28 lessons (batches 4, 6)
    • Flask: 15 lessons (batch 1) - recategorized 1 core Python lesson
    • pandas: 17 lessons (batch 2)
    • NumPy: 17 lessons (batch 3)
    • scikit-learn: 15 lessons (batch 5) - ML/AI
    • Redis: 15 lessons (batches 1, 6)
    • FastAPI: 12 lessons (batch 2)
    • SQLAlchemy: 12 lessons (batch 4)
    • pytest: 13 lessons (batches 4, 6)
    • Celery: 8 lessons (batch 1)
    • Kafka: 2 lessons (batch 1) - recategorized 2 system design lessons
  • 26 Syntax-Validated Stubs (15.1%): Minimal code that introduces framework concepts

    • boto3 (26) - AWS-specific, requires account for practical learning

Recent Upgrades (December 2025):

  • Batch 1 (43 lessons): Kafka, Redis, Flask, Celery → 180,869 chars
  • Batch 2 (29 lessons): pandas, FastAPI → 140,734 chars
  • Batch 3 (17 lessons): NumPy → 67,541 chars
  • Batch 4 (51 lessons): Django, SQLAlchemy, pytest → 249,293 chars
    • Django: 26 lessons (ORM, Views, DRF, async, signals, testing)
    • SQLAlchemy: 12 lessons (relationships, optimization, pooling)
    • pytest: 13 lessons (fixtures, parametrization, mocking, CI/CD)
  • Batch 5 (15 lessons): scikit-learn ML/AI → 74,625 chars
    • Train-test split, Linear/Logistic Regression, Decision Trees
    • Random Forest, K-Means, Classification Metrics, Cross-Validation
    • Feature Scaling, PCA, GridSearchCV, Pipelines, Ensembles
    • Real-world project: Customer churn prediction
  • Batch 6 (6 lessons): Final cleanup → 10,298 chars
    • Recategorized 4 misclassified lessons (not actually framework lessons)
    • Django: 2 lessons (Deployment Configuration, Caching Strategies)
    • Redis: 1 lesson (Pub/Sub Real-time Messaging)
    • pytest: 1 lesson (Fixtures & Parametrization)
  • Total: 161 new simulations, 723,360 characters of production code
  • Growth: From 22 → 146 simulations (+564% increase!)
  • Coverage: 84.9% of all Python framework lessons now have realistic simulations
  • All simulations include "# In production:" comments showing real framework usage
  • Students can run framework code immediately without installing dependencies

How It Works

1. Lesson Tagging

All 302 framework lessons are now tagged with:

{
  "id": 148,
  "title": "Spring-Style Controller Method",
  "isFramework": true,
  "frameworkName": "Spring",
  ...
}
  • isFramework: Boolean flag indicating this needs external dependencies
  • frameworkName: Name of framework (Flask, Django, Spring, etc.)

2. Syntax Validation

When a framework lesson is run:

Python:

# Syntax-only check (no execution)
try:
    compile(code, '<string>', 'exec')
    return {"success": True, "message": "✓ Syntax valid", "isFramework": True}
except SyntaxError as e:
    return {"success": False, "error": str(e), "isFramework": True}

Java:

# Compile only (don't run)
javac Main.java
# Return compilation result

3. User Messaging

The UI shows clear indicators:

Badge: "Framework Example - {FrameworkName}"

Message:

This lesson demonstrates real {Framework} code.

✓ Your code is syntactically valid
ℹ️ To run this code locally, install: pip install {framework}

Expected Output:
{expectedOutput}

Benefits

✅ Students learn real framework code patterns ✅ Code is verified for syntax errors ✅ Clear expectations set (not executable in platform) ✅ expectedOutput shows what code should produce ✅ Fast validation (no framework installation needed) ✅ Small Docker image (500MB vs 5GB)

Implementation

Current Status

  1. ✅ All framework lessons tagged with isFramework flag
  2. ⏳ Server endpoints updated to handle framework lessons
  3. ⏳ UI updated to show framework badges
  4. ⏳ Clear user messaging added

Server Changes Needed

Update /run/python and /run/java endpoints:

app.post('/run/python', (req, res) => {
    const { code, isFramework, frameworkName } = req.body;

    // If it's a framework lesson, only validate syntax
    if (isFramework) {
        return validatePythonSyntax(code, frameworkName, res);
    }

    // Otherwise, run normally
    executePythonCode(code, res);
});

Frontend Changes Needed

Show badge and message for framework lessons:

if (lesson.isFramework) {
    showFrameworkBadge(lesson.frameworkName);
    showFrameworkMessage(lesson.frameworkName, lesson.expectedOutput);
}

Testing

After implementation:

  1. Test non-framework lesson (should run normally)
  2. Test framework lesson (should show syntax validation only)
  3. Test syntax error in framework lesson (should show error)
  4. Verify UI shows appropriate badges and messages

Rollout Plan

  1. Update server.js with framework validation logic
  2. Update frontend to detect isFramework flag
  3. Add UI badges and messaging
  4. Test with sample lessons
  5. Deploy

FAQ

Q: Can students run framework code at all? A: Yes, locally. The lesson shows them real code + installation instructions.

Q: Does this affect learning? A: No - students learn by reading and typing code, not running it.

Q: What about expectedOutput? A: Still shown - students see what the code should produce.

Q: Can we add real execution later? A: Yes - can provide optional Docker images for power users.