Skip to content

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 IntegrationTestSeeder so tests can enable it. Add a matching state on database/factories/QuestionnaireFactory.php.
  • Add a case on app/Enums/QuestionnaireNames.php. config/questionnaires.php uses 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() or Factors::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().
  • If the factor should appear in selection rules:
    • Define fields in config/automated-suggestions. The name is the translation key in lang/{locale}/selection-rule-fields.php.
    • Merge the fields in Domain/AutomatedSuggestions/Services/Rules/MyClicRuleService.php.
  • Platform reports (Domain/Reports):
    • QuestionnaireAnalyticsReport usually works without extra code. Check it.
    • QuestionnaireAnswersReport: add answer options and any factor scores.
    • FactorUpdatesReport usually 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.
    • StoreQuestionnaireAnalyticsReport usually works.
    • Domain/Stores/Reports/FactorUpdatesReport/StoreFactorUpdatesReport.php usually works.
    • StoreParticipantsScoresStoreQuestionsReport: list category calculations.
  • If it belongs on the health index:
    • Add the score type to ScoreTypes::storeAverageScoreTypes(). SaveAllStoresAverageScores only pages stores and dispatches SaveStoreAverageScore.
    • Add the questionnaire to resources/js/pages/HealthIndex/ShowDashboard.vue.
    • Factor classes live in Domain/MyClic/Factors. Implement HasBarGraph and HealthIndexSubFactor. A group factor also implements HasSubFactors.
    • Add a questionnaire class in Domain/MyClic/Questionnaires that implements Questionnaire and AvailableInHealthIndex.
    • Keep Domain/MyClic/Factories/QuestionnaireFactory.php and database/factories/QuestionnaireFactory.php in sync.
    • Make sure the questionnaire engine can return a category for an average score. The health index needs that for partial calculations.
  • 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:

  1. terms. Shown when the user has not accepted medical or automated data-processing terms.
  2. loading. Loads the first page.
  3. load_error. Initial load failed.
  4. show_content. Questions, errors, next page or submit.
  5. complete. Factor update succeeded. The modal then reloads the page.
  6. 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/.