Variables

variable panel

A variable is a container that holds information. A variable has three properties: its name, type and value. The type cannot be changed after the variable is created, but the name and value being stored can change. For example, you might create a variable named SCORE, of type number that has an initial value of 0. Every time a certain action is performed, such as a correct response to a question, the SCORE can be incremented by a value of, say, 1. Then at some point, such as the completion of an exercise, the SCORE variable can be retrieved and displayed on the page.

There are three variable types: number, text and true/false.

Local vs Global
The difference between a Local and a Global variable is that a Local variable is only available on that one page.

So if you're doing some calculations and are displaying the information on that page, you can limit yourself to a Local variable.  If you only need them on that one page, then by using Local variables you also don't clutter up your variables panel with lots of variables that are not important (for example, if you have lots of variables on page 10, you don't have to see them on all your other pages).

Global variables are used when you need to carry information from one page to another, or if you need that value remembered when you leave the page and come back.  Examples of this might be an "exercise1Completed" variable or a "studentNameVar" that is recorded on one page, and then displayed on another.

Now that you know the difference, you can decide whether the variables need to be Global or Local.  If you wish to change an existing variable, simply click the globe icon on the variable, and that will toggle between them.

Where Used: To aid in your discovery of where these variables are being used, you can also select the variable (click in the empty space somewhere, or on the type [e.g., T/F, Num, Text]), and you can use the right-most icon to highlight any actions that are using that variable (on that page).  See this video:

Note that the Value displayed with Variable will be the initial value of the variable when the lesson is launched.  The default initial values are 0 for numbers, false for True/False, and blank for Text variables.  However, if you have a count down from 10 points, you might change the initial value to 10.  This can be useful if you plan to change the value later, or for debugging and testing purposes.

To learn how to create a variable, click here.

Create a new variable

To create a variable:

create a new variable

1. Click the green Insert icon in the Variables panel.

2. Enter the name of the variable in the Name field.

3. Click the Type dropdown menu.

4. Select the desired type of variable.

5. Click OK.

NOTE: Variables can be configured as local variables that are only accessible on a given page, or global variables that are accessible across all pages of a lesson.  Global variables are differentiated in the variable list using the globe icon global variable.

Delete a Variable

1. Open the Variables panel.

2. Select the variable to be deleted (to select a variable, click on variable Type to select the variable).

3. Click the Delete button.

select variable

Number Variables

A number variable stores numbers.

For example, you might create a variable named SCORE, of type number that has an initial value of 0. Every time a certain action is performed, such as a correct response to a question, the SCORE can be incremented by a value of, say, 1. Then at some point, such as the completion of an exercise, the SCORE variable can be retrieved and displayed on the page.

variable panel

Store and Retrieve Data from Variables

To store data in a variable, click the Select button in the response section from an action, and then select the desired variable from the pop-up menu.

You can set the variable to a fixed value.  In the example below, the "Quiz score" variable is being set to "80".

Alternatively, you can dynamically set the value based on the value returned by some other object.  To do this, click the dropdown menu icon, then select the object that will pass data to the variable.  In the example below, the "Student name" variable is being set to whatever the learner types into the "Name input field" object.

Set the tracker value to a variable value

Often times you will want to display a value being stored in a number variable using the tracker object.

To do this, you will need to specify the trigger when you want this action to take place.  The response object will be the Percent Tracker object.  Choose the method "setValue" and set the value to a function which calls the number variable's "getValue" method.

Text Variables

A text variable is also known as a string variable.  This type of variable stores an array, or sequence, of characters.

For instance, at the beginning of a lesson, you might want a user to enter their name, so that at the end of a lesson, you could offer them personalized feedback. You might create a text variable, NAME, in which to store their name for retrieval at the end of the lesson.

variable panel

True/False Variables

A true/false variable is also known as a boolean variable.  This type of variable stores a true or false value.

For example, you might require users to enter their name at the beginning of an interaction.  Following that, you might create a true/false variable named COMPLETE and give it an initial value of false.  When the user enters their name, the COMPLETE variable sould be set to true.  When the user tries to continue from that page, a condition checks to see if the value of COMPLETE is true.  If so, the user is allowed to continue, but if COMPLETE is false, then they are prompted to enter their name before continuing.

variable panel