lmsAPI Functionality in HTML5 Output

Hey all,

I've been searching through the forums and haven't been able to find anything solid.  I'm using Storyline 360, outputting to both HTML5 and Flash to cover my bases, since the audience doesn't have dedicated machines that they are taking this from.

I'm relying heavily on external Javascript that I wrote, which I have tested thoroughly in the Flash version, and it works fine.  But when it comes to the HTML5 version, it stops working.  I've proven that I'm able to get into the Javascript functions, like I would expect, but it appears that lmsAPI is no longer available to the course.

Are there any similar functions to those of the lmsAPI functions in the HTML5 output?  

Specifically, I'm looking for a way to do the following in HTML5:

  1. Get the StudentID from the LMS.
  2. Get the StudentName from the LMS.
  3. Manually call SetStatus("completed"); to pass a completion to the LMS on the last page of the course.
144 Replies
Akshay Rao

Hi we have upgraded from stroyline 2 to 360, our javascript progress tracking was working fine in storyline 2 but it is not working in storyline 360 in LMS

var slideName="slide1"; //Change here
var slideNo="1"; //Change here
var totalSlideNo="3"; //Change here
var previousSlide=lmsAPI.GetBookmark();


if(previousSlide.length <1)

var txt= slideNo+","+totalSlideNo+","+slideName;
lmsAPI.SetBookmark( txt);
lmsAPI.SetProgressMeasure(slideNo/totalSlideNo);
}
else if(slideNo==totalSlideNo){
var array = previousSlide.split(',');
var index = array.indexOf(slideName) ;
var snoindex = array.indexOf(slideNo) ;
array[0]=totalSlideNo; 
array[1]=totalSlideNo;
var prevString=array.toString();
if(index==-1)
{
var txt=prevString+","+slideName;
lmsAPI.SetBookmark( txt);
lmsAPI.SetProgressMeasure(array[0]/totalSlideNo);
}
}
else{
var array = previousSlide.split(',');
var index = array.indexOf(slideName) ;
var snoindex = array.indexOf(slideNo) ;
if(snoindex==-1)
{
var _num=Number(array[0])+1;
array[0]=_num.toString();
}
else
{

}

array[1]=totalSlideNo;
var prevString=array.toString();

if(index==-1)
{
var txt=prevString+","+slideName;
lmsAPI.SetBookmark( txt);
lmsAPI.SetProgressMeasure(array[0]/totalSlideNo);
}

}

 

can anybody please help

Thank you in advance

 

Alyssa Gomez

Hi there Akshay,

Sorry you've run into this! We're working through an issue where the Javascript code to send completion status to LMS no longer works in Storyline 360. I'll let the team know about you experience, and I'll be sure to post an update here as soon as I get new information.

Thanks so much for letting us know what's going on, and I'm sorry if this is slowing you down. 

Adam Trosper

In the meantime, you should be able to use the function that I posted earlier in this thread to access lmsAPI correctly.  So somewhere at the top of your code, add the following:

function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}

var lmsAPI = findLMSAPI(this);

If it doesn't work past that point, I'm not sure what the fix would be.  I had to do a lot of workarounds with the combination between SL360 specifically and HTML5 that used to work fine in SL2.

 

ilana Dubovi

Hi all,

I've read through this discussion. 

 I'm wondering if anyone might be able to put together a step-by-step  how to set up an execute  javascript  function for transmitting score from HTML5 to moodle.

I've been using for Flash the following code, but seems that is not working with HTML5 publishing  only:

/*Get player to reference*/

var player = GetPlayer();

/*get LMS API*/

var lmsAPI = parent;

/*set score; the first number is the score*/

lmsAPI.SetScore(player.GetVar("zScores"), 100, 0);

/*set status; possible values: "completed","incomplete", "failed", "passed"*/

 

With thanks,

Ilana

ilana Dubovi

It seems that the code that was proposed by Adam relates
to SetStatus("completed"). I looking for code that will send score and not
the status.
How can I change the fallowing code?

/*Get player to reference*/

var player = GetPlayer();

/*get LMS API*/

var lmsAPI = parent;

/*set score; the first number is the score*/

lmsAPI.SetScore(player.GetVar("zScores"), 100, 0);

/*set status; possible values: "completed","incomplete", "failed",
"passed"*/

Thanks,
Ilana

ilana Dubovi

Hello,

I'm trying to send score from HTML5 to moodle.

My code is:

var player = GetPlayer();

function findLMSAPI(win) {
// look in this window
if (win.hasOwnProperty("GetStudentID")) return win;

// all done if no parent
else if (win.parent == win) return null;

// climb up to parent window & look there
else return findLMSAPI(win.parent);
}
/*Get player to reference*/

/*get LMS API*/

var lmsAPI = findLMSAPI(this);

/*set score; the first number is the score*/

lmsAPI.SetScore(player.GetVar("zScores"), 100, 0);

/*set status; possible values: "completed","incomplete", "failed", "passed"*/

 

Where am I go wrong? The moodle doesn't reseive the score.

 

Thanks,

Ilana

Adam Trosper

Hi Ilana,

Your code looks like it should be good.  Unfortunately, I don't have a lot of time to dig through the code to try to help, but I would try to follow the path through the code to see what happens exactly when you call SetScore.  

The reason I say that is because when I was having issues calling SetStatus('completed'), I just searched through the code, and ended up finding out that the SetStatus function is basically just a switch statement that calls a different function (lmsAPI.SetReachedEnd();).  By calling this function directly, I was able to get my code to work.  I'm hoping there's a similar situation for SetScore that you can find.

----------------------------------------------------------------------------------------

I really hope Articulate can get this bug fixed soon.  I guarantee this is a bug that is out there causing all kinds of unnoticed problems for most Storyline users, since they usually don't have a dedicated QA team that verifies all their work on every device.  But for that student who tries to take it on an iPad, it's going to fail repeatedly for "no reason", which is going to be very frustrating.

Alyssa Gomez

Thanks for checking in, Stephanie. We're still working through this bug. We thoroughly test our product updates to make sure that other features are not negatively impacted with fixes that we’ve built, and we wouldn’t want to commit to a date and release any builds that are not of superior quality.  But you are in the right place, and we’ll be sure to let you know any further information we have to share as soon as we can!

ilana Dubovi

Hello all,

Matthew  send me a code update for SetScore issue  which works perfect for sending score from HTML5 to LMS:

 

var player = GetPlayer();


function findLMSAPI(win) {
if (win.hasOwnProperty(" GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}


var lmsAPI = findLMSAPI(this);
lmsAPI.SetScore(player.GetVar( "zScores"), 100, 0);


if (player.GetVar(" 14543GameScore")>= player.GetVar(" 14543PassingPercentage"))
{
SetStatus("passed");
} else {
 SetStatus("failed");
}

 

 

Thank you Matthew, you are a life saver!

Ilana

Matthew Bibby

No worries Chris. The code above was made to work with the variables that Ilana had set up in her project. 

Here is an example for us to consider:

var player = GetPlayer();
var passingScore = "100";
function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}

var lmsAPI = findLMSAPI(this);
lmsAPI.SetScore(player.GetVar("Your_Score_Variable"), 100, 0);
if (player.GetVar("Your_Score_Variable")>= passingScore)
{
SetStatus("passed");
} else {
SetStatus("failed");
}

I'll step you through each section.

First, we need to establish communication with Storyline, which we do with:

var player = GetPlayer();

Then we need to define a passing score:

var passingScore = "100";

This is used later to determine if we should send a  passed or failed status to the LMS. 

So in this example, the user would need to get a score of 100 or more to pass. 

Next, we will use Adam's code to find the lmsAPI. This will allow us to talk to the LMS:

function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}

var lmsAPI = findLMSAPI(this);

Then we are going to get a score from Storyline (which in this example is stored in a variable called Your_Score_Variable*) and send that to the LMS:

lmsAPI.SetScore(player.GetVar("Your_Score_Variable"), 100, 0);

Next, we will see if the score we got from Storyline is greater than or equal to the passing score that we defined earlier:

if (player.GetVar("Your_Score_Variable")>= passingScore)

If it is, then we will send a passed status to the LMS. If not, then a failed status will be sent:

{
SetStatus("passed");
} else {
SetStatus("failed");
}

Does that help explain things?

* Note, you'll need a variable called Your_Score_Variable in Storyline for this to work. Alternatively, you can change the name of the variable in the JavaScript to match the one in your project.