Articulate Storyline: Sending Learner Score to LMS Using JavaScript

Articulate Storyline: Sending Learner Score to LMS Using JavaScript

JavaScript can be of great help to take your eLearning courses developed in the Storyline to the next level, be it Storyline 1, Storyline 2 or Storyline 360. It lets you extend the functionality of the built-in tools in Storyline that come by default. With JavaScript, you not only can update the Storyline variable, but it also comes handy while working with the eLearning courses that are going to land up in an LMS after eLearning development.

Articulate Storyline JavaScript gives you control to manipulate and use the information coming from LMS and being sent to LMS. Few popular examples of such scenarios are:

  • Getting the student’s name from LMS
  • Getting the student’s status
  • Getting and setting Lesson status
  • Getting student’s Language preferences
  • Sending user score to LMS

In this blog, we will discuss on how to send learner score to LMS using JavaScript.

Develop a Storyline course with questions or assessment. If you are selecting Storyline’s default assessment, some pre-defined variables will be added to calculate the score by default. But storyline doesn’t allow access to those variables. As a result, we don’t have an option to adjust their values because Storyline takes full control over them.

If you want to send custom calculated score to LMS, this is how you do it:

Step 1

Create a custom variable in Storyline

Step 2

Adjust its value using triggers

Step 3

Add a trigger to run JavaScript when timeline starts in the Result page

Trigger Wizard Storyline

Step 4

Copy and paste the following code.

var player = GetPlayer();

lmsAPI.SetScore(player.GetVar(‘Score’),100,80);

lmsAPI.CommitData();

Code Explanation:

  • GetPlayer() – Returns an object that contains the methods and variable values of storyline
  • lmsAPI – Is an object from Storyline’s SCORM API that contains the methods and values for establishing the connection and data flow from course to LMS
  • SetScore(score, maxScore, minScore) – SetScore is a function inside lmsAPI object that sends the score to the LMS. It accepts 3 parameters “Score, Max Score and Minimum Score”
  • commitData() –  Is a function inside lmsAPI object that saves all the data sent to LMS in the database.

Step 5

Make sure to set the LMS tracking based on the slides viewed and not Track using quiz result in case you are using Storyline’s default Assessment. If not Storyline overrides your custom score with its default result variable value.

Track using quiz result

Step 6 (Optional)

When the learner exits the course by clicking a button that has a trigger on it to exit the course, for Storyline 2 update 9 and below, it will still override the score to Zero even after setting the tracking option based on the slides viewed.,

In such case, we can use a workaround to exit the course without using the default trigger “Exit the course”.

You can add a trigger on the Exit button to Jump to the URL “./lms/goodbye.html” when learner clicks on it.

Storyline 2, update 9

Conclusion:

This is one of the many examples about how JavaScript is useful in Storyline courses. If you would like to know more about the integration of JavaScript in Storyline, feel free to take a look at our blog on Integration of JavaScript with Storyline. Hope you found this blog informative.

9 replies
  1. Bill Creger
    Bill Creger says:

    Thank you so much. I am using the Canvas LMS and for some reason it is not picking up the score . I set up an assignment and set the points possible to 30, then tried to send a score of 20 out of 30 to the Canvas grade book but it defaults to a 30/30 instead. Do you know the actions on the LMS side to get it to work?

    Thanks again for the information!

    Bill Creger

    Reply
  2. Godwin Vinny Carole
    Godwin Vinny Carole says:

    Hello Bill,

    I’m glad you found my blog helpful.

    As you know every LMS is slightly different from the other and each exhibit different behaviors when displaying scores and other details.

    For storyline courses, you need to use lmsAPI.SetScore(player.GetVar(‘Score’),100,80); function.

    Where player.GetVar(‘Score’) will fetch the value of Score variable you created in Storyline and send it to the LMS to save it as score secured by the user.

    If, you are using Storyline 2 and Update version is lower than 10 you must not use “Exit course” trigger on the Exit button to exit the course, using this button will override your custom score sent using JavaScript with the Storyline’s default score.

    I guess this is what’s happening in your case.

    Instead use “Jump to URL” trigger on the exit button and provide this url “./lms/goodbye.html” to exit the course.

    And be sure to select the Tracking option as “Track using number of slides viewed” in Report and tracking options before you publish for LMS.

    Hope this helps you out. Let me know if this works or not.

    Cheers!

    Reply
    • Swift Elearning Services
      Swift Elearning Services says:

      Yes Matthew, You are right. This blog only focuses on storyline 2. Thanks for sharing your observations. This might help future visitors using storyline 3.

      Reply
  3. Jane Lomas
    Jane Lomas says:

    I’ve been using this with much success and it makes a big difference to my learning packages, however when I’ve used this on a mobile device (both android and IOS), it doesn’t work. Is there a setting I need to change or an update to the javascript that will allow this to work on mobile devices? I’m publishing as HTML5.

    Reply
    • Swift Elearning Services
      Swift Elearning Services says:

      Jane, the code is tested on both android and iOS which works well for us. I believe you are using SL 2.

      Reply
  4. Sanjay Sood
    Sanjay Sood says:

    Hi
    I am also trying to push the score results into a SCORM LMS. I have used the code that you have mentioned. I am using Storyline 3 to develop my course.
    I am using a custom designed quiz and have used a variable called quiz1percentage. From your discussion it appears that I should use a variable called Score. So I created a variable called Score and set it equal to quiz1percantage.
    Then I copied the code and pasted it as suggested in the blog.
    However, I am still unable to parse the scores to LMS.
    The reporting and tracking are set exactly as you have suggested in the article.
    I will appreciate any help and guidance on this.

    Reply
    • Godwin Vinny Carole
      Godwin Vinny Carole says:

      Hi Sanjay,
      New Storyline 3 came with many changes under the hood.
      That’s the reason, above code “lmsAPI.SetScore(player.GetVar(‘Score’),100,80);” isn’t working anymore.
      In order to make it work with Stoyline 3 all you need to do is, just use the below code instead:

      objLMS.SetScore(player.GetVar(‘Score’),100,80);
      objLMS.CommitData();

      While all the other steps mentioned in the blog remain the same.

      Hope this helps you out.

      Cheers!

      Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *