Share a plan
Level 4 (same school) or Super Admin:POST /api/admin/forms/share
sections = all steps. Also supports GET (list shares) and DELETE (unshare). Super Admin can additionally share by email on the form document (sharedWithEmails).
Assistant Principals (level 3) do not inherit edit access from schoolName alone. They must appear in assignedForms (this route) or sharedWithEmails.
Transfer ownership
Super Admin:POST /api/forms/transfer-ownership
transferHistory[] and retargets userId / principal fields. GET lists transfer-capable principals.
Step locks
src/lib/locking.js keys:
- TTL 300 seconds, refreshable while the editor is open.
- Redis when
REDIS_URLis set; otherwise an in-processMap(not shared across Vercel instances). - The same Redis client caches the published question bank, year settings, and public overview, and rate-limits step saves.
- Fail-open: if lock infrastructure errors, the write still proceeds and may include
warning.
GET /api/forms/[id]/locksGET /api/forms/[id]/editorsandPOST .../editors/register(presence)POST /api/forms/[id]/step/[stepNumber]/unlock
Use Redis in production so two serverless instances cannot edit the same step without seeing each other’s lock.