Skip to main content

Logic

Logic is what turns a campaign from a flat list of questions into one that reacts. It can send participants down different routes, show and hide questions as they go, remember things about them, and end a session early.

Rules​

Everything is built from rules, and a rule has two halves: a condition that decides whether it applies, and one or more actions that happen when it does.

A rule with no condition always runs. That is a deliberate setting rather than an oversight, and it is how you do something on every pass through a page.

Where rules live​

Rules live in two places, and the split is strict.

Page rules route. They decide where a participant goes after this page, along with everything else that is not about a single question: setting a variable, disqualifying, discarding an answer.

Question rules only show and hide. A question's rules can reveal or conceal the question itself, or individual options within it, on the page it already sits on. They cannot send anyone anywhere.

Conditions​

A condition is built from tests, and the tests can be grouped.

A test compares one thing against a value. It can look at an answer a participant has already given, at a single row of a matrix question, or at a variable.

A group joins tests with All or Any. All requires every test in the group to pass, Any requires at least one. Groups can contain groups, so more involved conditions are built by nesting rather than by writing them out longhand.

The operators available depend on what you are testing:

Text: is equal to, is not equal to, contains, does not contain, starts with, does not start with, ends with, does not end with.

Number: equals, does not equal, is greater than, is greater than or equal to, is less than, is less than or equal to.

Date: is on, is not on, is after, is on or after, is before.

Options: contains, contains only, does not contain.

Number and date operators read both sides as numbers or as dates. If either side cannot be read that way, or the answer is not there at all, the test simply does not pass. The negative operators behave as you would expect from that: a test for "does not equal" passes when there is nothing to compare.

What a condition can look at​

A condition can only test answers from pages before the one the rule is on. The editor enforces this by offering you only those questions.

The reason is timing rather than policy. Rules on a page run when that page is submitted, so an answer from a later page does not exist yet, and a same-page answer is being submitted in the same breath.

What page rules can do​

ActionWhat it does
Go to pageSends the participant to a page or an ending, instead of the next one.
Disqualify participantEnds the session as disqualified, on an ending you choose.
Save answer to variableStores an answer in a variable, to reuse in wording or in later rules.
Set variableSets a variable to a fixed value.
Transform variableChanges a variable: multiply it by one number, then add another.
Invalidate questionMarks an earlier answer as void.

Invalidate is the one worth reading twice. It records that an earlier answer should no longer count, which is how you deal with an answer a later one contradicts. Results shows it as voided rather than answered when you look at that individual response. What it does not do is retract the answer: later conditions testing that question still see what the participant originally said. If a rule further on should stop matching too, give it a condition that says so.

What question rules can do​

ActionWhat it does
Show this questionReveals the question.
Hide this questionConceals it.
Show optionReveals one option within the question.
Hide optionConceals one option.

A question can also be set to start hidden, which is the usual way to build one that only appears for some participants: hide it by default, then write a rule that shows it.

Hiding every question on a page has a consequence beyond the questions themselves. The page has nothing left to show, so it is skipped entirely. See Navigation.

The order rules run in​

One principle covers all of it: every rule whose condition matches runs, in the order they are listed, and when two of them set the same thing the later one wins.

Rules are not mutually exclusive. Matching one does not stop the others being considered, so two rules that both send a participant somewhere will both run, and the second decides where they actually go. If that is not what you want, reorder them, or make the conditions exclusive.

The same applies to questions. Two matching rules that disagree about whether a question is visible resolve in favour of the later one.

Seeing the whole flow​

The branching view draws the campaign as a diagram: pages, the routes between them, and the conditions that choose between those routes. It is the quickest way to find a page nothing leads to, or a route you did not mean to create.

The branching view of a campaign

It also flags two problems worth fixing whenever they appear:

  • A rule that can never fire, because no route through the campaign satisfies its condition. It is not doing anything, and it is usually a sign that the condition refers to an answer the participant cannot have given by that point.
  • A question that can never appear, hidden by default with no rule that shows it, or shown only by a condition that can never be met.