Featured Categories
-
Lectora®
Lectora® is the most trusted authoring tool in the world. Rock out your creativity! Author courses any way you like. Lectora adheres to best practices for Accessibility and Web Content Accessibility Guidelines (WCAG), offers responsive authoring for eLearning, and publishes to any LMS (Learning Management System).
-
CenarioVR®
Experience virtual reality through CenarioVR®, our training and virtual reality (VR) authoring software that allows you to create immersive learning in minutes! No coding required!
-
Rockstar Learning Platform®
Our Rockstar Learning Platform® has all the features you’ll love. Help your employees be better at their jobs, more valuable to your company, and most effective in servicing your customers.
-
The Training Arcade®
Level up your learner engagement with the Training Arcade®! The Training Arcade is a library of fun, mobile-ready, casual games that can be rapidly customized with your content to create effective gaming!
-
ELB Learning Content
Did you know that our AssetLibrary™ has over 120 million engaging, interactive, and awe-inspiring templates and assets to help you become an eLearning Rockstar®?
Sum Variables

I’d like to take five variables (each variable tracks and reports out a different type of skill) and add the totals of all five variables to a sixth variable (which would then report out a total score). I am having problems getting that work. I'm starting to wonder if it's even possible to add multiple variables’ totals to another variable. If it is possible, could someone explain how to do that?
Best Answer
-
Yes, you can add multiple variables within Lectora in a few different ways, here are two:
You can use the Lectora action Modify Variable to add a value to another variable's value. Given a variable named runningTotal and another named Two, you would do an action like:
modVar
Target: runningTotal
Type: Add to Variable
Value: VAR(Two)
If you wanted to add five variables to this one, you would have five actions, with the Value field changing to the name of each variable.
Another method to add multiple variables to another is using javascript. Let's use three variables you define in Lectora named; One, Two, and Three, and the other named runningTotal. You could have an action that runs some JavaScript. One way to code it is as follows, assuming the addition is numerical and not adding characters to a string:
runJavascript
JavaScript: VarrunningTotal.set( parseInt(VarOne.getValue(),10) + parseInt(VarTwo.getValue(),10) + parseInt(VarThree.getValue(),10) );
Or if the action will run more than once and you want to keep adding to the runningTotal variable, then add its present value to the formula:
JavaScript: VarrunningTotal.set( parseInt(VarrunningTotal.getValue(),10) + parseInt(VarOne.getValue(),10) + parseInt(VarTwo.getValue(),10) + parseInt(VarThree.getValue(),10) );
The Lectora action method is easier within Lectora. The JavaScript method lets you fine-tune your code and use the power of JavaScript to build on the flexibility of Lectora.
0
Answers
-
CarlJFink Community Member, Lectora® Accessibility Group (LAUG) Member, eLearning Brothers® Partner Posts: 163 ♦ Idol ♦
To add to what @jholland wrote, something I wasn't sure of when I started using Lectora: actions always run in the order they are listed in your course, if they have the same trigger. That is, all OnShow actions attached to a page happen in the order they're listed in (as an example). This isn't guaranteed in all environments, but it's the case here.
0
Categories
- 35.9K All Categories
- 110 ✫ Announcements
- 33.2K Lectora®
- 31.1K Lectora Discussions
- 29K Lectora Desktop
- 2K Lectora Online
- 2K Lectora Feature Requests
- 71 Lectora User Groups
- 27 ELB Learning Content
- 27 ELB Learning Content Discussions
- 346 CenarioVR®
- 205 CenarioVR Discussions
- 141 CenarioVR Feature Requests
- 44 Rockstar Learning Platform®
- 41 Rockstar Learning Platform Discussions
- 108 CourseMill®
- 108 CourseMill Discussions
- 48 ReviewLink®
- 48 ReviewLink Discussions
- 7 The Training Arcade®
- 7 The Training Arcade Discussions
- 938 All Things eLearning
- 39 eLearning Development
- 546 Learning Management System (LMS) Integration
- 333 Web Accessibility
- 1.2K ♪ The Green Room
- 9 Additional Learning Products