How to set course as One Time Use - Help with Javascript

Oct 31, 2016

Hello Articulate Community!

I am hoping there's someone out there who knows how to read, modify, and interpret Javascript codes.

Objective: Set course as One Time Use using a JavaScript Trigger on Mobile Devices (iPhones)

I have an online course which is being published in Docebo LMS. I need to set it as One Time Use only (eg: in the screenshot, the preferences in my LMS are Number of views = "Until completed/passed".)

Because there is a lot of content in my course which is optional (eg: an instructions page, lots of tips or tools, etc), I have added in a trigger on the final slide which Executes the following JavaScript when the timeline starts the final slide:

//get LMS API
var lmsAPI = parent;
//set score; the first number is the score
lmsAPI.SetScore(100, 100, 0);
//set status; possible values: "completed","incomplete", "failed", "passed"


Also, for my Publish Settings, I have set the LMS Reporting as:

Report status to LMS as Passed/Incomplete.

 The problem is that my above solution only works on desktops and sets the course as complete in the LMS.

About 80% of my audience is using a mobile device - iPhone 5 or 6 - so this solution does not end up marking the content as complete.

I'm not a javascript programmer so I don't know how to modify my JavaScript above to work on mobile.

I would be tremendously grateful to anyone who might be able to assist me in resolving this issue.

Thank you so much in advance.


3 Replies
Dave Cox

Hi Emily

The javascript should run the same regardless of which device it is on. Javascript code is interpreted by the browser, and is a standard part of today's browsers.

What may be different on the mobile, is how the course exits. It is really difficult to know what really happens without some additional testing. Are you saying that the course completion doesn't get sent when you are on the mobile?

When troubleshooting javascript, I find it helpful to add statements to my code that let me know what is happening in the code, or if the code is even running at all. The console.log("message"); statement is very helpful to output messages to the console. On the desktop you can press F12 to get to the console. Take a look at this article to see how to access the console on an iphone.

Without error trapping when any line in javascript code fails, javascript will stop running, and any additional lines will not run. So if you add a console.log statement, and it never displays, either your code was never reached, or it failed to run. Placing a console statement both before and after your code will let you know if the code was reached, and if it completed.

Also, I'm not sure, but I don't think your code to set completed [SetStatus("Completed")] is calling the correct function. If this is attempting to set the completion status in the LMS, then it should probably call the lmsAPI function, unless you have a SetStatus function that does that.

I know this isn't exactly an answer, but hopefully this gives you some tools to help you diagnose the problem.

This discussion is closed. You can start a new discussion or contact Articulate Support.