Picture of Matt Leathes
Re: SCORM Finish Button
by Matt Leathes - Monday, 16 January 2017, 7:48 PM

Hi Joel

That's because of how all the Adapt code is written as IIFEs - so aren't normally accessible at run-time unless you use require to get a reference to the code you need.

So, it should work using that technique if you put something like:

require('core/js/adapt').offlineStorage.set('status', "completed");top.window.close();

In the onclick handler...

The correct way to do something like this would be to create an Adapt plugin that encapsulates this functionality... whether you create this as a component or an extension depends entirely on how and where in the course you want your 'confirm completion' to appear.

An alternative route could be to have a two-option MCQ component at the end of the course that asks the user to confirm (or not) that they have completed the course. Set the _attempts for the MCQ to something unfeasibly high (e.g. 999999) and ensure that the 'I can confirm' option is set as the correct answer. Assuming the user must complete all other parts of the course before getting to this component, selecting 'I can confirm' would complete the final component in the course and therefore trigger the overall course completion; selecting 'I cannot confirm' would not and would therefore leave the overall course status as "incomplete". It wouldn't automatically close the course on selecting 'I can confirm', but you could add a 'click here to close' link into the correct answer feedback for that... Obviously this doesn't work if the user doesn't have to complete all the other content before they can confirm completion, if that's a requirement then you do need to build a plugin (or just hack it in as you've been trying to do).

Hope this helps!