Programming tips: Accessing LMS functions using the Javascript API in Storyline for eLearning modules

Continuing with the programming tips we started in the previous post, regarding how to write code in Storyline for eLearning modules, let’s continue this time with a little bit more of an advanced coding.

To summarize, we now know that our eLearning modules, when published from Storyline, come with a set of Javascript libraries that allows assets developed in external tools (e.g. Adobe Flash) to communicate with our modules and modify variables.

We also know about the reporting capabilities Storyline has, meaning that all the quiz questions you create in the modules, have the option to be graded and then reported to the LMS.

However, learning may not be as simple as creating slide questions with multiple answer questions, drag and drops or matching sequences, and sometimes we are required to develop this interactions somewhere else, so what happens when you want those interactions to be part of your eLearning module’s grade?

Well, thankfully we are able to manually report that score to our LMS, using Storyline’s Javascript functionality.

Storing the activities’ points and converting it to a percentage

Let’s say we have developed 6 interactivities in Adobe Flash and all of them send a point value to Storyline after they have been completed by the learner (This will be covered in another tutorial). To store this value in Storyline, let’s create 6 Number variables as follows:

  • Activity1
  • Activity2
  • Activity3
  • Activity4
  • Activity5
  • Activity6

And set all of them to a default value of 0.

Now, after all the slides with the activities, let’s create another slide that will work as our results slide, calculating the percentage achieved by the learner on the previous activities. On this slide, we can use a Javascript code that looks something similar to this:

var player = GetPlayer();

var act1 = player.GetVar(“Activity1”);

var act2 = player.GetVar(“Activity2”);

var act3 = player.GetVar(“Activity3”);

var act4 = player.GetVar(“Activity4”);

var act5 = player.GetVar(“Activity5”);

var act6 = player.GetVar(“Activity6”);

var scoreTotal = act1 + act2 + act3 + act4 + act5 + act6;

var percentage = scoreTotal * 100 /60;

 

Looks a little bit complicated? Well, let me explain it.

On the first 7 lines of code, we first get the Javascript API from the player and then get and store all the six variables containing the values reported by the activities. Then we have the following line of code:

var scoreTotal = act1 + act2 + act3 + act4 + act5 + act6;

In this line, we are only finding the total achieved by the learner after going through all the 6 interactions. Finally, we see this:

var percentage = scoreTotal * 100 /60;

This is just a simple ratio that allows us to translate the achieved points by the learner into a percentage. Let’s assume we have only 6 of these interactions and each one of them awards the learner 10 points if completed correctly, thus the value of 60.

If we do the math, let’s say the learner scored a total of 40 points, then percentage will be 66.7% (rounding up to the nearest decimal).

Reporting the score to the LMS

Now that we have the percentage we want to report, we can now report it to our LMS. Thankfully, Storyline allows us to communicate manually by providing a set of functions that we can use to report score or completion.

We achieve that by adding the following lines of code after calculating the percentage:

var lmsAPI = parent;

lmsAPI.SetScore(percentage, 100, 0);

What the previous 2 lines of code do, is that first, we get the LMS API provided by Storyline, and then we use the “SetScore” function to report the percentage to our LMS. If you notice, this function takes 3 parameters:

  • The first value is the percentage achieved by the learner
  • The second value is the maximum score that can be reported, 100 in this case, because we are talking about percentages
  • And the third value is the minimum score that can be reported, 0 in this case.

After adding this Javascript code to your project, you can now rest assured that your elearning module will report a score, even if those values don’t come directly from Storyline, but they come from activities or interactions you developed in an external tool.

If you want to know more about Javascript applied to eLearning or about how to use other tools, such as software for 2D or 3D animation to enrich the outcome of your products, don’t forget to visit our blog or our website at www.pathwaystrainingandelearning.ca.

Programming tips: Accessing LMS functions using the Javascript API in Storyline for eLearning modules

To SCORM or not to SCORM

Multimedia icons in the hand of a womanOn a previous post (‘e’ for Experience), I stated that there are different ways to bring knowledge to users, like interactive modules, videos, infographics, etc., and that they should be used in conjunction and not as isolated products, in order to improve the learning experience on the users.

Let’s say you have to put together a product for a client, a video, an interactive module or an infographic. After days, nights and weeks of graphic design, architecture, programming, testing and fixing, you have the final files to deliver to your client, but then you start wondering if the outcome of the software you used to create and publish the product, will accommodate to the client’s platform.

Well, in the e-learning field there is a question you have to ask yourself (and the client) at the beginning of each project: is it going to be deployed to a LMS and does it have to be marked as “completed” after the user has gone through it? If the answer is yes, have a list of available SCORM wrappers at hand. Remember that, most of the time, you can deploy different types of files to a LMS, but they won’t necessarily have to be marked complete after the user has viewed them.

From my experience, authoring tools such as Articulate Storyline, Adobe Captivate and Trivantis Lectora, can provide you with the functionality to make your product SCORM-compliant, not just because you can actually create interactions and basic animations with them but because you can import a wide variety of files that you may have produced for your client and “wrap” them with the SCORM API. This process of importing videos, images and interactions created in other authoring tools, can be as easy as clicking on a button and selecting the file.

In addition to the aforementioned authoring tools, there are also stand-alone SCORM wrappers that you can use for your projects, usually developed using JavaScript or Action Script 3(like this one: http://pipwerks.com/tag/scorm-wrapper/). Yes, you may have to work alongside a programmer but it’s worth the time, because at the end of the day, you will have your engaging product compatible with the LMS of your choice, but don’t let SCORM limit your creativity when developing an e-learning product.

To SCORM or not to SCORM