Overview
The Set Variable action allows you to modify or update existing writable variables throughout your training. Variables store data that persists across states and transitions, enabling you to track learner progress, record choices, and implement conditional logic.When to Use
- Track scores or counts: increment a score each time a learner completes a task
- Record learner choices: store which option the learner selected
- Set flags: mark milestones (e.g.,
isComplete = true,hasAttempted = false) - Compute derived values: calculate new values based on existing variables using expressions
- Enable conditional logic: set variables that transitions or branching logic can check
Parameters
Data Types
Variables can store:- string:
"text","completed","user input" - number:
10,3.14,-5 - boolean:
true,false - array: lists of values
{{...}}.
Expression Examples
Use AXL expressions to compute or reference values dynamically:Practical Example
Scenario: A training module where learners attempt a repair task. Track every attempt, including the successful one, and set a completion flag when they succeed. Award 100 points for success within three attempts, or 50 points for success on a later attempt. First create Number variablesattempts and finalScore, and Boolean isComplete in the Variables pane. New Number variables start at 0, and a new Boolean starts at false. Keep the attempt count across retries.
1
Count each attempt when it starts
In the Repair Task step’s On Entry actions, add Set Variable:
- Variable:
attempts - Set Expression:
attempts + 1
attempts from 0 to 1; each retry increases it once more.2
Return to the repair step for a retry
On failure, transition to an Attempt Failed step. Set its retry transition’s target to Repair Task so the next attempt runs the same On Entry increment. Do not increment or reset
attempts in Attempt Failed.3
Record completion and calculate the score
On success, transition to Repair Successful. In that step’s On Entry actions, add two Set Variable actions:
- Variable:
isComplete - Set Value:
true
- Variable:
finalScore - Set Expression:
attempts <= 3 ? 100 : 50
4
Use the recorded values later
Later, use the
attempts or isComplete variables in a transition condition to branch to different states (e.g., show a “Congratulations” screen only if isComplete == true).Variables set in one state persist across the entire training session. You can reference them in transitions, conditions, and other Set Variable actions later. There is no built-in “clear all variables” action — if you need to reset a variable, explicitly set it to its initial value.

