Adding Number Variables

When you need to capture and track numeric values such as learner scores, number of attempts, or object prices, number variables can be a great solution.

In this simple example, you'll work with numeric variables to assign weighted scores to multiple choices. This is common when you have scenarios where the answer choices are all correct, but each choice is worth a different amount. You can then evaluate the choices and provide feedback based on their choices. The best part? You'll never have to write a line of code--Storyline manages everything through the Trigger Wizard.

Let's take a look at what we're going to build.

View the published example | Download the source file

The first slide is a decision slide. Each chat box is worth a number of points: 10, 5, or 1. When you click Submit, you'll branch to a slide based on the chat cloud you selected.

If you're following along, I'm in NumericVariable_START.story.

Step 1: Create a Number Variable

We only need one variable in this example. Variables can hold any type of data, but they can only hold one piece of data at a time. Points will be assigned based on the learner's selection.

  1. Click the Manage project variables icon (it's the small X at the lower right of the  Triggers panel).
  2. When the Variables window appears, click the Create a new variable icon (the icon looks like a blank piece of paper).
  3. Type Choice for the Name.
  4. Select Number for the variable Type.
  5. Leave the value blank.
  6. Click OK.

Step 2: Create a New Trigger to Assign a Point Value to Choice 1

Next, we'll set up a trigger to dynamically assign points to our Choice variable. For this example, we'll assign 10 points for the best choice, 5 points for the next best choice and 1 point for the worst choice. The chat captions have been placed in descending order to make it easier to follow.

  1. On slide 1.1, click the first chat caption ("Refer the employee to Human Resources") to select it.
  2. Create a new trigger by clicking the Create a new trigger icon (it's the icon at the bottom of the trigger panel that looks like a blank piece of paper).
  3. On the Trigger Wizard, choose the options as shown below. Basically, you're telling Storyline to change the number variable called "Choice" to a value of 10 when the learner clicks the chat caption.

Each time the learner clicks the first chat box, the variable Choice will have a point value of 10. Let's add the point values for the next two chat boxes.

Step 3: Create a New Trigger to Assign a Point Value to Choice 2

Now that we've created the first trigger, we'll copy the trigger to the second chat caption, and adjust the value to 5.

  1. In the Triggers panel, select the trigger you just added.
  2. Click the Copy trigger icon to copy the trigger.
  3. Now select the middle chat caption on your slide ("Ask the employee to discuss his feelings"). Then, on the Triggers panel, click the Paste trigger icon to paste the trigger to the caption.
  4. On the new trigger in the Triggers panel, click the value shown in blue (it should say 10.00) and change it to 5.00. 

Now, if you double-click the trigger assigned to the second chat caption, it should look like this:

Step 4: Create a New Trigger to Assign a Point Value to Choice 3

In this step, we copy the trigger once more, this time pasting it to the third chat caption.

  1. In the Triggers panel, select the trigger you just added.
  2. Click the Copy trigger icon to copy the trigger.
  3. Select the third chat caption on your slide ("Ignore the behavior and hope it doesn't happen again").
  4. Click the Paste trigger icon to paste the trigger.
  5. On the new trigger in the Triggers panel, change the value from 5.00 to 1.00.

Step 5: Verify the Triggers Are Adjusting the Variable Correctly

This next step is more of a best practices step. We'll add a temporary variable reference on our slide to verify that the value is being assigned correctly. (It never hurts to verify that things are working right before moving on!)

  1. On the Insert tab, choose Text Box  and insert a text box at the top of your slide
  2. Go back to the Insert tab and select Reference.
  3. In the Reference window, select Choice and click OK.

This inserts a reference to our variable, Choice. When you're building or editing your slide, Storyline shows variable references as a placeholder, with percent signs on either side. When you preview or publish, this placeholder will be replaced with the actual variable value. Each time the variable value changes, the reference will change to show the new value. 

Preview your slide. When you click each chat box, you should see a different value in the text box at the top of your slide. Now that you know things are working fine, you could delete the text box or turn off its visibility in the slide's timeline so that it doesn't appear in your final output.

Step 6: Evaluate the Variable and Branch to the Appropriate Slide

Now that our variable is set up, we can add some triggers to a Submit button to branch our learner to a slide based on their selected choice. Here's how:

  1. Select the blue Submit button on the slide.
  2. Click the Create a new trigger button in the Triggers panel.
  3. Set Action to Jump to slide.
  4. For Slide, select 1.2 Choice-1.
  5. Click Show Conditions to open the Conditions panel.

Here's where we evaluate the value of our variable. The trigger is set to jump to another slide, but we want to set up a condition that tells Storyline to jump to the selected slide only if the variable (Choice) has a specific value.

  1. Click the green plus sign to add a condition.
  2. In the If field, select Choice from the menu.
  3. Set the Operator to ==Equal to.
  4. Set Type to Value.
  5. Enter 10 for Value and click OK.

That sets up our first condition. Because we have three choices and three slides, we will want to add two more triggers with conditions to evaluate the other two point values.

  1. In the Triggers panel, copy and paste the trigger you just created for the Submit button.
  2. On the new trigger, change the slide to Slide 1.3 Choice-2.
  3. Click 10.00 to change the value to 5.00. You don't need to open the Trigger Wizard each time to update these values.

And finally, let's add one more trigger to evaluate the final choice value:

  1. In the Triggers panel, copy and paste the trigger you just created for the submit button
  2. On the new trigger, change the slide to Slide 1.4 Choice-3
  3. Click 5.00 to update the value to 1.00.

Notice what's happened in the slide thumbnails pane at the left of your slide workspace? Now that you've added some triggers, the thumbnails have rearranged themselves to reflect the different possibilities for the way a learner might branch from the first slide. The thumbnails should look like this:

Now, preview the entire scene. Select a caption and click the blue Submit button, and you'll branch to one of the three feedback slides.