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:
- Get the StudentID from the LMS.
- Get the StudentName from the LMS.
- Manually call SetStatus("completed"); to pass a completion to the LMS on the last page of the course.
166 Replies
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
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.
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:
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.
Hi Adam
i tried your solution still i am not able to receive any progress in LMS
Thank you
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
Have you tried any of the solutions suggested in this thread Ilana?
Hello
I'm not really understood what I suppose to change and how to adjust the code so HTML5 will be able to send the score to noodle. Sorry, I'm very green in java screept. Can you advise me how adjust the screept?
Thanks,
Ilana
Sure, just delete the code from your execute javascript trigger and replace it with this code that Adam shared. Hopefully that'll do the trick for you Ilana.
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
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
Hi there - is there an update on when this should be resolved? Thanks
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.
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!
Thanks Alyssa. This is a show-stopper for a client who has a "no Flash" policy in their organisation and our course is compliance based so getting the correct reporting is crucial. I really hope this can be fixed soon.
When do you need your course up and running by Stephanie? I might be able to help you get it working.
Hello Matthew,
I'll appreciate very much your help with the SetScore issue.
Many thanks
Can you send me a sample file that includes the code you are using at the moment? Then I'll take a look and send it back. You can either upload it here using 'add attachment' or email me.
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
I'm glad I could help!
Thanks Matthew.
Just to be clear - could someone explain what variables it is picking up - for example do I need to set a custom variable with a particular name etc?
Chris
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:
I'll step you through each section.
First, we need to establish communication with Storyline, which we do with:
Then we need to define a passing score:
This is used later to determine if we should send a
passed
orfailed
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: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: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 it is, then we will send a passed status to the LMS. If not, then a failed status will be sent:
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.That's brilliant - thank you so much. I really appreciate your time.
Chris
I've been trying to find a way to access the learner name for a while and never got round to it, your solution worked first time. No more asking learner to type their name in to get personalisation.
Many thanks
Jeremy
Thanks so much, Matthew!!
I was trying different scripts, but yours was the first to work!
Had a similar script for Flash, but not for HTML5.
Glad it helped you Daniel!