Onyx Questionnaire Cookbook

Skip to end of metadata
Go to start of metadata

Overview

This page shows how to create questions in all the available formats, how to add categories to a question, how to group questions, and gives a few other useful techniques for coding your questionnaire.


How to create an exclusive choice question (radio buttons)

An exclusive choice question is a question for which the participant can only choose one category.  Its categories are displayed as radio buttons. See a screenshot of an example here.

First, you create a Section / Page structure in which to add the question:

...or you can add the new question to an existing Page:

Then you add categories to the question:

The categories are displayed in a grid (multiple rows and columns). To see a single-column layout, look here. To see a multiple-column layout, look here.

The default number of rows is 5, but you can set the number of rows as shown below. You do not set the number of columns; it is derived: (Number of categories)/(Number of rows).

How to create a multiple choice question (checkboxes)

A multiple choice question is a question for which the participant can select several categories. The categories are displayed with checkboxes so the participant can select all the categories that apply. See a screenshot of an example here

See also How to make a category an exclusive choice in a multiple choice question.

How to group a list of questions

One way of grouping questions is to make the questions children of a parent question. Then you could configure each child question individually. 

You can also group questions by using an array question. See How to create an array question.

How to create an array question (use the same categories for a group of questions)

An array question includes a number of child questions, and a number of categories. The child questions automatically include the categories of the parent question.  See a screenshot of an array question here

By default, the child questions receive all the categories and configuration of the parent, however the child questions can be configured individually. For example: you can redefine whether one or multiple categories can be selected, what the answer count is, and so on.

You use an array question to group questions if all the questions take the same answers. If you want to group questions that do not all take the same answers, see How to group a list of questions.

How to limit the number of answers to a question

You can specify the minimum and maximum number of answers that a participant can select for a question.  This applies to questions that are not open-answer questions.  

How to make a question optional

Set the minimum number of answers to 0.

How to share categories (througout the questionnaire)

Sharing a category means reusing a category's configuration (and possibly its associated open answers) for different questions anywhere in the questionnaire.  You configure the category first time you add it to one question. Then you can refer to this category by name when you are defining another question. The advantages of sharing categories are: you only to configure the category once, and you only need to localize the text for the category once in the properties file for each interface language (see Localizing the Questionnaire).

To ensure consistency in your shared categories, you can define static variables  for shared category that you require in questionnaire builder class.  When you add a shared category to a question, you use the static variable.

See also How to create an array question (use the same categories for a group of questions).

How to define an alternative name for a category (whether shared or not)

When you add a category to a question, you can provide an alternative name for the category.

Since category names are not unique in a questionnaire, it may be necessary to specify an alternative name for the category for the question to which the category  belongs.

Usually categories are given alphanumerical names for readability. However, some old statistical systems only deal with numerical values, so you can give an alternative name (also called an export name) which can be represented as a numerical value.

How to make a category an exclusive choice in a multiple choice question

Even though a multiple choice question normally allows the participant to select several answers, there are certain categories that, if selected, can be the only selection.  For those properties, you must set the 'escape' property to true. For example:

How to add an open-answer question

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.

You create an open-answer question by adding the OPEN_N category to it. Then you set the DataType, so that the appropriate UI element is used and so that the entry can be validated appropriately.

The possible data types are:

  • DataType.BOOLEAN
  • DataType.DATA
  • DataType.DATE
  • DataType.DECIMAL
  • DataType.INTEGER
  • DataType.TEXT

By default, an open-answer question is optional. To make it required, set the minimum number of answers to 1.

To restrict the size the field used to capture the participant's resonse to an open-answer question, set the 'size' property.

How to use multiple fields for an open-answer question

The participant's response to an open-answer question can be captured in several fields. To do this, you add the open-answer question and its category, then you add an open-answer definition (the parent definition) to the category and several child open-answer definitions to the parent definition.

How to validate an open-answer question

A validator can be applied to the response captured for an open-answer question. Two kinds of validator are available:

How to set a condition for displaying a question (also known as a skip pattern)

To control whether or not a question is displayed, you can set a condition on the question.  The condition is defined with one or more DataSource objects.  When you call the setCondition method, you can pass it:

  • The names of questions and categories defined earlier in the your builder class.  DataSource objects will be constructed from these names.  See the first two examples below.
  • A boolean expression that will be evaluated at runtime, and the DataSource objects used in the expression. The DataSource objects are constructed from names and categories defined earlier in your builder class. See the third example below.

At runtime, the DataSource will provide a Data object that will be interpreted as a boolean value (true or false). If the returned Data object is null, the condition is resolved as being false. 

Search Onyx Documentation
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.