Skip to content

feat: Add District-Level Set (Batch) Management featureure - #58

Open
kudimirohith-bit wants to merge 23 commits into
vicharanashala:mainfrom
kudimirohith-bit:set-feature
Open

feat: Add District-Level Set (Batch) Management featureure#58
kudimirohith-bit wants to merge 23 commits into
vicharanashala:mainfrom
kudimirohith-bit:set-feature

Conversation

@kudimirohith-bit

Copy link
Copy Markdown

What

Adds District-Level Set (Batch) Management: District/Block Organizers can group
students into Sets, bulk-generate personalized question papers for every student
in a Set, merge them into one printable package (cover page + papers in student
order), and track each Set through its status lifecycle (Created → ... →
Evaluation Completed).

Why

Printing/generating papers one student at a time doesn't scale for district-wide
assessments (thousands of students). This lets an organizer manage generation,
printing, and tracking at the Set level while each student still gets their own
personalized paper — personalization logic is untouched.

New endpoints

  • POST /api/sets
  • GET /api/sets (filter by setId, assessmentName, schoolId, classGroup, status)
  • GET /api/sets/:id
  • PATCH /api/sets/:id/status (enforces forward-only lifecycle transitions)
  • POST /api/sets/:id/generate
  • GET /api/sets/:id/generate/:jobId/progress
  • GET /api/sets/:id/download

Access control

All /api/sets* routes are restricted to DISTRICT_ADMIN, BLOCK_ADMIN, SUPERADMIN,
and force-scoped by the caller's districtCode/blockCode — a District Admin can
only see/act on Sets belonging to schools in their own district, regardless of
query params.

Known limitations (by design, not oversight)

  • Set generation jobs are tracked in-memory (same pattern as the existing
    /api/diagnostic/bulk jobs) and are lost on server restart.
  • The download endpoint accepts the auth token as a query param as well as a
    header, since the frontend triggers download via a plain link click (browsers
    don't attach custom headers to navigation). This matches the app's existing
    token scheme (a plain identifier, not a signed/expiring credential), so this
    isn't a new class of exposure — but it does mean the token can appear in
    browser history/server logs. Flagging for awareness.

Testing done

  • Manual end-to-end: create → search/filter → generate → poll progress →
    download → status transitions (valid + rejected invalid transitions).
  • Verified role/scope enforcement: non-organizer roles get 403; a district admin
    cannot see or act on another district's Sets.
  • tsc --noEmit clean on both backend and frontend.

- Update collection count from 11 to 12 in overview
- Add  entry to the numbered collections overview list
- Append full  interface and  enum as schema section 12
  * SetStatus covers all 9 forward-only lifecycle stages from Created
    through Evaluation Completed
  * Set interface fields: id, name, assessmentName, schoolId,
    classGroup, studentIds (ordered), status, createdAt, createdByEmail
- Export SetStatus union type (9 forward-only lifecycle stages)
- Export Set interface matching schema_design.md spec
- Export generateSetId() following STD_/WS_ Math.random convention
  ('SET_' + Math.floor(10000 + Math.random() * 90000))
- Add sets: Set[] to DatabaseSchema
- Register sets in COLLECTION_NAMES map
- Add getSets(), addSet(), updateSet() helpers mirroring worksheets pattern
- Seed with empty sets: [] array in getSeedData() return
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