Copy link to clipboard
Copied
I worry this isn't possible but here goes....any help would be incredible.
Recently I was given some great advice on how to trigger a Javascript action in the frame on our LMS which the Captivate file plays in.
It works perfectly and on the final page triggers the Javascript which send usage back to the LMS and forward the user to a page which allows them to rate the course.
The code was as follows:
top.code.closeSCOContent();
closeSCOContent() is something written into our LMS.
However the obvious issue occurs when a user just closes the browser window and for some reason our LMS doesn't record any bookmarking or any data.
The only way it seems to do this is if that function is called.
So using the window.onunload() or the DOFinish; function is there a way I can edit any file in the Captivate output to trigger this function when closing the browser?
Long shot I know but currently the best I have managed is getting the course to trigger this as soon as it loads rather than closing the window?
Massive thanks in advance for any advice.
1 Correct answer
Are you publishing to swf or html5?
If swf you could have a widget send the info whaen a slide is entered. For HTML you can do the same thing regisitering the event with the window.
I can make you a widget for a small fee. Here is the html5 code (insert in the head section):
<script>
var interfaceObj;
var eventEmitterObj;
window.addEventListener("moduleReadyEvent", function(evt)
{
interfaceObj = evt.Data;
eventEmitterObj = interfaceObj.getEventEmitter();
initializeEventListeners();
});
function initi
...Copy link to clipboard
Copied
Is your LMS SCORM? If so, are you publishing to 2004?
You could always stick that code on the <body onbeforeunload="top.code.closeSCOContent();">
I'm sure you could include it in the html template also.
Copy link to clipboard
Copied
It is SCORM 1.2 compatible but not 2004 I'm afraid.
The issue I seem to have is when I use window.onunload when the focus changes from the HTML file to the inbuilt flash file it seems to think the window is being closed and triggers the event straight away.
Would the <body onbeforeunload="top.code.closeSCOContent();"> you're mentioning work on 1.2 or just 2004?
Copy link to clipboard
Copied
The SCORM version wouldn't matter. I was wondering about the 2004 because sometimes session data is help in temporary tables, so when the user closes the browser all the data is lost. We fix this by setting the cmi.exit (cmi.core.exit in 1.2) to "suspend" which forces the data into the permanent table. We do this every time the data changes.
Copy link to clipboard
Copied
Any solution to ensure the data is written back to the LMS would solve the issue.
Currently when the close button is pressed nothing happens at all and it's a big problem.
Triggering this .closeSCOContent() function would be the ideal, but if it's not possible anything to write back would be best.
When you say <body onbeforeunload="top.code.closeSCOContent();">
Do you mean putting this in the HTML file of the output which currently is:
<body bgcolor="#f2f2f2">
and change this to:
<body onbeforeunload="top.code.closeSCOContent();" body bgcolor="#f2f2f2">
Copy link to clipboard
Copied
You had 2 body tags in there.
<body bgcolor="#f2f2f2" onbeforeunload="top.code.closeSCOContent();">
Copy link to clipboard
Copied
Whoops well spotted...unfortunately it still doesn't do anything, I close the window and that's all that happens, no data is stored.
I tried just a simple alert so I know it's definitely triggering the function:
<body bgcolor="#f2f2f2" onbeforeunload="alert("I am an alert box!");">
But even this isn't doing anything. I'm really stumped now.
Copy link to clipboard
Copied
You need single quotes inside of the alert:
<body bgcolor="#f2f2f2" onbeforeunload="alert('I am an alert box!');">
Where was that code being executed from before? From inside of Captivate or Captivates' html page?
Copy link to clipboard
Copied
Wow it's been a long day and I missed that thanks.
OK so now the alert box appears as soon as the course loads and only after I accept a security pop up the content was blocked with security errors. It then just keeps appearing in a never ending loop. Maybe I'm over complicating the problem by calling the full script, I guess all I need is just something to send SCORM 1.2 data back to the LMS when the window is closed.
The code before was being executed from within Captivate and the function is stored in frame inside the popup window which the course loads in.
Copy link to clipboard
Copied
Are you publishing to swf or html5?
If swf you could have a widget send the info whaen a slide is entered. For HTML you can do the same thing regisitering the event with the window.
I can make you a widget for a small fee. Here is the html5 code (insert in the head section):
<script>
var interfaceObj;
var eventEmitterObj;
window.addEventListener("moduleReadyEvent", function(evt)
{
interfaceObj = evt.Data;
eventEmitterObj = interfaceObj.getEventEmitter();
initializeEventListeners();
});
function initializeEventListeners()
{
if(interfaceObj)
{
if(eventEmitterObj)
{
eventEmitterObj.addEventListener("CPAPI_SLIDEENTER",function(e){
top.code.closeSCOContent();
});
}
}
}
</script>
Copy link to clipboard
Copied
Did this solution ever work or you?
Copy link to clipboard
Copied
Hi,
As everything felt like a work around to solve a problem that I believe shouldn't exist I ended up contact our LMS supplier to see if they can implement the function site wide and improve how the data is handled when the browser window is closed with the 'x' button.
Thank you for all of your help though as it really helped me get an insight into how the LMS, Captivate and it's pop up window all work together.
Copy link to clipboard
Copied
Having a user just close the browser without clicking a course exit button has always been an issue with saving the information. Glad to help.

