How to: Submit custom score to LMS from Captivate
Hello all and good afternoon,
I have spent the better part of my free time these last few weeks working with SCORM, JavaScript, and our LMS.
I have included the HTML w/ JavaScript to show how you too can do this.
Quiz Preferences
- For this to work the "Enable reporting for this project" must be disabled in quiz preferences.
- Because of this, a SCORM .js file must be included.
- I used the APIWrapper.js file available from ADL.
- SCORM 1.2
- LMS = IBM / Kenexa / Outstart / SCORMcloud.com
The rest is up to your creativity!!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script src="standard.js" type="text/javascript"></script>
<script src="SCORM_12_APIWrapper.js" type="text/javascript"></script>
<script>
function startUp()
{
doLMSInitialize();
var lsnStatusStart = doLMSGetValue("cmi.core.lesson_status");
if (lsnStatusStart == "not attempted")
{
doLMSSetValue("cmi.core.lesson_status", "incomplete");
}
}
</script>
<script>
function closeOut()
{
var Passing_percentage = window.cpAPIInterface.getVariableValue("cpQuizInfoQuizPassPercent");
var currentQuiz = window.cpAPIInterface.getVariableValue("quiz_score");
var prevScore = doLMSGetValue("cmi.core.score.raw");
var lsnStatus = doLMSGetValue("cmi.core.lesson_status");
if ((prevScore == "unknown")||(prevScore == null)||(prevScore == "undefined")||(prevScore == ""))
{
prevScore = 0;
}
if (currentQuiz > 0)
{
if(currentQuiz >= Passing_percentage)
{
doLMSSetValue("cmi.core.lesson_status", "passed")
doLMSSetValue("cmi.core.exit", "logout");
doLMSSetValue("cmi.suspend_data", "");
doLMSSetValue("cmi.core.score.raw",currentQuiz);
doLMSSetValue("cmi.core.score.max", 100);
doLMSSetValue("cmi.core.score.min",0)
doLMSCommit();
doLMSFinish();
window.close();
}
else if (currentQuiz > prevScore)
{
doLMSSetValue("cmi.core.lesson_status", "incomplete");
doLMSSetValue("cmi.core.exit", "logout");
doLMSSetValue("cmi.suspend_data", "");
doLMSSetValue("cmi.core.score.raw",currentQuiz);
doLMSSetValue("cmi.core.score.max", 100);
doLMSSetValue("cmi.core.score.min",0);
doLMSCommit();
doLMSFinish();
window.close();
}
else
{
doLMSSetValue("cmi.core.lesson_status", lsnStatus);
doLMSSetValue("cmi.core.exit", "logout");
doLMSSetValue("cmi.suspend_data", "");
doLMSSetValue("cmi.core.score.raw",prevScore);
doLMSSetValue("cmi.core.score.max", 100);
doLMSSetValue("cmi.core.score.min",0);
doLMSCommit();
doLMSFinish();
window.close();
}
}
else
{
doLMSSetValue("cmi.core.exit", "");
doLMSSetValue("cmi.suspend_data", "");
if (prevScore > 0)
{
doLMSSetValue("cmi.core.score.raw",prevScore);
doLMSSetValue("cmi.core.score.max", 100);
doLMSSetValue("cmi.core.score.min", 0);
doLMSSetValue("cmi.core.lesson_status", lsnStatus);
}
else
{
doLMSSetValue("cmi.core.score.raw",0);
doLMSSetValue("cmi.core.score.max", 100);
doLMSSetValue("cmi.core.score.min",0);
doLMSSetValue("cmi.core.lesson_status", "incomplete");
}
doLMSCommit();
doLMSFinish();
window.close();
}
}
</script>
<script language="JavaScript1.2">
window.onkeypress = CheckForDebugCommand;
window.onload = startUp;
window.onunload = closeOut;
blnDebug = false;
</script>
</head>
<link rel="stylesheet" type="text/css" href="captivate.css" />
<body onunload="closeOut()" bgcolor="#333333">
<div id="CaptivateContent"> </div>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
You may have noticed in a noob @ JavaScripting, however i got it to work!!!
Thoughts?
