Skip to content

Actions and Transitions

ruitedk6 edited this page Jul 13, 2020 · 3 revisions

Actions

When transitioning between states, there are certain actions that we may or may not want to have performed.

The most common action is save, which takes the answer provided by an annotator on a question state and saves it in the database. For each transition in a question state, you can provide the save action as the last element of the transition definition.

"transitions": [["politician", "s2", ["save"]],
                ["other", "end"]]

The transition with path politician will now save the chosen answer in the database, while if other is chosen, this will not be saved.

If you have a large number of transitions and want to save all, it can be cumbersome to add the save action to each transition. In such a case it is easier to set the field saveAll to true.

"saveAll": true,
"transitions": [["politician", "s2"],
                ["other", "end"]]

Transitions

The general layout of a transition is

"transitions": [[path, target, [actions]]

Where the list of actions is at the end. If no actions are needed for a transition, the list of actions can be left out.

"transitions": [[path, target]

Also, if the field nextState is provided, the target by default carries the value of nextState and can be left out. If, however, the target is provided despite the nextState field, the default value is overridden. All of this leads to a minimal transition definition of

"transitions": [[path]]

Note that a list of actions can still be added to the end of this minimal transition.

Clone this wiki locally