Frontend: - Replace Next.js with Vite + React + TypeScript - Add new component architecture (app-shell, sidebar, dashboard modules) - Implement product modules: FRAME, safety protocols, walkthrough checkin, campus/staff attendance, personality quiz, sign language, classroom timer - Add shadcn/ui component library with Tailwind CSS - Remove legacy generated components, stores, and pages Backend: - Add product migrations: frame_entries, user_progress, safety_quiz_results, walkthrough_checkins, communication_events, personality_quiz_results, campus_attendance_config/summaries, staff_attendance_records, content_catalog - Add corresponding models, services, and routes - Implement cookie-based auth with refresh token rotation - Add content catalog seeder with product content - Migrate to ESLint flat config - Switch from yarn to npm Infrastructure: - Update .gitignore for new tooling - Add project documentation (CLAUDE.md, docs/) - Remove deprecated config files and yarn.lock Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
45 lines
1.9 KiB
Markdown
45 lines
1.9 KiB
Markdown
# Personality Quiz Results Backend
|
|
|
|
## Purpose
|
|
|
|
The personality quiz results API stores each authenticated staff user's current EI/personality quiz result and exposes aggregate distribution data for leadership reporting.
|
|
|
|
The workflow uses a dedicated tenant-owned table:
|
|
|
|
- `personality_quiz_results`
|
|
|
|
It does not update staff profile records. Staff profile extension should be handled as a separate schema decision if the product later needs personality type on the staff profile itself.
|
|
|
|
## API
|
|
|
|
All routes require JWT authentication.
|
|
|
|
- `GET /api/personality_quiz_results/me`: returns the current user's saved result or `null`.
|
|
- `PUT /api/personality_quiz_results/me`: creates or updates the current user's saved result.
|
|
- `GET /api/personality_quiz_results/distribution`: returns aggregate counts by personality type for authorized report roles.
|
|
- `GET /api/personality_quiz_results/distribution?campusId=<campusId>`: filters aggregate counts by campus when provided.
|
|
|
|
## Access Rules
|
|
|
|
- Authenticated tenant users can read and update only their own result.
|
|
- Director, superintendent, and mapped backend leadership roles can read aggregate distributions.
|
|
- Distribution endpoints return counts only. They do not expose individual staff names or individual answers.
|
|
- Organization, campus, user, creator, and updater fields are derived from the authenticated backend user.
|
|
|
|
## Data Contract
|
|
|
|
Result mutation fields:
|
|
|
|
- `personalityType`
|
|
- `quizAnswers`
|
|
|
|
The backend validates that `personalityType` is present and that `quizAnswers` is an object. The frontend sends answer maps through the typed API layer; the backend stores them as JSON.
|
|
|
|
## Files
|
|
|
|
- `backend/src/constants/personality.js`
|
|
- `backend/src/db/models/personality_quiz_results.js`
|
|
- `backend/src/db/migrations/20260608005000-create-personality-quiz-results.js`
|
|
- `backend/src/services/personality_quiz_results.js`
|
|
- `backend/src/routes/personality_quiz_results.js`
|