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.
- EdCrane-1026e64Community Member
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.
- EdCrane-1026e64Community Member
No worries! Thanks so much!
Absolutely Adam, and that's just the type of feedback that will help us look at what features to include as we continue to add to Articulate 360! Thanks for sharing it here. 🙂
- StephaniePownerCommunity Member
Hey Matthew - some how i missed your offer of help. Big thanks anyway. I think the help you gave Ilana should help me, so i will give that a go. Thanks again!
- StephaniePownerCommunity Member
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
- HeleneSobelman-Community Member
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!
- HeleneSobelman-Community Member
Awesome!!! that worked!
thanks so much!
- DonAnthonyManueCommunity Member
Hi guys... I am trying to create a certificate on a slide, following the assessment that will pull variables from SCORM (student name / today's date) and then allow me to print.
I've seen people mention to Print that you would need a flash object. Our organization no longer supports Flash at all.
Any help? - ChrisPim-7dc640Community Member
Try this:
---------------------------
if (document.location.href.indexOf('html5') < 0) {
GetPlayer().printSlide()
} else {
if(!window.hasPrintStyle){
window.hasPrintStyle = true;
var css = "@media print {div.controls.grid-row.inflexible,div.area-secondary.cs-left.inflexible,header.header-primary.centered-title.extended-height,div.presentation-wrapper:after {display:none !important; visibility:hidden !important;}}";
head = document.head || document.getElementsByTagName('head')[0];
style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
}
window.print();
} - AdamTrosperCommunity Member
If that doesn't work, the way that I've printed in the past was to use Execute Javascript to essentially create a new window with the certificate I wanted to print created on it using HTML. The one piece of advice I have about printing is that different browsers handle printing just a little differently, and you will have to account for that. Also, I always include a "print" button on the page that will disappear when clicked, in case they want to print a second copy, the cancel the print job, etc.