Overview
The Set Variable action allows you to create, modify, or update 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| Variable Name | string | Yes | The name of the variable to create or update. If the variable doesn’t exist, it will be created. |
| Value or Expression | string/number/boolean | Yes | The new value for the variable. Can be a literal value (e.g., "completed", 42, true) or an AXL expression that evaluates to a value. |
Data Types
Variables can store:- string:
"text","completed","user input" - number:
10,3.14,-5 - boolean:
true,false - object: JSON-like structures
- 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. You want to track the number of attempts and set a completion flag when they succeed.In the Attempt Failed state’s
onEntry, add a Set Variable action:- Variable Name:
attempts - Value or Expression:
attempts + 1
In the Repair Successful state’s
onEntry, add two Set Variable actions:- Variable Name:
isComplete - Value or Expression:
true
- Variable Name:
finalScore - Value or Expression:
attempts <= 3 ? 100 : 50
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.

