In our recent reader survey, many of you said that you wanted to learn more about using variables in Lectora® e-Learning software. We asked our Product Manager, Daryl Fleary, to write a blog post—just for you!
Using Variables in Lectora
by Daryl Fleary, Product Manager
I was asked to write a blog entry to answer this question: “How can I use variables in Lectora/Lectora Online?” Wow! That’s a tall order. It’s like answering “What’s the meaning of life?” or “How many stars are in the universe?” Variables can be used in so many ways, including but not limited to:
- Manipulating course progress/branching
- Counting (e.g., clicks, plays, views, tries, etc.)
- Performing calculations
- Dynamically changing text
- Dynamically moving and resizing of objects
- Creating custom questions
- Receiving and sending values with a LMS
- Getting values from SWF files
- Gaming and badging
And the most common use: as an action condition. But before we talk about applications of variables, let’s first define what a variable is and how it works.
What is a variable?
Merriam-Webster defines variable as “a quantity or function that may assume any given value or set of values.” From a Lectora standpoint, the best way to think of a variable is as a bucket or container into which you can put any value, and then later change what is in the bucket, or determine whether to do, or not do, other actions based on what’s in the bucket at any given time.
Here are two examples:
If we create a variable and call it Variable1, we could set the beginning value of it to be “Car.”
In other words, we put “Car” into the bucket. If we look in the bucket later, we see that Variable1:
- Is Equal To—the exact contents are—Car
But in addition to the exact contents, the bucket also:
- Contains capital letter C
- Contains lowercase letters a and r
- Contains the string of letters Ca, ar and Car
- Is Not Empty
A variable contains everything that is in the bucket and equals the exact contents of the bucket.
Numbers are perhaps a little easier to understand. If the initial value of Variable2 is “10”:
- the exact contents are Equal To 10
But in addition to the exact contents, the Variable2 bucket also:
- Contains 10
- Is Greater Than all values under 10
- Is Greater Than or Equal all values under 10 and 10 itself
- Is Less Than all values over 10
- Is Less Than or Equal all values over 10 and 10 itself
- Is Not Empty
So, a variable is just a named bucket that stores some information as text strings or numeric-only values.
How do variables work?
Variable values—what’s in the bucket—can change or “vary” (which is why they are called “Variables”). Some variables—Lectora’s Reserved variables—change automatically, such as the CurrentTime, CurrentDate or CurrentPageName. For others that we create—User-Defined variables—we can use Modify Variable actions to change what’s in the bucket. For example:
- If we add “pet” to Variable1 above, it is now Equal To “Carpet”
- If we add 10 to Variable2 above, it is now Equal to 20
- And if we add Variable2 to Variable1, Variable1 will now equal “Carpet20”
For variables containing numeric-only values (such as Variable2 above), the Modify Variable action allows you to Add, Subtract, Multiply, Divide, Round and Round Down the value. For variables containing text (e.g., Variable1), you can Add to (“concatenate”) the string or Subtract from (“pull out of”) the string. And for all User-Defined variables (text or numeric-only), you can use the Modify Variable action to Set [it] Equal To another value (i.e., “replace whatever is currently in the bucket with a new value”) or to Set [it] As Empty (i.e., “completely dump out the bucket so that it has no contents”).
You cannot change what’s in the bucket for Lectora’s Reserved variables, but just like any User-Defined variables, you can look into those buckets to see what they equal or contain, and use that information to do, or not do, some other action.
Using variables for Conditional Actions
A conditional action is a fancy way of saying “Do something if this is true.”
We choose to do, or not do, actions every day based on some conditions. For example:
In this example, we determine which action to perform based on the condition—the current state (i.e., “what’s in the bucket”)—of the variables named Light, Stopping Distance and Road Hazard.
In Lectora, conditional actions work the same way. You state what action you want to do if the current value of some variable(s) meets some condition; “Do something if this condition is true.” Here is scenario #3 from the table above in Lectora-speak:
If the conditions specified are not met (i.e., not true), then this action will not run. Keep in mind, however, that sometimes ALL of the conditions have to be met (as above), and sometimes you want the action to occur when ANY of the conditions are true. For example, in scenario #1 above, you’ll want to stop your car if the light is red OR if there is a road hazard, either one:
You can use variables to apply conditions to any action and determine if or when that action will run.
Using variables to dynamically change objects
As we discussed earlier, a variable stores information as text strings or numeric-only values. A few objects in Lectora use text strings or numeric values for their content:
- Text Blocks
- Display Message action
- Set Progress Bar Position action
And every object uses a numeric X/Y coordinate value to set its location on the page and its size (height and width). Since Lectora is just looking for a value to plug in, in many cases you can plug in a variable value. You can use a variable with a text value in the bucket to Change Contents of the text shown in a text block or message. Here are two examples:
Display Message action:
You can use a variable with a numeric-only value in the bucket to Move or Resize an object or change the position (fill level) of a Progress Bar:
Set Progress action:
Or with V11 you can perpetually maintain the progress bar position by associating a variable on the Custom Progress Bar Properties:
Using variables to dynamically change the content of your title can keep it current and fresh and enrich the experience for your learners.
Other uses of variables
All questions automatically have a variable associated with them, typically named something like “Question_0001.” When your learner answers a question, the answer (e.g., the radio button selection, entered text, etc.) is placed into the question’s variable. You can look into that bucket and perform actions based on whether what’s in the bucket Is Correct (is equal to the expected answer) or Is Not Correct (not equal to the expected answer). Because answers are stored in a variable, you can make almost anything into a scorable, custom question simply by modifying the value of the question’s variable.
Here’s an example of a Fill-in-the-Blank question:
Of course, this is not a typical Fill-in-the-Blank question. But if you place a Modify Variable action on each button, you can force a value—an answer—into the question’s variable:
Variables are also used to communicate with your Learning Management System. You can access information such as the Student’s Name as it’s stored on the LMS and send information such as the answers to questions, test scores and lesson (completion) status.
For more information on using variables, check out the following recorded webinars:
(Note: These webinars were recorded with Lectora X but the concepts are still valid for V11 and Lectora Online.)
You may also want to view and download the sample course, Let’s Cook with Lectora V11. In this course, variables are used to:
- Track page access and restrict access to the Knowledge Check
- Update the progress bar position
- Track which links, videos, documents and pop-ups have been viewed
- Accumulate badge points and award the appropriate number of badges
- Determine which Lectora features to highlight for each page
- Change the contents of the “comment” text block which describes the features
- Capture notes entered by the learner
- Perform measurement conversion calculations
- Loop through Character Pose changes
- Create custom questions
- Change feedback text
- Limit the number of selections on a Multiple Response survey question
So, there’s no simple answer to “How can I use variables in Lectora/Lectora Online?” Variables have many, many uses in titles. If you can imagine it, you can probably use variables to accomplish it.
Daryl Fleary is a Product Manager at Trivantis and has delivered a host of presentations and webinars on technical and instructional design topics related to effectively and creatively using the Lectora family of products.
Stay tuned for more of your awesome ideas in our Just for You! Lectora e-Learning Blog series.
Latest posts by Christie Wroten (see all)
- Announcing CourseMill LMS Version 7 with Advanced Learning Analytics - July 29, 2014
- The Best of e-Learning in July - July 22, 2014
- What e-Learning Development Style Are You? - July 15, 2014