|
|
OverviewYour organization probably requires one or more questionnaires for its custom version of Onyx. One of the questionnaires may be a contraindication questionnaire which participants would answer first in order to establish if there are any reasons the participant should not do one of the other stages. All questionnaires (including contraindication questionnaires) are built in the same way. This section explains how to build a questionnaire. The Process of Building a QuestionnaireTo build a questionnaire:
Question TypesOnyx questionnaires can include questions in many formats. You can view screenshots of the different question formats on the OBiBa website. Questionnaire TerminologyA category is one of the possible answers to a question that are proposed to the participant. An answer is the category (or categories) selected by the participant. An open-answer question is a question that the participant responds to by supplying their own answer rather than by selecting a category. The participant's answer is entered in a field. Planning Your QuestionnaireBefore you get deep into programming your questionnaire, we recommend that you and your organization design the required questionnaires as part of your customization plan. As a minimum, for each question, you must decide the question format, the question text, and the text for the categories. The questions should be grouped into pages (questions that will appear on the same screen). Questions can also be grouped into sections (by topic). You can add one or more conditions to a question to control whether the question will be displayed or skipped. The conditions can be:
You can apply the same condition to several questions in a page or a section. Initially, you could display one question, and only display the other questions if the participant selects a particular answer for the first question. For example, if the participant answers "No" to "Are you pregnant?, then you would not display any of the questions on which this condition had been set: setCondition("PREGNANT", Y). You must decide which type of screen the questionnaire will be displayed on:
Writing Your Questionnaire BuilderYou need to write a java class that builds your questionnaire. Example builder classesIf you downloaded the source files for onyx-demo and the Maven project file as explained in Installing Required Software, you should have several examples in the src/main/java/org/obiba/onyx/example/questionnaire/util directory:
You can copy one of these files, rename it, and use it as a starting point for your builder class. What your builder class needs to doAs you will see in the example java files, your builder class needs to: 1. Get an instance of QuestionnaireBuilder and call its createQuestionnaire method: 2. Set the questionnaire display mode (for a standard screen or touchscreen): 3. Use the methods of QuestionnaireBuilder (which is in the package org.obiba.onyx.quartz.core.engine.questionnaire.util}]) to add elements ({{Section, Page, Question...) to the questionnaire.
All the above methods return the builder object itself so they can be concatenated. The builder object keeps track of a "current element" so you can add elements to it and set its properties. Using the Onyx Questionnaire CookbookFor examples of how add to various types of questions and categories to your questionnaire, see the Onyx Questionnaire Cookbook. Building Your QuestionnaireBuilding your questionnaire means generating the XML and properties files that you will include in the war file for your custom version of Onyx. What you needIf you downloaded the source files for onyx-demo and the Maven project file as explained in Installing Required Software, you should have everything you need to build your questionnaire. To generate the XML and properties file1. Modify these lines in CreateQuestionnaire.java to include the name and version of your questionnaire. src/main/java/org/obiba/onyx/example/questionnaire/util/CreateQuestionnaire.java 2. Use this maven command to compile and run the CreateQuestionnaire programme. mvn clean compile exec:java -Dexec.mainClass="org.obiba.onyx.example.questionnaire.util.CreateQuestionnaire"obiba.onyx.example.questionnaire.util.CreateQuestionnaire" Localizing Your QuestionnaireDepending on how many locales (languages) you specify in your questionnaire builder programme, one or more properties files will have been generated when you run the programme. There should be a properties file per locale. For example, if you created your questionnaire in English and French, two properties files should have been generated: language_en.properties and language_fr.properties. Each properties file will contain a key for each questionnaire element in your questionnaire. You must ensure that string values are supplied for all keys in all of the properties file. Checking Your QuestionnaireYou will probably want to write your questionnaire builder programme bit by bit, and check that your questionnaire is being structured as you intend. You can check your questionnaire as you go along by generating an HTML version of the questionnaire using the QuestionnaireRenderer class which outputs one HTML file from the XML and properties files. This saves you the trouble of installing the questionnaire, running Onyx, and answering questions in order to advance through the questionnaire. What you needIf you downloaded the source files for onyx-demo and the Maven project file as explained in Installing Required Software, you should have everything you need to use the QuestionRenderer. To generate the HTMLAfter you have compiled and run your questionnaire builder, you can generate the HTML version from the command line as follows: 1. Change to the directory where the QuestionnaireRenderer class file is located: $yourOnyxIHome/onyx-modules/quartz/quartz-core 2. Use this maven command to run the QuestionnaireRenderer. mvn -e exec:java -Dexec.classpathScope=test -Dexec.mainClass=org.obiba.onyx.quartz.core.engine.questionnaire.util.QuestionnaireRenderer -Dexec.args="inputPath htmlPath" where: questionnairesPath is the questionnaires directory in which the directory containing the questionnaire.xml and properties files for your questionnaire are located Including Your Questionnaire in OnyxWhen your questionnaire is complete, you must put the questionnaire files in the appropriate place in the onyx directory structure, and you must modify the onyx configuration as explained below. Where to put your questionnaire filesBy default, questionnaires must be deployed in this directory: WEB-INF/config/quartz/resources/questionnaires For example, for a questionnaire named "HealthQuestionnaire", version "1.0", localized in English and French, the questionnaire files would go here: WEB-INF/config/quartz/resources/questionnaires/HealthQuestionnaire/1.0/questionnaire.xml For a touchscreen questionnaire that includes image categories, you would put the images in this directory: WEB-INF/config/quartz/resources/questionnaires/HealthQuestionnaire/1.0/images If several versions of the same questionnaire exist, the one with the highest version number is active. The version numbers must respect this pattern of digits separated by dots: "1.0", "1.0.1", "2.1.0", and so on. Modifying the Onyx configurationYou must add your custom questionnaire stage to Onyx and remove any of the questionnaire stages that came with the onyx-demo that you do not want. To edit stages.xmlTo configure Onyx to include your questionnaire as a stage of the interview, you must edit the WEB-INF/config/quartz/stages.xml file and add a stage element for the questionnaire. The stage name must be the name that you used for the questionnaire in your QuestionnaireBuilder class. If you want to define any stage dependencies, see Defining Stage Dependencies. You should also remove any stages that you do not want in your custom version of Onyx WEB-INF/config/quartz/stages.xml To localize the name of your questionnaireYou must also edit each of the properties files in the WEB-INF/config/quartz directory to localize the names of the questionnaire in each interface language. For example: In the English properties file (WEB-INF/config/quartz/messages_en.properties), add a line like this: HealthQuestionnaire.description=Custom Health Questionnaire In the French properties file (WEB-INF/config/quartz/messages_fr.properties), add a line like this: HealthQuestionnaire.description=Questionnaire personnalisé sur la santé |
Search Onyx Documentation |
Building Custom Questionnaires
Labels:
None