Add a Questionnaire Question
Add a question to the readiness questionnaire and feed it into scoring.
The readiness questionnaire is data-driven. Its structure lives in
kredal-app/src/lib/questionnaire/schema.ts, keyed by the eight sections defined in
src/lib/constants.ts (QUESTIONNAIRE_SECTIONS).
Steps
-
Add the question to the right section in
src/lib/questionnaire/schema.ts. Each question has:key— a unique, stable snake_case identifier (this becomes thequestion_keystored inquestionnaire_responses).label— the question text.type—text,textarea,number,select, orradio.options— forselect/radio.- optional
helpText,placeholder,required, andshowIf(conditional display keyed off another question in the same section).
-
No migration needed. Answers are stored as
(company_id, question_key, answer_json)rows with a unique constraint on(company_id, question_key), so new keys just work. -
Wire it into scoring (optional). If the answer should affect the score, add a rule that reads
answers.<your_key>— see Add a scoring rule. -
Verify. Run the app, open a company's questionnaire, confirm the question renders, saves per-section, and (if scored) changes the assessment.
cd kredal-app && npm run build
Conventions
- Keep keys stable once shipped — they are the storage contract. Renaming a key orphans existing answers.
- Put conditional follow-ups behind
showIfrather than a separate section. - Match the existing plain, non-jargon phrasing; the ICP is often a non-native English speaker.