I have built a simple 2 minute flash movie which is the entire course.
The only tracking stuff that I need the LMS to do is as follows:
* The HTML page that contains the Flash movie (index.html) needs to tell the LMS that the course is “incomplete”.
* Then, within the movie, there is a button that must be pressed for the course to be shown as “completed” – pressing this button is the only way to complete the course. To achieve this the button in the movie loads a page called agree.html
That’s it – nothing else – no clever book marking, time stamping or scoring. Just incomplete and completed.
I don’t want to do this from within Flash if I can avoid it. I just want some nice simple HTML and JavaScript code. This is what I’ve got so far, for the agree.html:
-------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript" language="javascript" name="mm_scormRTI" > // define global var as handle to API object var mm_adl_API = null;
// mm_getAPI, which calls findAPI as needed function mm_getAPI() { var myAPI = null; var tries = 0, triesMax = 500; while (tries < triesMax && myAPI == null) { window.status = 'Looking for API object ' + tries + '/' + triesMax; myAPI = findAPI(window); if (myAPI == null && typeof(window.parent) != 'undefined') myAPI = findAPI(window.parent) if (myAPI == null && typeof(window.top) != 'undefined') myAPI = findAPI(window.top); if (myAPI == null && typeof(window.opener) != 'undefined') if (window.opener != null && !window.opener.closed) myAPI = findAPI(window.opener); tries++; } if (myAPI == null) { window.status = 'API not found'; alert('JavaScript Warning: API object not found in window or opener. (' + tries + ')'); } else { mm_adl_API = myAPI; window.status = 'API found'; } }
// returns LMS API object (or null if not found) function findAPI(win) { // look in this window if (typeof(win) != 'undefined' ? typeof(win.API) != 'undefined' : false) { if (win.API != null ) return win.API; } // look in this window's frameset kin (except opener) if (win.frames.length > 0) for (var i = 0 ; i < win.frames.length ; i++); { if (typeof(win.frames[i]) != 'undefined' ? typeof(win.frames[i].API) != 'undefined' : false) { if (win.frames[i].API != null) return win.frames[i].API; } } return null; }
// call LMSInitialize() function mm_adlOnload() { if (mm_adl_API != null) { mm_adl_API.LMSInitialize(""); // set status mm_adl_API.LMSSetValue("cmi.core.lesson_status", "completed"); } }
// call LMSFinish() function mm_adlOnunload() { if (mm_adl_API != null) { // set status mm_adl_API.LMSSetValue("cmi.core.lesson_status", "completed"); mm_adl_API.LMSCommit(""); mm_adl_API.LMSFinish(""); } }
// get the API mm_getAPI(); // --> </script> </head>
<body onload="mm_adlOnload()" onunload="mm_adlOnunload()"> <p>Thank you.</p> <p>You have completed the course. </p> <p>Please <a href="JavaScript:(self.close())">close this window</a> or navigate to a new location. </p> </body> </html>
----------------------------------
I’ve created the imsmaniest.xml file and it seems to be dragging in the correct files into the LMS.
And that’s it. But it doesn’t work! The movie opens and plays, the agree.htm page opens, but the tracking is non-existent.
So, do you think you can help.
It would be very much appreciated and worth a beer or two!