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.
- AdamTrosperCommunity Member
Thanks Damien! That's nice to hear on a Thursday morning! I glad my suggestions helped!
- AstutisArtic013Community Member
Hi there.
Firstly, I'd just like to say thanks to everyone that's contributed to this thread, as it's helped me with a project I'm working on.
I'm a bit stuck with one thing though. I'm trying to report the following details to an LMS for a confidence based multiple choice assessment:
- The answers that the user selected.
- The user's final 'knowledge' score (based on how they answered the question).
- The user's final 'confidence' score (based on how confident they were about their answer).
- The user's final 'combined' score as a percentage (based on both their knowledge and confidence).
- Whether they passed or failed (based on the final 'combined' score).
I've got the answers for each question being reported by using Storyline's built-in multiple choice quiz slides. I've also got the 'knowledge' and 'confidence' scores being reported by using hidden 'How many' survey slides. The final percentage score is being reported using bits of different Javascript code that I've found in this thread. The bit I'm stuck on is the 'Passed/failed' reporting.
I think it's currently taking the passed/failed status from the built-in Results.ScorePoints variable, which is the same as the 'Knowledge' score, as it's just based on whether the answers were right or wrong. This isn't taking the confidence score into account.
I've tried using the Javascript code recommended in this thread, but it doesn't seem to be overwriting it. I need to have the tracking based on the quiz result slide, as otherwise the answers aren't passed to the LMS. Is there any way to make the Javascript code overwrite the passed/failed status?
Here's the code I'm using. I'm a complete novice when it comes to coding, so it's possible the mistake being made is in here somewhere:
var p = GetPlayer();
var passingScore = "14";
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);
var cs = p.GetVar("finalscore");
var currentScorePercent = p.GetVar("finalscore_percent");
var ns = 2;
var currentScorePercent = Math.round(cs / ns * 10);
p.SetVar("finalscore_percent", currentScorePercent );
lmsAPI.SetScore(currentScorePercent, 100, 0);
if (player.GetVar("finalscore")>= passingScore)
{
SetStatus("passed");
} else {
SetStatus("failed");
}The status is set to be reported as 'Passed/Failed' in Storyline, although I've tried pretty much every option and none of them are working correctly.
I want the status to show as failed if the 'combined' score percentage is less than 70%, or if the 'combined' score is less than 14.
I've tried a few different things in the code, but was wondering if someone with more coding knowledge would be able to see something obvious that I'm not seeing. Or if what I'm trying to achieve is just not possible when the tracking is based on the quiz results slide.
Thanks.
- karunareddygariCommunity Member
Hello Astutis,
May be you can set a trigger in the results slide or the final slide like the following .
{Complete course
when the time line ends
if combinedscore is greater then or equal to passing score}
Then the track the results by setting the tracking options as Track using complete course trigger
- AstutisArtic013Community Member
Hi Karuna.
I have tried this, but when I track the results using a complete course trigger I lose the answers to the questions - they only send to the LMS when the results are tracked by the quiz results slide.
I may look at reporting the answers via hidden survey slides, rather than using the built-in quiz functionality, although I'm not sure this is going to be possible when using a randomised question bank.
- AdamTrosperCommunity Member
Hi Astutis,
One thing I noticed in your code is that you have quotes around the "14" when you are declaring the passingScore variable. This is most likely forcing that variable to be used as a String. So, when you do your '>=' comparison later on, it would be comparing a number to a string (which wouldn't be reliable). Otherwise, I think your code looked good.
The other thing I would double-check is that these variables that you are pulling in are exactly what you are expecting them to be. For example, I'm assuming that you have a trigger on your results slide somewhere to set "finalscore" equal to "Results.PassPoints" or something like that, right?
If you try these things, it may or may not work. If it doesn't work, perhaps you could upload a .story file and I could take a look?
- AstutisArtic013Community Member
Hi Adam.
I removed the quotations from the "14", but it's still setting a 'Passed' status when the score is 13.
I have a variable in my project titled 'finalscore', but I don't have a trigger on my results slide involving it. Should I? The only triggers I have are a 'Submit results' one to get the question answers sent to the LMS, and the one executing the Javascript code.
I do have a trigger on the previous hidden 'How many' survey slide which is setting finalscore to the typed value in the numeric entry box.
I've got the variables being displayed on the results slide so that I can check they're working okay, and they are displaying correctly. It's just the passed/failed status that's not working.
- AdamTrosperCommunity Member
So, I believe the way that it works is that as soon as you call the Submit Results trigger, it is going to set Passed/Failed and send a score to the LMS based on the actual results of your quiz.
I would put an alert into each portion of your if/else statement to see which one it's calling. If it's calling the "Failed" one, but you are still getting a "Passed" in the LMS, it's most likely because the Submit Results trigger is overriding your code (or something to that effect).
You *might* be able to swap the order of your triggers so that your JS trigger comes before the Submit Results trigger, but I don't know that it would help or not. You might not be able to accomplish exactly what you are going for without digging further into the Storyline engine code to understand exactly what's happening.
- AstutisArtic013Community Member
I suspected that may be the case.
Do you know if there's a way to push variables to the LMS via Javascript without the need to track using quiz results?
- AdamTrosperCommunity Member
What I was suggesting was to switch the tracking to "Complete Course Trigger" and then remove the quiz functionality but keep the questions (submitting each as interactions). Without actually testing this myself, I would think this would store the questions themselves in the LMS, but not require a results slide to submit the score. Then, you could keep your JS code to try to submit a passed/failed. Again, just thoughts, but I would think it could work.
If you do manage to get this to work, this thread could benefit from knowing your solution! Best of luck!
- AstutisArtic013Community Member
Ah okay. This sounds promising. I shall investigate this approach and let you know how I get on.
EDIT: It seems there's no way to submit an interaction without using the built-in quiz functionality. And they only get reported to the LMS when the results are submitted on a results slide. Is there something I'm missing?
- AdamBayliss-16aCommunity Member
OK, a further question here - The name works fine, but I need Gender / Salutation - any idea what the lmsAPI method is? Thanks
- AdamTrosperCommunity Member
I don't believe there is a method for getting that info. If I'm not mistaken, you can only get the Student's name and user ID. You may just need to ask the user their Gender/Salutation up-front at the beginning of the course.
- AdamBayliss-16aCommunity Member
Hi Adam – thanks for replying – but ha! I’m not giving up that easily, that data is stored by the LMS – there must be a way to get to it? – If I can open an LMS page that shows it, it is there…
We are using Ilias LMS – I’ll try the user forums there, will let you know if I find anything..
Cheers
Adam
- amityunger-53b6Community Member
Hi Matthew,
Thank you so much for the code you wrote, the LMS gets the score (after hours of searching...).
However, the success status remains unknown, instead of passed or failed.I tired to make the slide a question slide, tried different tracking settings...
What am I doing wrong?Many thanks,
Amit