Re-implemented the SVG scorecard system with class-aware metrics that displays on student README files.
File: OSS-Doorway/src/templates/class-template.svg
Features:
- Class Name in header
- Two Progress Dials:
- Your Progress (0-100%)
- Class Rank (percentile with color coding)
- Quest Information:
- Current Quest ID and Title
- Task completion (e.g., "3/7 complete")
- Class Metrics:
- Class average completion percentage
- Personal Stats:
- Points and XP
- Data collected count (from
storedValues) - Completed quests with badges
- Dynamic Height: Adjusts based on number of completed quests
Location: OSS-Doorway/src/gamification.js (lines ~1616-1713)
- Fetches all students in a class from OSS-Management backend
- Returns array of student data with completion percentages
- Calculates user's rank within the class
- Returns percentile, display text, and color:
- Gold (#FFD700): Top 10%
- Orange (#FFA500): Top 25%
- Blue (#2f80ed): Top 50%
- Green (#00C853): Below 50%
- Computes average completion % across all class students
- Extracts current quest details:
- Quest ID
- Quest title (truncated if >30 chars)
- Task progress (e.g., "3/7")
- Router function that decides which SVG to generate
- If
customGroupIdexists → Class-aware SVG - Otherwise → Legacy individual SVG
- Generates new class-based scorecard
- Fetches class data from management backend
- Calculates class metrics
- Saves to
userCards/{username}-scorecard-{timestamp}.svg
- Original implementation preserved
- Fallback for users without class association
- Saves to
userCards/draft-{timestamp}.svg
Location: OSS-Doorway/src/gamification.js - updateReadme() function
Key Features:
- ✅ Conditional SVG: Only generates for repos starting with
"misanetc" - ✅ Auto-includes: Embeds SVG image in README progress section
- ✅ Graceful fallback: Continues without SVG if generation fails
// Only for repos starting with "misanetc"
const shouldIncludeSVG = repo.toLowerCase().startsWith('misanetc');
if (shouldIncludeSVG) {
const classId = user_data?.customGroupId;
newSVG = await generateSVG(owner, repo, context, user_data, db, classId);
}
// Dynamic section includes SVG
if (newSVG) {
dynamicSection += `\n\n`;
}Task Completion Event
↓
updateReadme() called
↓
Check: repo.startsWith('misanetc')?
↓ YES
Get user's customGroupId
↓
generateSVG() → Router
↓
Has customGroupId?
├─ YES → generateClassAwareSVG()
│ ├─ Fetch class students from backend
│ ├─ Calculate percentile & class avg
│ ├─ Get current quest info
│ ├─ Populate class-template.svg
│ └─ Save to repo
│
└─ NO → generateLegacySVG()
└─ Use original template.svg
↓
Embed SVG in README
↓
Commit README update
MANAGEMENT_BASE_URL: URL to OSS-Management backend- Default:
https://oss-michael-production.up.railway.app
- Default:
- Backend must have endpoints:
GET /api/group/:classId/studentsGET /api/group/:classId
- Repo starts with "misanetc"
- User has
customGroupId - Expected: Class-aware SVG generated and shown
- Repo starts with "misanetc"
- User has NO
customGroupId - Expected: Legacy SVG generated and shown
- Repo does NOT start with "misanetc"
- Expected: NO SVG generated, text-only progress
- Management backend is down
- Expected: Falls back to N/A for class metrics, still generates SVG
| Percentile | Display | Color | Meaning |
|---|---|---|---|
| ≥ 90% | "Top 10%" | Gold | Exceptional |
| ≥ 75% | "Top 25%" | Orange | Excellent |
| ≥ 50% | "Top 50%" | Blue | Good |
| < 50% | "50%" | Green | Making Progress |
OSS-Doorway/
├── src/
│ ├── gamification.js # Main implementation
│ └── templates/
│ ├── template.svg # Legacy individual SVG
│ └── class-template.svg # NEW: Class-aware SVG
└── SVG_SCORECARD_IMPLEMENTATION.md # This file
- Educational Context: Students see their progress relative to class
- Privacy-Conscious: Only shows percentiles, not raw scores
- Motivational: Color-coded ranks encourage progress
- Flexible: Auto-detects class membership
- Backwards Compatible: Works for non-class users
- Targeted Rollout: Only enabled for "misanetc" repos
- Cache class data for 5 minutes to reduce backend calls
- Add cleanup script to remove old scorecard SVGs
- Support custom themes per class
- Add "quest milestone" badges for major achievements
- Show trend arrows (↑ improved, ↓ declined, → stable)
- SVG files are never deleted (accumulate over time)
- Each update creates a new timestamped file
- GitHub caches SVGs aggressively (query param
?helps bust cache) - Class data is fetched on every README update (consider caching)
- Fixed Octokit API Path: Changed from
context.octokit.repostocontext.octokit.rest.repos - Fixed Class ID Extraction: Now correctly extracts base class ID from suffixed IDs
- Example:
68a770b8140b9c0174c13ce7_purple_1760378826454→68a770b8140b9c0174c13ce7 - Fixes 404 errors when fetching class data from management backend
- Example:
- Improved Image URL Format: Using full GitHub raw URL with timestamp cache-busting
- Enhanced Error Handling: Added timeout protection and better fallback behavior
Implementation Date: October 2025
Developer: AI Assistant
Status: ✅ Complete and Tested