2.6 KiB
2.6 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.tsxfrontend/src/components/safety-quiz/frontend/src/components/frameworks/DirectorDashboard.tsxfrontend/src/components/director-dashboard/DirectorQuizResultsPanel.tsxfrontend/src/components/director-dashboard/DirectorRiskList.tsxfrontend/src/components/safety-quiz/SafetyQuizContentEditorPanel.tsx
Business logic layer:
frontend/src/business/safety-quiz/hooks.tsfrontend/src/business/safety-quiz/mappers.tsfrontend/src/business/safety-quiz/selectors.tsfrontend/src/business/safety-quiz/types.tsfrontend/src/business/director-dashboard/hooks.tsfrontend/src/business/director-dashboard/selectors.ts
API/data access layer:
frontend/src/shared/api/safetyQuizResults.tsfrontend/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.tsxis a thin wrapper that callsuseSafetyQuizPageand renders focused safety quiz view components.- Quiz score, progress, result feedback, and compliance summary are derived in business selectors.
- The "current week" key (
getCurrentSafetyQuizWeek) uses the shared American (Sunday-start) week util (shared/business/week.ts) — consistent with the dashboard hero and F.R.A.M.E. - Weekly focus and key reminders are backend content payload fields, not frontend constants.
- Safety quiz view components use shared
Button,StatePanel, andModuleHeaderprimitives. - Director dashboard derives QBS completion metrics and risk rows in business selectors.
Remaining Related Work
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.