lmsAPI Functionality in HTML5 Output

Apr 28, 2017

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.
146 Replies
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

Ed Crane

Mathew was kind enough to send me to this thread in order to resolve my problem. To summarize, some learners will go through the Storyline module and take a quiz using the basic  Storyline quiz slides and results slide. They must get 80% or higher to get completion credit. However, some learners won't be required to view most of the content nor the quiz, so I created a button to take them to the last slide ("Thanks for taking this training"), where they can exit. However, as they're not taking the quiz, they won't get credit for completion. So I wanted to set it up so that upon clicking the button (or by whatever other means), and exiting the course, it will send a passing score to the LMS.

So I'm looking at the code and have a couple of questions (as you'll see, I'm a newbie to JavaScript -- I apologize in advance):

"...we need to define a passing score:

var passingScore = "100";

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

 

In my case, the user needs nothing to pass except clicking the button, so I’m not sure what to put here? 0? I believe passingScore would also be a custom variable I would need to create?

“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);”

 

Not sure which lines of code I would need from here....I don't need to get the Student ID as Adam did.

"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)"

I'm not sure what lines I need here, what variable I may need to create, and what the values should be.

 

Ashley Terwilliger-Pollard

Hi Stephanie,

Thanks for checking in. This is something that our team is still taking a look at. Those features and Javascript elements that were accessible in Storyline 2, changed in Storyline 3 and 360 as we entirely rewrote the player and it's behavior. 

Those types of modifications have always been unsupported, but we do see the value in their use, so we're looking at how and why they fit the needs of Storyline 2 users and what options we could include in Storyline 3/360 to fix it going forward. 

Adam Trosper

Hi Ashley,

I understand that the modification of Javascript is not necessarily "supported" by Articulate.  That makes total sense, since it's not on your team if one of us makes a mistake in our coding.

However, in most cases I've encountered related to this topic, I believe we are only modifying the code because of a lack of a feature that meets our needs within Storyline.  

For example, this entire thread probably wouldn't be necessary if there was a trigger for "Mark Course Complete" within Storyline.  In that case, I would be able to simply say "Mark the course complete when the timeline starts on Page 4.4" or something to that effect.

Since this feature would be built into Storyline, it would presumably work in both Flash and HTML5, and wouldn't require external Javascript.

Alternatively, it could also be solved if we were given a new option in Publish Settings > Tracking, for "Mark [Completed/Passed] when user reaches slide: [4.4]".

I hope this is helpful for your team in determining how best to approach the request.

Stephanie Powner

Hi - I am able to set the status to pass/fail using the javascript so I think I am getting there.  I have put the javascript on in a trigger on the results slide I need to report on (to get the scores for the final exam across to the LMS).  The problem is that the status I set with the script is being overwritten  by some built in function used for reporting. Does anyone have a suggestion about the best way to avoid this?  Many thanks

Helene Sobelman

I apologize if this is duplicative... I have read thru this thread but I still can't get this to work.. so I must be doing something wrong.

I had a very simple piece of javascript that was working to mark completion (below) and it was working for flash output just fine but now does not seem to be working for html5.

var lmsAPI = parent;
SetStatus("completed");

It doesn't sound like there has been a software update to address this yet.. but in the meantime.. is there any snippet of code that I can use to mark completion in both the flash and html5 versions?

Any help is much appreciated!