Picture of Joel Kellner
SCORM Finish Button
by Joel Kellner - Friday, 13 January 2017, 8:27 PM
 

Hello Forum-

   I am a flash developer who is very familiar with the Pipwerks SCORM API wrapper.  When completing courses in flash, we normally have an acknowledgment statement and a button that users click to mark themselves complete setCourseToComplete(), then the LMS takes over and closes the window and returns user to LMS.  

However I am finding it difficult to do the same thing within ADAPT.  The test courses I have created and loaded into the SCORM CLOUD and it is not passing complete with the SPOOR plugin.

I have found in the wrapper a function API.LMSFinish(); but when I try calling the function using a text component with

<p><a href="#" id="mylink" onclick="API.LMSFinish(); return false">Submit Course</a></p>

It appears the call is being blocked and the course does nothing.

 

Can anyone help point me in the right direction?

 

Thanks!

JOEL

Picture of Matt Leathes
Re: SCORM Finish Button
by Matt Leathes - Monday, 16 January 2017, 9:52 AM
 

Hi Joel

You don't use the Pipwerks API directly in Adapt, you need to go through the 'offline storage' API.

The code you need to use is therefore:

Adapt.offlineStorage.set('status', "completed");
top.window.close();

You don't need to call LMSFinish, the spoor extension will do that for you as the window closes.

Picture of Joel Kellner
Re: SCORM Finish Button
by Joel Kellner - Monday, 16 January 2017, 5:30 PM
 

Matt-

   Thanks for the response... When using the authoring tool, where do I place that Javascript code?  I have been trying the non-best practice of placing the function inside <a> tag that has an "onclick" function and it seems to be working for alert messages, but not for other functions.

I see a place to create .CSS rules in the Project Settings, but I don't see any place to write javascript functions.

 

JOEL

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!