40227-vm/frontend/docs/safety-quiz-integration.md
Dmitri d4a5378adf Refactor: migrate frontend to Vite/React, add product backend modules
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>
2026-06-09 15:18:23 +02:00

2.4 KiB

Safety Quiz Frontend Integration

Purpose

Safety/QBS quiz results follow the frontend three-layer architecture.

View -> Business Logic -> API/Data Access -> Backend

Files

View layer:

  • frontend/src/components/frameworks/QBSSafety.tsx
  • frontend/src/components/safety-quiz/
  • frontend/src/components/frameworks/DirectorDashboard.tsx
  • frontend/src/components/director-dashboard/DirectorQuizResultsPanel.tsx
  • frontend/src/components/director-dashboard/DirectorRiskList.tsx
  • frontend/src/components/safety-quiz/SafetyQuizContentEditorPanel.tsx

Business logic layer:

  • frontend/src/business/safety-quiz/hooks.ts
  • frontend/src/business/safety-quiz/mappers.ts
  • frontend/src/business/safety-quiz/selectors.ts
  • frontend/src/business/safety-quiz/types.ts
  • frontend/src/business/director-dashboard/hooks.ts
  • frontend/src/business/director-dashboard/selectors.ts

API/data access layer:

  • frontend/src/shared/api/safetyQuizResults.ts
  • frontend/src/shared/types/safetyQuiz.ts

Constants:

  • frontend/src/shared/constants/safetyQuiz.ts

Behavior

  • Quiz submission uses POST /api/safety_quiz_results.
  • Staff completion and director dashboard rows load from GET /api/safety_quiz_results.
  • QBS quiz content loads from GET /api/public/content-catalog/safety-qbs-quiz.
  • Directors and superintendents can edit the QBS quiz content through the authenticated content catalog endpoint PUT /api/content-catalog/safety-qbs-quiz.
  • Editable QBS quiz payloads are JSON-validated in the business layer before saving.
  • Compliance views render empty and error states explicitly instead of substituting static staff rows.
  • Result ownership is derived by the backend from the authenticated session.
  • QBSSafety.tsx is a thin wrapper that calls useSafetyQuizPage and renders focused safety quiz view components.
  • Quiz score, progress, result feedback, and compliance summary are derived in business selectors.
  • Weekly focus and key reminders are backend content payload fields, not frontend constants.
  • Safety quiz view components use shared Button, StatePanel, and ModuleHeader primitives.
  • Director dashboard derives QBS completion metrics and risk rows in business selectors.

If compliance needs pending/overdue rows for all staff, add a backend summary endpoint that joins staff membership with submitted results. Do not recreate pending staff rows in frontend static data.