Skip to content

added XP system#717

Open
Mulesneha wants to merge 1 commit into
Charushi06:mainfrom
Mulesneha:main
Open

added XP system#717
Mulesneha wants to merge 1 commit into
Charushi06:mainfrom
Mulesneha:main

Conversation

@Mulesneha
Copy link
Copy Markdown

Related Issue

Closes #273

Summary

Implemented a persistent XP (experience points) system that automatically tracks and rewards users for study activity including time spent studying, task completions, topic completions, and notes completion.

Changes Made

  • Added xp_system.js — Express router with SQLite-backed XP ledger and session tables
  • Added xp_client.js — Browser-side XP client with XPClient, XPWidget, integrateXpWithStore, and attachXpToTimer utilities
  • Added xp_integration.js — Drop-in wiring module; call initXP(store) to activate the full system
  • Patched store.toggleTaskStatus to automatically award XP on task completion
  • Wired Focus Mode timer to track study time and flush XP on session end or page close
  • Added floating XP badge widget (level, XP total, progress bar) that mounts into the existing UI
  • Integrated XP award toasts with the existing Toast utility

Testing

  • Verified XP is awarded correctly for each action type (task done, topic done, notes done, study time)
  • Confirmed anti-abuse guards work: task/note XP awarded only once per ID; topic XP once per day; study time capped at 120 min per call and deduplicated via session token
  • Tested pagehide/beforeunload beacon flush to ensure study time is not lost on tab close
  • Confirmed level computation thresholds (Lv1→2: 100 XP, Lv2→3: 200 XP, etc.)
  • Tested API endpoints manually: GET /api/xp, GET /api/xp/ledger, POST /api/xp/task-done, POST /api/xp/topic-done, POST /api/xp/notes-done, POST /api/xp/study-time, POST /api/xp/award
  • Verified XP widget re-renders correctly on XP change events

Checklist

  • Code follows project style
  • Tested locally
  • No unrelated changes included
  • Documentation updated (if applicable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Implement XP (Experience Points) System for Study Progress Tracking

1 participant