Skip to content

week3: call checkAndAward and activities PUT on lesson/puzzle completion - #268

Open
sruju333 wants to merge 2 commits into
mainfrom
week3-wire-completion
Open

sruju333 wants to merge 2 commits into
mainfrom
week3-wire-completion

Conversation

@sruju333

@sruju333 sruju333 commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Wires badge awarding and activity completion into the real lesson and puzzle completion paths. Until now, checkAndAward had no caller outside e2e/seed.ts, and the ?taskId= deep link emitted by ActivitiesModal.tsx was read nowhere. A student who finishes a lesson or puzzle now triggers a badge check and, when they arrived via an activity deep link, marks that daily activity complete.

Type of Change

  • New feature

Key Changes

  • core/services/activitiesApi.ts: Added getActivityNameByTaskId(username, token, taskId). The deep link carries the catalog taskId, but PUT /activities/:username/activity matches on activities.name, so this resolves one to the other. Also fixed the stale @param docstring on completeActivity.
  • Puzzles.tsx: Reads ?taskId= via useSearchParams. In the puzzle-completed branch of handlePlayerMove, calls completeActivity (when a taskId is present) and checkAndAward. Guarded with role === "student" so a mentor in a shared session doesn't trigger these under their own username.
  • Lesson-overlay.tsx: In handleVPopup, right after updateCompletion(), resolves the username via SetPermissionLevel, then calls completeActivity (when ?taskId= is present) and checkAndAward.
  • All new calls are fire-and-forget with .catch logging, so a failed badge or activity call never blocks the success popup.

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • All tests pass

Bugs Fixed (if applicable)

  • The ?taskId= deep link emitted by ActivitiesModal.tsx was never consumed, so daily activities could not be completed through the UI.
  • Badges could only be awarded to the seeded e2e test student, since nothing in the app called checkAndAward.

TODO (Follow-up Work)

  • Info-only lessons (the "Continue" button) call updateCompletion() on a separate path and are not wired to these calls yet. Decide whether they should count.
  • Streak-adjacency defect in utils/studentStats.js:76-92 and routes/streak.js:83-99: ticket filed, link below. Should be fixed before any badge is awarded on a streak threshold.
  • Manual end-to-end verification once the local Docker environment is working.

Additional Notes

  • Streak ticket:
  • Not tested end to end locally: the middlewarenode container fails to start with a missing indexKey config value, which is unrelated to this change. Please verify on a working environment, or I'll update this PR once my local setup is fixed.
  • Depends on the Week 1 and Week 2 PRs, which are merged. Touches the same files as the currency-event work, but only adds independent calls.
  • I left the testing boxes unchecked; tick them to match what you actually ran (npx tsc --noEmit, CI=true npm test -- --watchAll=false).

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.

1 participant