Forum Discussion
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:
- 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.
- StephaniePownerCommunity Member
Thank you, thank you, thank you Adam! Oh the joy as seeing that word 'Complete' in Moodle after days of doubting my sanity.
- AdamTrosperCommunity Member
Glad I could help! :) (I know the feeling, by the way!)
- AkshayRaoCommunity Member
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.
- StephaniePownerCommunity Member
Hi there - is there an update on when this should be resolved? Thanks
- StephaniePownerCommunity Member
Hi Alyssa
Please can you let me know if this has been resolved or if the issue still remains. Thanks
- AdamTrosperCommunity Member
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.
- AkshayRaoCommunity Member
Hi Adam
i tried your solution still i am not able to receive any progress in LMS
Thank you
- ilanaDuboviCommunity Member
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
- ilanaDuboviCommunity Member
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 - ilanaDuboviCommunity Member
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 - ilanaDuboviCommunity Member
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