Questionnaires
Adding a new questionnaire
- Insert the questionnaire with a one-time operation.
- Add the slug to
Domain/MyClic/Enums/QuestionnaireSlugs.php. - Add score keys to
Domain/MyClic/Enums/ScoreTypes.php. - Add the questionnaire to
config/questionnaires.php. - Insert it in
IntegrationTestSeederso tests can enable it. Add a matching state ondatabase/factories/QuestionnaireFactory.php. - Add a case on
app/Enums/QuestionnaireNames.php.config/questionnaires.phpuses it. - Add score fixtures under
database/assets/MyClic(usually the completed-questionnaire and with-scores sets). - Add a translation for the questionnaire name in the JSON locale files.
- Add factor translations in
lang/{locale}/enums/my-clic/factors.php. - If it has a group factor (Lifestyle, Menopause total, Menstrual complaints), exclude that group from
Factors::hasScoresPage(). - If a factor is not updatable, or has no score page, exclude it from
Factors::updatable()orFactors::hasScoresPage(). - Add factor classes under
Domain/MyClic/Factors/{Questionnaire}/. - Add a Blade score view at
resources/views/pages/front/scores/questionnaires/{slug}.blade.php. Score pages are still Blade. - If it has updatable factors (sub-questionnaires):
- Add a tracking code in
Domain/Activity/Enums/TrackingCodes.php. - Add strings in
lang/{en_US,nl_NL,de_DE,es_ES,fr_FR}/tracking-codes.php. - Add the slug to
QuestionnaireSlugs::hasUpdatableFactors().
- Add a tracking code in
- If the factor should appear in selection rules:
- Define fields in
config/automated-suggestions. The name is the translation key inlang/{locale}/selection-rule-fields.php. - Merge the fields in
Domain/AutomatedSuggestions/Services/Rules/MyClicRuleService.php.
- Define fields in
- Platform reports (
Domain/Reports):QuestionnaireAnalyticsReportusually works without extra code. Check it.QuestionnaireAnswersReport: add answer options and any factor scores.FactorUpdatesReportusually works. Check it when there are updatable factors.ScoreCategoriesReport: list category calculations.
- Store reports (
Domain/Stores/Reports):Domain/Stores/Reports/QuestionnaireAnswers/StoreQuestionnaireAnswersReport.php: same as the platform answers report.StoreQuestionnaireAnalyticsReportusually works.Domain/Stores/Reports/FactorUpdatesReport/StoreFactorUpdatesReport.phpusually works.StoreParticipantsScoresStoreQuestionsReport: list category calculations.
- If it belongs on the health index:
- Add the score type to
ScoreTypes::storeAverageScoreTypes().SaveAllStoresAverageScoresonly pages stores and dispatchesSaveStoreAverageScore. - Add the questionnaire to
resources/js/pages/HealthIndex/ShowDashboard.vue. - Factor classes live in
Domain/MyClic/Factors. ImplementHasBarGraphandHealthIndexSubFactor. A group factor also implementsHasSubFactors. - Add a questionnaire class in
Domain/MyClic/Questionnairesthat implementsQuestionnaireandAvailableInHealthIndex. - Keep
Domain/MyClic/Factories/QuestionnaireFactory.phpanddatabase/factories/QuestionnaireFactory.phpin sync. - Make sure the questionnaire engine can return a category for an average score. The health index needs that for partial calculations.
- Add the score type to
- Fix the tests.
Example: Menstrual complaints.
Rendering questionnaires
Questionnaires open in a full-screen modal. Separate endpoints load questionnaires and factor updates. Progress comes from the questionnaire engine (Domain/QuestionnaireEngine/Actions/GetQuestionnaireProgress.php).
Submitting questionnaires
There are separate submit endpoints for questionnaires and sub-questionnaires because extra checks differ, and because a factor slug can match a questionnaire slug.
QeQuestionnaireButton.vue and QeQuestionnaireModal.vue
QeQuestionnaireButton.vue
resources/js/components/questionnaire-engine/QeQuestionnaireButton.vue starts, restarts, and continues a questionnaire. The default slot is the control that opens the flow.
For a main questionnaire it first opens QeIntroQuestionnaireModal.vue. Factor updates and skipIntros skip the intro and open QeQuestionnaireModal.vue directly.
Props include questionnaireName, questionnaireDescription, questionnaireSlug, questionnaireCover, isFactorUpdate, skipIntros, loadModalOnInit, isDemoMode, and the two medical-data consent flags.
QeQuestionnaireModal.vue
resources/js/components/questionnaire-engine/QeQuestionnaireModal.vue uses FullScreenDialog.
States:
terms. Shown when the user has not accepted medical or automated data-processing terms.loading. Loads the first page.load_error. Initial load failed.show_content. Questions, errors, next page or submit.complete. Factor update succeeded. The modal then reloads the page.outro. Main questionnaire succeeded. The modal stays open and links to the score page.
QeQuestionnaireElement.vue renders Select, SelectText, Radio, Checkbox, MultiCheckbox, or Text under resources/js/components/questionnaire-engine/questionnaire-elements/.