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.
146 Replies
- 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!
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.
- AdamTrosperCommunity Member
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.
- ShaneLeonardCommunity Member
BUUUUMMMP!
Adam - much appreciated for your contribution to what is probably the Articulate Hack of the Year - which is a prestigious award considering how many hacks are required.
Speaking of hacks...
Articulate Staffers... has there been any progress on the above mentioned and extremely well articulated feature suggestions? Articulate 360 offers a few wonderful new features (closed captions!!), but to completely break the users' ability to effectively communicate with the LMS is simply madness! Madness I say!
You should add the above mentioned action triggers. It will take a few days for your skilled dev team to do, and will literally retain many paying customers. Ready? Go!
Meanwhile... I think I have the featured workaround working on my Moodle System thanks to Ad-rock's self-calling Javascript function, but I have yet one remaining thorn in my side.
I can't, for the life of me, change the cmi.core.lesson_status to anything other than Failed (SL360, HTML5, Moodle). I can set the score. I can get a li'l tick in the li'l "you did a thing" box in Moodle, but if I view the attempt details, it's cmi.core.lesson_status = failed.I dunno.
My JS snippet is:
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("percentage"), 100, 0);
if (player.GetVar("percentage") >= 70)
{
lmsAPI.SetReachedEnd();
}That last command, I've also tried:
a) lmsAPI.SCORM_CallLMSSetValue("cmi.core.lesson_status", "completed");
b) SetStatus("complete");
c) lmsAPI.SCORM_SetCompleted();Any ideas?
Shane Leonard
...this entire thread probably wouldn't be necessary if there was a trigger for "Mark Course Complete" within Storyline.
Hi folks,
Thanks for your feedback here. I wanted to confirm that a new 'Complete Course' Trigger is currently in Beta and is on track to be released in an upcoming Storyline 360 update.
As you'd expect, the new trigger gives you the flexibility to specify all sorts of custom completion criteria from inside Storyline, and sits alongside the slides viewed and results slide as a third way of tracking course completion with an LMS.
We'll keep you posted and let you know once the update is available for download.
- Simon
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!
- AdamTrosperCommunity Member
Hi Helene,
SetStatus("completed") only works with the Flash version because the HTML5 version doesn't end up using the lms.js file. So, you will have to bypass that function and directly call the function that the SetStatus function would have called... Try this:
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.SetReachedEnd(); - HeleneSobelman-Community Member
Awesome!!! that worked!
thanks so much!
Related Content
- 3 months ago
- 4 months ago
- 10 months ago