Reputation: 51
Thanks for reading and I hope you can give me a hand with this.
I don't have much experience with SCORM; until now I had always worked in SCORM 1.2 but I have been asked to deliver a project in SCORM 2004. This is for a course which has been built in HTML5 directly in Dreamweaver and I've linked the JS as external files.
WHAT IS SUPPOSED TO HAPPEN: 1) Supposedly I'm storing the lesson location so that when you exit a lesson and open it again, you start off on the page where you left it. Unfortunately, it always starts again from the first page. 2) Supposedly the lesson should not be marking itself as "completed" until you reach the last page of the lesson, but unfortunately it marks itself as "completed" as soon as you've started the lesson.
Following are samples of my code, starting with three HTML samples (first page of the lesson, intermediate pages of the lesson and final page of the lesson), and then the two JS files with my SCORM functions.
1) HTML: first page of the lesson.
<script type="text/javascript" language="javascript" name="mm_scormRTI" src="SCOfunctions.js"></script>
<script language="javascript">
var currentScoPage = scoPage[ i ] ;
SetValue("cmi.location", currentScoPage );
Terminate(); // close out this SCO, we are finished
</script>
<script language="javascript">
Initialize(); // initialize the SCO with the LMS
var currentScoPage = GetValue("cmi.location");
if (currentScoPage != "") {
self.location = currentScoPage;
}else{
currentScoPage = scoPage[0];
}
</script>
</head>
<body onLoad="mm_adlOnload()">
...
2) HTML: intermediate pages of the lesson
<script type="text/javascript" language="javascript" name="mm_scormRTI" src="SCOfunctions.js"></script>
<script language="javascript">
var currentScoPage = scoPage[ i ] ;
SetValue("cmi.location", currentScoPage );
Terminate(); // close out this SCO, we are finished
</script>
</head>
<body onLoad="mm_adlOnload()">
...
3) HTML: final page of the lesson
<script type="text/javascript" language="javascript" name="mm_scormRTI" src="SCOcomplete.js"></script>
<script language="javascript">
var currentScoPage = scoPage[ i ] ;
SetValue("cmi.location", currentScoPage );
Terminate(); // close out this SCO, we are finished
</script>
</head>
<body onLoad="mm_adlOnload()" onUnload="mm_adlOnunload()">
...
4) SCORM: external file "SCOfunctions.js"
function mm_adlOnload()
{
if (mm_adl_API != null)
{
mm_adl_API.Initialize("");
mm_adl_API.SetValue("cmi.completion_status", "incomplete");
}
}
function mm_adlOnunload()
{
if (mm_adl_API != null)
{
mm_adl_API.SetValue("cmi.completion_status", "incomplete");
mm_adl_API.Commit("");
}
}
GetAPI(window);
var nFindAPITries = 0;
var API = null;
var maxTries = 500;
function ScanForAPI(win)
{
while ((win.API_1484_11 == null) && (win.parent != null) && (win.parent != win))
{
nFindAPITries++;
if (nFindAPITries > maxTries)
{
return null;
}
win = win.parent;
}
return win.API_1484_11;
}
function GetAPI(win)
{
if ((win.parent != null) && (win.parent != win))
{
API = ScanForAPI(win.parent);
}
if ((API == null) && (win.opener != null))
{
API = ScanForAPI(win.opener);
}
}
5) SCORM: external file "SCOcomplete.js"
var nFindAPITries = 0;
var API = null;
var maxTries = 500;
function ScanForAPI(win)
{
while ((win.API_1484_11 == null) && (win.parent != null) && (win.parent != win))
{
nFindAPITries++;
if (nFindAPITries > maxTries)
{
return null;
}
win = win.parent;
}
return win.API_1484_11;
}
function GetAPI(win)
{
if ((win.parent != null) && (win.parent != win))
{
API = ScanForAPI(win.parent);
}
if ((API == null) && (win.opener != null))
{
API = ScanForAPI(win.opener);
}
}
function mm_adlOnload()
{
if (mm_adl_API != null)
{
mm_adl_API.SetValue("cmi.completion_status", "incomplete");
}
}
function mm_adlOnunload()
{
if (mm_adl_API != null)
{
mm_adl_API.SetValue("cmi.completion_status", "completed");
mm_adl_API.Commit("");
mm_adl_API.Terminate("");
}
}
GetAPI();
What am I doing wrong? If anybody at least has a working example of a similar SCORM 2004 project or can see what I might be doing wrong, it would be greatly appreciated.
Many, many thanks in advance!
Upvotes: 0
Views: 1636
Reputation: 2549
Building off your example couple others things.
So if you have a lesson/unit/chapter (imsmanifest.xml) made up of individual pages as each page they view you'll want to auto-score them or base it on something they are interacting with.
terminate()
All depends on your single vs multi page. If single page you'll exit normal, no bookmark needed. The LMS will mark each item in the TOC completed/scored as you progress.
Good Luck
Upvotes: 0
Reputation: 4581
You're calling Terminate()
immediately after SetValue()
. You must invoke Commit()
after SetValue()
to persist (save) the data in the database. Otherwise you're exiting the SCO without having saved anything.
Also, have you checked to ensure the value of scoPage[i]
is accurate?
Upvotes: 0