Trouble mapping internal variable to cmi.score

May 31, 2019

Hello community!

We've been stumped for a few weeks trying to get our LMS to read a score from an older Storyline project. I'm grateful for all the great tips and ideas we've picked up from the community, but so far we haven't gotten it to work.

Here's the situation:

  • We have an interactive module in Storyline 3 that accumulates a score via a variable "Total" based on user interactions.
  • We tried doing the clever workaround of building in a hidden Survey quiz using numeric entry with a Results slide and mapping the variable "Total" to "NumericEntry". This is the closest we've come to passing a value to the LMS — unfortunately, the LMS is rather narrow in its functionality and it won't read anything as a test score except "cmi.score Raw"
  • From what I can tell, "cmi.score Raw" can't be affected directly except through using Quiz objects, which is not how the interactive module was built. The only way we can discern to modify "cmi.score Raw" is to use Javascript.
  • We've been trying variations of the following code, but nothing so far seems to work — the LMS is consistently receiving a score of 0%:

var p = GetPlayer(); 
var TotalScore = p.GetVar("Total");
var lmsAPI = parent; 
lmsAPI.SetScore(TotalScore, 100, 0);

  • I can't share the Storyline 3 due to Intellectual Property issues, but here is the outline of how it's built:
    • (a) Various branching slides build up a value between 0 and 100 in the variable "Total"
    • (b) These all funnel into a Survey Slide set to a numeric input, which is effectively hidden to the user. Triggers listed below:
    • (c) This then goes to the next Graded Results Slide which is mapped to the survey question's Numeric Input Survey Slide. The slide pops up different layers based on the user's score. A "Success" executes the javascript on Timeline Start
    • A few more details: we're publishing using Tracking by Quiz Result and have tested Reporting to LMS as: Passed/Incomplete, Passed/Failed, Completed/Incomplete. I am trying both SCORM 1.2 and SCORM 2004 (4e). Incidentally, 2004 isn't working with our system to release the course page, so we've been less successful testing that one. The SCORM 1.2 testing that was able to release the pages always comes through as 0% in score.
    • I'm attaching a log from the debugger from the most recent attempt (SCORM 1.2, Reporting as Passed/Incomplete)

Any help or ideas folks can offer would be most welcome in helping us getting this to work as expected. It feels like we're close but we're just not understanding some part of how Storyline functions, or getting the code wrong and not seeing it. Many thanks for your help!


1 Reply
Thor Melicher

The first thing you might have going against you is that you haven't had success with SCORM 2004.  This is needed to pass question text to the LMS as SCORM 1.2 doesn't support this feature.  Looking at what you have though, it seems that you may not need to pass along question text as it seems what you want to do is pass along a final score?

The second thing you might have going against you is that your code may not have found the LMS?  

Before trying the below code, check your variable in Storyline with JavaScript to see if you're getting the value.  Try this:

var p = GetPlayer();
var TotalScore = p.GetVar("Total");
alert("The score is: " + TotalScore);

If you see the score you're expecting now add the following code:

function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;

else if (win.parent == win) return null;

else return findLMSAPI(win.parent);

This part of the code checks where the LMS is (is it in the current window? is it in the window above it? are we not running from an LMS?) so that way we can then...

Call the function to get the window where the LMS is...

var lmsAPI = findLMSAPI(this);

And then finally run the code you had to report the score:

lmsAPI.SetScore(TotalScore, 100, 0);

You can read more about the above code in this post here:

I hope this helps get you closer to what you're needing to do.


This discussion is closed. You can start a new discussion or contact Articulate Support.