Display Logic

Some questions should only be asked if certain things are true. To specify when a question should be asked, add Display Logic to the question.

Note

Display logic can also be added to entire sequences of questions and to edit checks.

Add Display Logic

To add display logic to a question, click the question’s menu and choose Add Display Logic.

../../../_images/add-display-logic-button.png

The display logic editor will appear.

../../../_images/display-logic-editor.png

Neutral Specification vs Native Code

At the top of the display logic editor is a toggle labeled Use Native Code. When using native code, custom Blaise code can be specified and will be included in an IF expression in the RULES section of the generated Blaise survey.

Describe Display Logic with a Neutral Specification

By default, the display logic editor shows the neutral expression specification editor.

Edit an Expression

To add a condition to the expression, use the first dropdown box to select a previous question. In this example, we select the question that asked for the respondent’s age.

../../../_images/condition-1.png

Use the second dropdown box to choose how to evaluate the value of the previous question. In this example, we indicate we want to make sure the age is greater than or equal to a certain value.

../../../_images/condition-2.png

Use the third input box to enter the value to compare. In this example, we will only ask the question if the respondent’s age is at least 18.

../../../_images/condition-3.png

Complex Expressions

To add an extra term to an expression, click the Add button.

../../../_images/add-condition-button.png

The new condition can be edited as described above. In addition, you can chose whether the new condition should also be true, or if only one of the conditions needs to be true (AND or OR).

../../../_images/expression-combinor-dropdown.png

To create even more complex expressions, use the Add new Group button to add a new group of conditions.

Native Code

To specify custom Blaise code as display logic, click the Use Native Code toggle at the top of the display logic editor.

Inputs

The Inputs tab lets you specify what values are necessary in the logical expression.

To add an input:

  1. Click the plus button.

  2. The Select an Input dialog is displayed

  3. Choose an item from the survey to use as an input to the logical expression.

  4. The input will now be available as a token on the Code tab.

Code

The Code tab lets you specify Blaise code that will be included in an IF condition in the RULES section.

Input tokens are displayed above the code entry box. These should be surrounded by double curly braced. For example, to refer to the field named dogAge, code like the following can be used.

{{dogAge}} < 2

When generating Blaise code, Blaise Colectica Questionnaires will replace the terms with the appropriate field names. This allows custom Blaise code to be re-used across instruments, even when the fields used as input to the logical expression may have different names in different instruments.

Description

The Description tab allows you to enter a human readable description of the logic that describes when the question is to be asked of the respondent.

View Display Logic

Questions that have display logic applied indicate this with a banner above the question’s card.

When formal display logic is set, a green banner displays the logic.

../../../_images/valid-expression-banner.png

When only a human readable description is set, a light blue banner displays the description.

../../../_images/specification-only-expression-banner.png

When an invalid expression is set, a red banner indicates the error.

../../../_images/invalid-expression-banner.png