Untitled diff

Created Diff never expires


var SCORM2004_LOGOUT = "logout";
var SCORM2004_LOGOUT = "logout";
var SCORM2004_SUSPEND = "suspend";
var SCORM2004_SUSPEND = "suspend";
var SCORM2004_NORMAL_EXIT = "normal";
var SCORM2004_NORMAL_EXIT = "normal";
var SCORM2004_TIMEOUT = "time-out";
var SCORM2004_TIMEOUT = "time-out";


var SCORM2004_PASSED = "passed";
var SCORM2004_PASSED = "passed";
var SCORM2004_FAILED = "failed";
var SCORM2004_FAILED = "failed";
var SCORM2004_UNKNOWN = "unknown";
var SCORM2004_UNKNOWN = "unknown";


var SCORM2004_COMPLETED = "completed";
var SCORM2004_COMPLETED = "completed";
var SCORM2004_INCOMPLETE = "incomplete";
var SCORM2004_INCOMPLETE = "incomplete";
var SCORM2004_NOT_ATTEMPTED = "not attempted";
var SCORM2004_NOT_ATTEMPTED = "not attempted";


//var SCORM2004_BROWSED = "browsed";
//var SCORM2004_BROWSED = "browsed";


var SCORM2004_CREDIT = "credit";
var SCORM2004_CREDIT = "credit";
var SCORM2004_NO_CREDIT = "no-credit";
var SCORM2004_NO_CREDIT = "no-credit";


var SCORM2004_BROWSE = "browse";
var SCORM2004_BROWSE = "browse";
var SCORM2004_NORMAL = "normal";
var SCORM2004_NORMAL = "normal";
var SCORM2004_REVIEW = "review";
var SCORM2004_REVIEW = "review";


var SCORM2004_ENTRY_ABINITIO = "ab-initio";
var SCORM2004_ENTRY_ABINITIO = "ab-initio";
var SCORM2004_ENTRY_RESUME = "resume";
var SCORM2004_ENTRY_RESUME = "resume";
var SCORM2004_ENTRY_NORMAL = "";
var SCORM2004_ENTRY_NORMAL = "";


var SCORM2004_TLA_EXIT_MESSAGE = "exit,message";
var SCORM2004_TLA_EXIT_MESSAGE = "exit,message";
var SCORM2004_TLA_EXIT_NO_MESSAGE = "exit,no message";
var SCORM2004_TLA_EXIT_NO_MESSAGE = "exit,no message";
var SCORM2004_TLA_CONTINUE_MESSAGE = "continue,message";
var SCORM2004_TLA_CONTINUE_MESSAGE = "continue,message";
var SCORM2004_TLA_CONTINUE_NO_MESSAGE = "continue,no message";
var SCORM2004_TLA_CONTINUE_NO_MESSAGE = "continue,no message";




var SCORM2004_RESULT_CORRECT = "correct";
var SCORM2004_RESULT_CORRECT = "correct";
var SCORM2004_RESULT_WRONG = "incorrect";
var SCORM2004_RESULT_WRONG = "incorrect";
var SCORM2004_RESULT_UNANTICIPATED = "unanticipated";
var SCORM2004_RESULT_UNANTICIPATED = "unanticipated";
var SCORM2004_RESULT_NEUTRAL = "neutral";
var SCORM2004_RESULT_NEUTRAL = "neutral";


var SCORM2004_INTERACTION_TYPE_TRUE_FALSE = "true-false";
var SCORM2004_INTERACTION_TYPE_TRUE_FALSE = "true-false";
var SCORM2004_INTERACTION_TYPE_CHOICE = "choice";
var SCORM2004_INTERACTION_TYPE_CHOICE = "choice";
var SCORM2004_INTERACTION_TYPE_FILL_IN = "fill-in";
var SCORM2004_INTERACTION_TYPE_FILL_IN = "fill-in";
var SCORM2004_INTERACTION_TYPE_LONG_FILL_IN = "long-fill-in";
var SCORM2004_INTERACTION_TYPE_LONG_FILL_IN = "long-fill-in";
var SCORM2004_INTERACTION_TYPE_MATCHING = "matching";
var SCORM2004_INTERACTION_TYPE_MATCHING = "matching";
var SCORM2004_INTERACTION_TYPE_PERFORMANCE = "performance";
var SCORM2004_INTERACTION_TYPE_PERFORMANCE = "performance";
var SCORM2004_INTERACTION_TYPE_SEQUENCING = "sequencing";
var SCORM2004_INTERACTION_TYPE_SEQUENCING = "sequencing";
var SCORM2004_INTERACTION_TYPE_LIKERT = "likert";
var SCORM2004_INTERACTION_TYPE_LIKERT = "likert";
var SCORM2004_INTERACTION_TYPE_NUMERIC = "numeric";
var SCORM2004_INTERACTION_TYPE_NUMERIC = "numeric";




var SCORM2004_NO_ERROR = "0";
var SCORM2004_NO_ERROR = "0";
var SCORM2004_ERROR_INVALID_PREFERENCE = "-1";
var SCORM2004_ERROR_INVALID_PREFERENCE = "-1";
var SCORM2004_ERROR_INVALID_STATUS = "-2";
var SCORM2004_ERROR_INVALID_STATUS = "-2";
var SCORM2004_ERROR_INVALID_SPEED = "-3";
var SCORM2004_ERROR_INVALID_SPEED = "-3";
var SCORM2004_ERROR_INVALID_TIMESPAN = "-4";
var SCORM2004_ERROR_INVALID_TIMESPAN = "-4";
var SCORM2004_ERROR_INVALID_TIME_LIMIT_ACTION = "-5";
var SCORM2004_ERROR_INVALID_TIME_LIMIT_ACTION = "-5";
var SCORM2004_ERROR_INVALID_DECIMAL = "-6";
var SCORM2004_ERROR_INVALID_DECIMAL = "-6";
var SCORM2004_ERROR_INVALID_CREDIT = "-7";
var SCORM2004_ERROR_INVALID_CREDIT = "-7";
var SCORM2004_ERROR_INVALID_LESSON_MODE = "-8";
var SCORM2004_ERROR_INVALID_LESSON_MODE = "-8";
var SCORM2004_ERROR_INVALID_ENTRY = "-9";
var SCORM2004_ERROR_INVALID_ENTRY = "-9";


var SCORM2004_TRUE = "true";
var SCORM2004_TRUE = "true";
var SCORM2004_FALSE = "false";
var SCORM2004_FALSE = "false";


var SCORM2004_EARLIEST_DATE = new Date("1/1/1900");
var SCORM2004_EARLIEST_DATE = new Date("1/1/1900");








var intSCORM2004Error = SCORM2004_NO_ERROR;
var intSCORM2004Error = SCORM2004_NO_ERROR;
var strSCORM2004ErrorString = "";
var strSCORM2004ErrorString = "";
var strSCORM2004ErrorDiagnostic = "";
var strSCORM2004ErrorDiagnostic = "";


var SCORM2004_objAPI = null;
var SCORM2004_objAPI = null;


var blnReviewModeSoReadOnly = false;
var blnReviewModeSoReadOnly = false;


var blnSCORM2004_SSP_Is_Supported = null;
var blnSCORM2004_SSP_Is_Supported = null;


function SCORM2004_Initialize(){
function SCORM2004_Initialize(){


WriteToDebug("In SCORM2004_Initialize");
WriteToDebug("In SCORM2004_Initialize");


var blnResult = true;
var blnResult = true;
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
WriteToDebug("Grabbing API");
WriteToDebug("Grabbing API");
try{
try{
SCORM2004_objAPI = SCORM2004_GrabAPI();
SCORM2004_objAPI = SCORM2004_GrabAPI();
}
}
catch (e){
catch (e){
WriteToDebug("Error grabbing 1.2 API-" + e.name + ":" + e.message);
WriteToDebug("Error grabbing 1.2 API-" + e.name + ":" + e.message);
}
}
if (typeof(SCORM2004_objAPI) == "undefined" || SCORM2004_objAPI == null){
if (typeof(SCORM2004_objAPI) == "undefined" || SCORM2004_objAPI == null){
WriteToDebug("Unable to acquire SCORM API:")
WriteToDebug("Unable to acquire SCORM API:")
WriteToDebug("SCORM2004_objAPI=" + typeof(SCORM2004_objAPI));
WriteToDebug("SCORM2004_objAPI=" + typeof(SCORM2004_objAPI));
InitializeExecuted(false, "Error - unable to acquire LMS API, content may not play properly and results may not be recorded. Please contact technical support.");
InitializeExecuted(false, "Error - unable to acquire LMS API, content may not play properly and results may not be recorded. Please contact technical support.");
return false;
return false;
}
}
WriteToDebug("Calling LMSInit");
WriteToDebug("Calling LMSInit");
blnResult = SCORM2004_CallInitialize();
blnResult = SCORM2004_CallInitialize();
if (! blnResult){
if (! blnResult){
WriteToDebug("ERROR Initializing LMS");
WriteToDebug("ERROR Initializing LMS");
InitializeExecuted(false, "Error initializing communications with LMS");
InitializeExecuted(false, "Error initializing communications with LMS");
return false;
return false;
}
}


//only set the status to incomplete if it's not attempted yet
//only set the status to incomplete if it's not attempted yet
if (SCORM2004_GetStatus() == LESSON_STATUS_NOT_ATTEMPTED){
if (SCORM2004_GetStatus() == LESSON_STATUS_NOT_ATTEMPTED){
WriteToDebug("Setting Status to Incomplete");
WriteToDebug("Setting Status to Incomplete");
blnResult = SCORM2004_CallSetValue("cmi.completion_status", SCORM2004_INCOMPLETE);
blnResult = SCORM2004_CallSetValue("cmi.completion_status", SCORM2004_INCOMPLETE);
}
}


//we want to set the exit type to suspend immediately because some LMS's only store data if they get a suspend request
//we want to set the exit type to suspend immediately because some LMS's only store data if they get a suspend request
blnResult = SCORM2004_CallSetValue("cmi.exit", SCORM2004_TranslateExitTypeToSCORM(DEFAULT_EXIT_TYPE)) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.exit", SCORM2004_TranslateExitTypeToSCORM(DEFAULT_EXIT_TYPE)) && blnResult;


//if mode is review, check if we should go to read only mode
//if mode is review, check if we should go to read only mode
if (SCORM2004_GetLessonMode() == MODE_REVIEW){
if (SCORM2004_GetLessonMode() == MODE_REVIEW){
if (!(typeof(REVIEW_MODE_IS_READ_ONLY) == "undefined") && REVIEW_MODE_IS_READ_ONLY === true){
if (!(typeof(REVIEW_MODE_IS_READ_ONLY) == "undefined") && REVIEW_MODE_IS_READ_ONLY === true){
blnReviewModeSoReadOnly = true;
blnReviewModeSoReadOnly = true;
}
}
}
}
WriteToDebug("Calling InitializeExecuted with parameter-" + blnResult);
WriteToDebug("Calling InitializeExecuted with parameter-" + blnResult);
InitializeExecuted(blnResult, "");
InitializeExecuted(blnResult, "");
return;
return;
}
}








function SCORM2004_Finish(strExitType, blnStatusWasSet){
function SCORM2004_Finish(strExitType, blnStatusWasSet){


WriteToDebug("In SCORM2004_Finish strExitType=" + strExitType + ", blnStatusWasSet=" + blnStatusWasSet);
WriteToDebug("In SCORM2004_Finish strExitType=" + strExitType + ", blnStatusWasSet=" + blnStatusWasSet);
var strStatusAfterCompletion;
var strStatusAfterCompletion;
var blnResult = true;
var blnResult = true;
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
if ( (strExitType == EXIT_TYPE_FINISH) && ! blnStatusWasSet ){
if ( (strExitType == EXIT_TYPE_FINISH) && ! blnStatusWasSet ){
WriteToDebug("Getting completion status");
WriteToDebug("Getting completion status");
strStatusAfterCompletion = SCORM2004_GetCompletionStatus();
strStatusAfterCompletion = SCORM2004_GetCompletionStatus();
WriteToDebug("Setting completion status to " + strStatusAfterCompletion);
WriteToDebug("Setting completion status to " + strStatusAfterCompletion);
blnResult = SCORM2004_CallSetValue("cmi.completion_status", strStatusAfterCompletion) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.completion_status", strStatusAfterCompletion) && blnResult;


}
}
if( strExitType == EXIT_TYPE_SUSPEND && USE_2004_SUSPENDALL_NAVREQ ) {
if( strExitType == EXIT_TYPE_SUSPEND && USE_2004_SUSPENDALL_NAVREQ ) {
WriteToDebug("Setting adl.nav.request to suspendAll");
WriteToDebug("Setting adl.nav.request to suspendAll");
blnResult = SCORM2004_CallSetValue("adl.nav.request","suspendAll");
blnResult = SCORM2004_CallSetValue("adl.nav.request","suspendAll");
}
}
WriteToDebug("Setting Exit");
WriteToDebug("Setting Exit");
blnResult = SCORM2004_CallSetValue("cmi.exit", SCORM2004_TranslateExitTypeToSCORM(strExitType)) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.exit", SCORM2004_TranslateExitTypeToSCORM(strExitType)) && blnResult;
WriteToDebug("Calling Commit");
WriteToDebug("Calling Commit");
blnResult = SCORM2004_CallCommit() && blnResult;
blnResult = SCORM2004_CallCommit() && blnResult;
WriteToDebug("Calling Finish");
WriteToDebug("Calling Finish");
blnResult = SCORM2004_CallTerminate() && blnResult;
blnResult = SCORM2004_CallTerminate() && blnResult;
WriteToDebug("Returning " + blnResult);
WriteToDebug("Returning " + blnResult);
return blnResult;
return blnResult;


}
}




function SCORM2004_CommitData(){
function SCORM2004_CommitData(){


WriteToDebug("In SCORM2004_CommitData");
WriteToDebug("In SCORM2004_CommitData");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();

// check for current completion status and if it is completed, set the status back to completed before commit

if (SCORM2004_GetStatus()) {
}

return SCORM2004_CallCommit();
return SCORM2004_CallCommit();


}
}






//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
//General Get and Set Values
//General Get and Set Values


function SCORM2004_GetStudentID(){
function SCORM2004_GetStudentID(){


WriteToDebug("In SCORM2004_GetStudentID");
WriteToDebug("In SCORM2004_GetStudentID");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
return SCORM2004_CallGetValue("cmi.learner_id");
return SCORM2004_CallGetValue("cmi.learner_id");


}
}


function SCORM2004_GetStudentName(){
function SCORM2004_GetStudentName(){


WriteToDebug("In SCORM2004_GetStudentName");
WriteToDebug("In SCORM2004_GetStudentName");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
return SCORM2004_CallGetValue("cmi.learner_name");
return SCORM2004_CallGetValue("cmi.learner_name");


}
}


function SCORM2004_GetBookmark(){
function SCORM2004_GetBookmark(){
WriteToDebug("In SCORM2004_GetBookmark");
WriteToDebug("In SCORM2004_GetBookmark");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
return SCORM2004_CallGetValue("cmi.location");
return SCORM2004_CallGetValue("cmi.location");


}
}


function SCORM2004_SetBookmark(strBookmark){
function SCORM2004_SetBookmark(strBookmark){
WriteToDebug("In SCORM2004_SetBookmark strBookmark=" + strBookmark);
WriteToDebug("In SCORM2004_SetBookmark strBookmark=" + strBookmark);
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
return SCORM2004_CallSetValue("cmi.location", strBookmark);
return SCORM2004_CallSetValue("cmi.location", strBookmark);
}
}


function SCORM2004_GetDataChunk(){
function SCORM2004_GetDataChunk(){
WriteToDebug("In SCORM2004_GetDataChunk");
WriteToDebug("In SCORM2004_GetDataChunk");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
return SCORM2004_CallGetValue("cmi.suspend_data");
return SCORM2004_CallGetValue("cmi.suspend_data");
}
}


function SCORM2004_SetDataChunk(strData){
function SCORM2004_SetDataChunk(strData){
// 4000 characters for 2nd edition
// 4000 characters for 2nd edition
// 64000 characters here for 3rd edition
// 64000 characters here for 3rd edition
WriteToDebug("In SCORM2004_SetDataChunk");
WriteToDebug("In SCORM2004_SetDataChunk");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
return SCORM2004_CallSetValue("cmi.suspend_data", strData);
return SCORM2004_CallSetValue("cmi.suspend_data", strData);
}
}




function SCORM2004_GetLaunchData(){
function SCORM2004_GetLaunchData(){
WriteToDebug("In SCORM2004_GetLaunchData");
WriteToDebug("In SCORM2004_GetLaunchData");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
return SCORM2004_CallGetValue("cmi.launch_data");
return SCORM2004_CallGetValue("cmi.launch_data");
}
}




function SCORM2004_GetComments(){
function SCORM2004_GetComments(){
WriteToDebug("In SCORM2004_GetComments");
WriteToDebug("In SCORM2004_GetComments");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
var intCommentCount;
var intCommentCount;
var strComments = "";
var strComments = "";
intCommentCount = SCORM2004_CallGetValue("cmi.comments_from_learner._count");
intCommentCount = SCORM2004_CallGetValue("cmi.comments_from_learner._count");
for (var i=0; i < intCommentCount; i++){
for (var i=0; i < intCommentCount; i++){
if (strComments.length > 0){
if (strComments.length > 0){
strComments += " | ";
strComments += " | ";
}
}
strComments += SCORM2004_CallGetValue("cmi.comments_from_learner." + i + ".comment");
strComments += SCORM2004_CallGetValue("cmi.comments_from_learner." + i + ".comment");
}
}
return strComments;
return strComments;


}
}


function SCORM2004_WriteComment(strComment){
function SCORM2004_WriteComment(strComment){


WriteToDebug("In SCORM2004_WriteComment strComment=" + strComment);
WriteToDebug("In SCORM2004_WriteComment strComment=" + strComment);
var intCurrentIndex;
var intCurrentIndex;
var blnResult;
var blnResult;
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
//remove the "|" since we can use the comments collection
//remove the "|" since we can use the comments collection
if (strComment.search(/ \| /) == 0){
if (strComment.search(/ \| /) == 0){
strComment = strComment.substr(3);
strComment = strComment.substr(3);
}
}
//remove encoding of "|"
//remove encoding of "|"
strComment.replace(/\|\|/g, "|")
strComment.replace(/\|\|/g, "|")
intCurrentIndex = SCORM2004_CallGetValue("cmi.comments_from_learner._count");
intCurrentIndex = SCORM2004_CallGetValue("cmi.comments_from_learner._count");
blnResult = SCORM2004_CallSetValue("cmi.comments_from_learner." + intCurrentIndex + ".comment", strComment);
blnResult = SCORM2004_CallSetValue("cmi.comments_from_learner." + intCurrentIndex + ".comment", strComment);
blnResult = SCORM2004_CallSetValue("cmi.comments_from_learner." + intCurrentIndex + ".timestamp", ConvertDateToIso8601TimeStamp(new Date())) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.comments_from_learner." + intCurrentIndex + ".timestamp", ConvertDateToIso8601TimeStamp(new Date())) && blnResult;
return blnResult;
return blnResult;
}
}




function SCORM2004_GetLMSComments(){
function SCORM2004_GetLMSComments(){
WriteToDebug("In SCORM2004_GetLMSComments");
WriteToDebug("In SCORM2004_GetLMSComments");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
var intCommentCount;
var intCommentCount;
var strComments = "";
var strComments = "";
intCommentCount = SCORM2004_CallGetValue("cmi.comments_from_lms._count");
intCommentCount = SCORM2004_CallGetValue("cmi.comments_from_lms._count");
for (var i=0; i < intCommentCount; i++){
for (var i=0; i < intCommentCount; i++){
if (strComments.length > 0){
if (strComments.length > 0){
strComments += " \r\n";
strComments += " \r\n";
}
}
strComments += SCORM2004_CallGetValue("cmi.comments_from_lms." + i + ".comment");
strComments += SCORM2004_CallGetValue("cmi.comments_from_lms." + i + ".comment");
}
}
return strComments;
return strComments;
}
}




function SCORM2004_GetAudioPlayPreference(){
function SCORM2004_GetAudioPlayPreference(){


var intTempPreference;
var intTempPreference;
WriteToDebug("In SCORM2004_GetAudioPlayPreference");
WriteToDebug("In SCORM2004_GetAudioPlayPreference");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
intTempPreference = SCORM2004_CallGetValue("cmi.learner_preference.audio_level");
intTempPreference = SCORM2004_CallGetValue("cmi.learner_preference.audio_level");
if (intTempPreference == ""){
if (intTempPreference == ""){
intTempPreference = 0;
intTempPreference = 0;
}
}
intTempPreference = parseInt(intTempPreference, 10);
intTempPreference = parseInt(intTempPreference, 10);
WriteToDebug("intTempPreference=" + intTempPreference);
WriteToDebug("intTempPreference=" + intTempPreference);
if (intTempPreference > 0){
if (intTempPreference > 0){
WriteToDebug("Returning On");
WriteToDebug("Returning On");
return PREFERENCE_ON;
return PREFERENCE_ON;
}
}
else if (intTempPreference <= 0) {
else if (intTempPreference <= 0) {
WriteToDebug("Returning Off");
WriteToDebug("Returning Off");
return PREFERENCE_OFF;
return PREFERENCE_OFF;
}
}
else{
else{
WriteToDebug("Error: Invalid preference");
WriteToDebug("Error: Invalid preference");
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_PREFERENCE,
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_PREFERENCE,
"Invalid audio preference received from LMS",
"Invalid audio preference received from LMS",
"intTempPreference=" + intTempPreference);
"intTempPreference=" + intTempPreference);
return null;
return null;
}
}
}
}






function SCORM2004_GetAudioVolumePreference(){
function SCORM2004_GetAudioVolumePreference(){
var intTempPreference;
var intTempPreference;
WriteToDebug("In SCORM2004_GetAudioVollumePreference");
WriteToDebug("In SCORM2004_GetAudioVollumePreference");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
intTempPreference = SCORM2004_CallGetValue("cmi.learner_preference.audio_level");
intTempPreference = SCORM2004_CallGetValue("cmi.learner_preference.audio_level");
WriteToDebug("intTempPreference=" + intTempPreference);
WriteToDebug("intTempPreference=" + intTempPreference);
if (intTempPreference == "") {
if (intTempPreference == "") {
intTempPreference = 100;
intTempPreference = 100;
}
}
intTempPreference = parseInt(intTempPreference, 10);
intTempPreference = parseInt(intTempPreference, 10);
if (intTempPreference <= 0){
if (intTempPreference <= 0){
WriteToDebug("Setting to 100");
WriteToDebug("Setting to 100");
intTempPreference = 100;
intTempPreference = 100;
}
}
if (! (intTempPreference > 0 && intTempPreference <= 100)){
if (! (intTempPreference > 0 && intTempPreference <= 100)){
WriteToDebug("ERROR: invalid preference");
WriteToDebug("ERROR: invalid preference");
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_PREFERENCE,
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_PREFERENCE,
"Invalid audio preference received from LMS",
"Invalid audio preference received from LMS",
"intTempPreference=" + intTempPreference);
"intTempPreference=" + intTempPreference);
return null;
return null;
}
}
WriteToDebug("Returning " + intTempPreference);
WriteToDebug("Returning " + intTempPreference);
return intTempPreference;
return intTempPreference;
}
}


function SCORM2004_SetAudioPreference(PlayPreference, intPercentOfMaxVolume){
function SCORM2004_SetAudioPreference(PlayPreference, intPercentOfMaxVolume){
WriteToDebug("In SCORM2004_SetAudioPreference PlayPreference=" + PlayPreference + ", intPercentOfMaxVolume=" + intPercentOfMaxVolume);
WriteToDebug("In SCORM2004_SetAudioPreference PlayPreference=" + PlayPreference + ", intPercentOfMaxVolume=" + intPercentOfMaxVolume);
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
if (PlayPreference == PREFERENCE_OFF){
if (PlayPreference == PREFERENCE_OFF){
WriteToDebug("Setting percent to 0");
WriteToDebug("Setting percent to 0");
intPercentOfMaxVolume = 0;
intPercentOfMaxVolume = 0;
}
}
return SCORM2004_CallSetValue("cmi.learner_preference.audio_level", intPercentOfMaxVolume);
return SCORM2004_CallSetValue("cmi.learner_preference.audio_level", intPercentOfMaxVolume);
}
}






function SCORM2004_SetLanguagePreference(strLanguage){
function SCORM2004_SetLanguagePreference(strLanguage){
WriteToDebug("In SCORM2004_SetLanguagePreference strLanguage=" + strLanguage);
WriteToDebug("In SCORM2004_SetLanguagePreference strLanguage=" + strLanguage);
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
return SCORM2004_CallSetValue("cmi.learner_preference.language", strLanguage);
return SCORM2004_CallSetValue("cmi.learner_preference.language", strLanguage);


}
}




function SCORM2004_GetLanguagePreference(){
function SCORM2004_GetLanguagePreference(){
WriteToDebug("In SCORM2004_GetLanguagePreference");
WriteToDebug("In SCORM2004_GetLanguagePreference");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
return SCORM2004_CallGetValue("cmi.learner_preference.language");
return SCORM2004_CallGetValue("cmi.learner_preference.language");


}
}




function SCORM2004_SetSpeedPreference(intPercentOfMax){
function SCORM2004_SetSpeedPreference(intPercentOfMax){
//SCORM 2004's scale is greater than 0, our range is 1 to 100, just store our range
//SCORM 2004's scale is greater than 0, our range is 1 to 100, just store our range
WriteToDebug("In SCORM2004_SetSpeedPreference intPercentOfMax=" + intPercentOfMax);
WriteToDebug("In SCORM2004_SetSpeedPreference intPercentOfMax=" + intPercentOfMax);


SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
return SCORM2004_CallSetValue("cmi.learner_preference.delivery_speed", intPercentOfMax);
return SCORM2004_CallSetValue("cmi.learner_preference.delivery_speed", intPercentOfMax);


}
}




function SCORM2004_GetSpeedPreference(){
function SCORM2004_GetSpeedPreference(){


var intSCORMSpeed;
var intSCORMSpeed;
var intPercentOfMax;
var intPercentOfMax;
WriteToDebug("In SCORM2004_GetSpeedPreference");
WriteToDebug("In SCORM2004_GetSpeedPreference");


SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
intSCORMSpeed = SCORM2004_CallGetValue("cmi.learner_preference.delivery_speed");
intSCORMSpeed = SCORM2004_CallGetValue("cmi.learner_preference.delivery_speed");
WriteToDebug("intSCORMSpeed=" + intSCORMSpeed);
WriteToDebug("intSCORMSpeed=" + intSCORMSpeed);
if (intSCORMSpeed == ""){
if (intSCORMSpeed == ""){
WriteToDebug("Detected empty string, defaulting to 100");
WriteToDebug("Detected empty string, defaulting to 100");
intSCORMSpeed = 100;
intSCORMSpeed = 100;
}
}
intSCORMSpeed = parseInt(intSCORMSpeed, 10);
intSCORMSpeed = parseInt(intSCORMSpeed, 10);
if (intSCORMSpeed < 0){
if (intSCORMSpeed < 0){
WriteToDebug("ERROR - out of range");
WriteToDebug("ERROR - out of range");
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_SPEED,
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_SPEED,
"Invalid speed preference received from LMS - out of range",
"Invalid speed preference received from LMS - out of range",
"intSCORMSpeed=" + intSCORMSpeed);
"intSCORMSpeed=" + intSCORMSpeed);
return null;
return null;
}
}


WriteToDebug("intSCORMSpeed " + intSCORMSpeed);
WriteToDebug("intSCORMSpeed " + intSCORMSpeed);
return intSCORMSpeed;
return intSCORMSpeed;


}
}








function SCORM2004_SetTextPreference(intPreference){
function SCORM2004_SetTextPreference(intPreference){
WriteToDebug("In SCORM2004_SetTextPreference intPreference=" + intPreference);
WriteToDebug("In SCORM2004_SetTextPreference intPreference=" + intPreference);
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
return SCORM2004_CallSetValue("cmi.learner_preference.audio_captioning", intPreference);
return SCORM2004_CallSetValue("cmi.learner_preference.audio_captioning", intPreference);


}
}




function SCORM2004_GetTextPreference(){
function SCORM2004_GetTextPreference(){


var intTempPreference;
var intTempPreference;
WriteToDebug("In SCORM2004_GetTextPreference");
WriteToDebug("In SCORM2004_GetTextPreference");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();


intTempPreference = SCORM2004_CallGetValue("cmi.learner_preference.audio_captioning");
intTempPreference = SCORM2004_CallGetValue("cmi.learner_preference.audio_captioning");
intTempPreference = parseInt(intTempPreference, 10);
intTempPreference = parseInt(intTempPreference, 10);
WriteToDebug("intTempPreference=" + intTempPreference);
WriteToDebug("intTempPreference=" + intTempPreference);
if (intTempPreference > 0){
if (intTempPreference > 0){
WriteToDebug("Returning On");
WriteToDebug("Returning On");
return PREFERENCE_ON;
return PREFERENCE_ON;
}
}
else if (intTempPreference == 0 || intTempPreference == ""){
else if (intTempPreference == 0 || intTempPreference == ""){
WriteToDebug("Returning Default");
WriteToDebug("Returning Default");
return PREFERENCE_DEFAULT;
return PREFERENCE_DEFAULT;
}
}
else if (intTempPreference < 0) {
else if (intTempPreference < 0) {
WriteToDebug("Returning Off");
WriteToDebug("Returning Off");
return PREFERENCE_OFF;
return PREFERENCE_OFF;
}
}
else{
else{
WriteToDebug("Error: Invalid preference");
WriteToDebug("Error: Invalid preference");
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_PREFERENCE,
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_PREFERENCE,
"Invalid text preference received from LMS",
"Invalid text preference received from LMS",
"intTempPreference=" + intTempPreference);
"intTempPreference=" + intTempPreference);
return null;
return null;
}
}
}
}






//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
//Time Management Functions
//Time Management Functions
function SCORM2004_GetPreviouslyAccumulatedTime(){
function SCORM2004_GetPreviouslyAccumulatedTime(){
var strIso8601Time;
var strIso8601Time;
var intMilliseconds;
var intMilliseconds;
WriteToDebug("In SCORM2004_GetPreviouslyAccumulatedTime");
WriteToDebug("In SCORM2004_GetPreviouslyAccumulatedTime");


SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
strIso8601Time = SCORM2004_CallGetValue("cmi.total_time")
strIso8601Time = SCORM2004_CallGetValue("cmi.total_time")
WriteToDebug("strIso8601Time=" + strIso8601Time);
WriteToDebug("strIso8601Time=" + strIso8601Time);


if (! IsValidIso8601TimeSpan(strIso8601Time)){
if (! IsValidIso8601TimeSpan(strIso8601Time)){
WriteToDebug("ERROR - Invalid Iso8601Time");
WriteToDebug("ERROR - Invalid Iso8601Time");
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_TIMESPAN,
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_TIMESPAN,
"Invalid timespan received from LMS",
"Invalid timespan received from LMS",
"strTime=" + strIso8601Time);
"strTime=" + strIso8601Time);
return null;
return null;
}
}
intMilliseconds = ConvertScorm2004TimeToMS(strIso8601Time);
intMilliseconds = ConvertScorm2004TimeToMS(strIso8601Time);
WriteToDebug("Returning " + intMilliseconds);
WriteToDebug("Returning " + intMilliseconds);
return intMilliseconds;
return intMilliseconds;


}
}




function SCORM2004_SaveTime(intMilliSeconds){
function SCORM2004_SaveTime(intMilliSeconds){


var strISO8601Time;
var strISO8601Time;
WriteToDebug("In SCORM2004_SaveTime intMilliSeconds=" + intMilliSeconds);
WriteToDebug("In SCORM2004_SaveTime intMilliSeconds=" + intMilliSeconds);
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
strISO8601Time = ConvertMilliSecondsIntoSCORM2004Time(intMilliSeconds);
strISO8601Time = ConvertMilliSecondsIntoSCORM2004Time(intMilliSeconds);
WriteToDebug("strISO8601Time=" + strISO8601Time);
WriteToDebug("strISO8601Time=" + strISO8601Time);
return SCORM2004_CallSetValue("cmi.session_time", strISO8601Time);
return SCORM2004_CallSetValue("cmi.session_time", strISO8601Time);
}
}


function SCORM2004_GetMaxTimeAllowed(){
function SCORM2004_GetMaxTimeAllowed(){


var strIso8601Time;
var strIso8601Time;
var intMilliseconds;
var intMilliseconds;
WriteToDebug("In SCORM2004_GetMaxTimeAllowed");
WriteToDebug("In SCORM2004_GetMaxTimeAllowed");




SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
strIso8601Time = SCORM2004_CallGetValue("cmi.max_time_allowed")
strIso8601Time = SCORM2004_CallGetValue("cmi.max_time_allowed")
WriteToDebug("strIso8601Time=" + strIso8601Time);
WriteToDebug("strIso8601Time=" + strIso8601Time);
if (strIso8601Time == ""){
if (strIso8601Time == ""){
strIso8601Time = "20Y";
strIso8601Time = "20Y";
}
}


if (! IsValidIso8601TimeSpan(strIso8601Time)){
if (! IsValidIso8601TimeSpan(strIso8601Time)){
WriteToDebug("ERROR - Invalid Iso8601Time");
WriteToDebug("ERROR - Invalid Iso8601Time");
SCORM2004_SetErrorInfoManually(SCORM_ERROR_INVALID_TIMESPAN,
SCORM2004_SetErrorInfoManually(SCORM_ERROR_INVALID_TIMESPAN,
"Invalid timespan received from LMS",
"Invalid timespan received from LMS",
"strIso8601Time=" + strIso8601Time);
"strIso8601Time=" + strIso8601Time);
return null;
return null;
}
}
intMilliseconds = ConvertScorm2004TimeToMS(ConvertScorm2004TimeToMS);
intMilliseconds = ConvertScorm2004TimeToMS(ConvertScorm2004TimeToMS);
WriteToDebug("intMilliseconds=" + intMilliseconds);
WriteToDebug("intMilliseconds=" + intMilliseconds);
return intMilliseconds;
return intMilliseconds;


}
}






function SCORM2004_DisplayMessageOnTimeout(){
function SCORM2004_DisplayMessageOnTimeout(){


var strTLA;
var strTLA;
WriteToDebug("In SCORM2004_DisplayMessageOnTimeout");
WriteToDebug("In SCORM2004_DisplayMessageOnTimeout");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
strTLA = SCORM2004_CallGetValue("cmi.time_limit_action");
strTLA = SCORM2004_CallGetValue("cmi.time_limit_action");
WriteToDebug("strTLA=" + strTLA);
WriteToDebug("strTLA=" + strTLA);
if (strTLA == SCORM2004_TLA_EXIT_MESSAGE || strTLA == SCORM2004_TLA_CONTINUE_MESSAGE){
if (strTLA == SCORM2004_TLA_EXIT_MESSAGE || strTLA == SCORM2004_TLA_CONTINUE_MESSAGE){
WriteToDebug("returning true");
WriteToDebug("returning true");
return true;
return true;
}
}
else if(strTLA == SCORM2004_TLA_EXIT_NO_MESSAGE || strTLA == SCORM2004_TLA_CONTINUE_NO_MESSAGE || strTLA == ""){
else if(strTLA == SCORM2004_TLA_EXIT_NO_MESSAGE || strTLA == SCORM2004_TLA_CONTINUE_NO_MESSAGE || strTLA == ""){
WriteToDebug("returning false");
WriteToDebug("returning false");
return false;
return false;
}
}
else{
else{
WriteToDebug("Error invalid TLA");
WriteToDebug("Error invalid TLA");
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_TIME_LIMIT_ACTION,
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_TIME_LIMIT_ACTION,
"Invalid time limit action received from LMS",
"Invalid time limit action received from LMS",
"strTLA=" + strTLA);
"strTLA=" + strTLA);
return null;
return null;
}
}
}
}


function SCORM2004_ExitOnTimeout(){
function SCORM2004_ExitOnTimeout(){


var strTLA;
var strTLA;
WriteToDebug("In SCORM2004_ExitOnTimeout");
WriteToDebug("In SCORM2004_ExitOnTimeout");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
strTLA = SCORM2004_CallGetValue("cmi.time_limit_action");
strTLA = SCORM2004_CallGetValue("cmi.time_limit_action");
WriteToDebug("strTLA=" + strTLA);
WriteToDebug("strTLA=" + strTLA);
if (strTLA == SCORM2004_TLA_EXIT_MESSAGE || strTLA == SCORM2004_TLA_EXIT_NO_MESSAGE){
if (strTLA == SCORM2004_TLA_EXIT_MESSAGE || strTLA == SCORM2004_TLA_EXIT_NO_MESSAGE){
WriteToDebug("returning true");
WriteToDebug("returning true");
return true;
return true;
}
}
else if(strTLA == SCORM2004_TLA_CONTINUE_MESSAGE || strTLA == SCORM2004_TLA_CONTINUE_NO_MESSAGE || strTLA == ""){
else if(strTLA == SCORM2004_TLA_CONTINUE_MESSAGE || strTLA == SCORM2004_TLA_CONTINUE_NO_MESSAGE || strTLA == ""){
WriteToDebug("returning false");
WriteToDebug("returning false");
return false;
return false;
}
}
else{
else{
WriteToDebug("ERROR invalid TLA");
WriteToDebug("ERROR invalid TLA");
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_TIME_LIMIT_ACTION,
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_TIME_LIMIT_ACTION,
"Invalid time limit action received from LMS",
"Invalid time limit action received from LMS",
"strTLA=" + strTLA);
"strTLA=" + strTLA);
return null;
return null;
}
}


}
}




function SCORM2004_GetPassingScore(){
function SCORM2004_GetPassingScore(){
var fltScore;
var fltScore;
WriteToDebug("In SCORM2004_GetPassingScore");
WriteToDebug("In SCORM2004_GetPassingScore");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
fltScore = SCORM2004_CallGetValue("cmi.scaled_passing_score")
fltScore = SCORM2004_CallGetValue("cmi.scaled_passing_score")
WriteToDebug("fltScore=" + fltScore);
WriteToDebug("fltScore=" + fltScore);
if (fltScore == ""){
if (fltScore == ""){
fltScore = 0;
fltScore = 0;
}
}
if ( ! IsValidDecimal(fltScore)){
if ( ! IsValidDecimal(fltScore)){
WriteToDebug("Error - score is not a valid decimal");
WriteToDebug("Error - score is not a valid decimal");
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_DECIMAL,
SCORM2004_SetErrorInfoManually(SCORM2004_ERROR_INVALID_DECIMAL,
"Invalid mastery score received from LMS",
"Invalid mastery score received from LMS",
"fltScore=" + fltScore);
"fltScore=" + fltScore);
return null;
return null;
}
}
fltScore = parseFloat(fltScore);
fltScore = parseFloat(fltScore);
//multiply by 100 to normalize from -1 to 1 to 0-100 - (we always set the score so we know it won't be negative)
//multiply by 100 to normalize from -1 to 1 to 0-100 - (we always set the score so we know it won't be negative)
fltScore = fltScore * 100;
fltScore = fltScore * 100;
WriteToDebug("returning fltScore-" + fltScore);
WriteToDebug("returning fltScore-" + fltScore);
return fltScore;
return fltScore;
}
}




function SCORM2004_SetScore(intScore, intMaxScore, intMinScore){
function SCORM2004_SetScore(intScore, intMaxScore, intMinScore){
var blnResult;
var blnResult;
var fltNormalizedScore;
var fltNormalizedScore;


WriteToDebug("In SCORM2004_SetScore intScore=" + intScore + ", intMaxScore=" + intMaxScore + ", intMinScore=" + intMinScore);
WriteToDebug("In SCORM2004_SetScore intScore=" + intScore + ", intMaxScore=" + intMaxScore + ", intMinScore=" + intMinScore);


SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
fltNormalizedScore = intScore / 100;
fltNormalizedScore = intScore / 100;


var strPercentScore = fltNormalizedScore.toString();
var strPercentScore = fltNormalizedScore.toString();
var nPos = strPercentScore.lastIndexOf(".");
var nPos = strPercentScore.lastIndexOf(".");
if (nPos >= 0 && strPercentScore.length - 5 > nPos)
if (nPos >= 0 && strPercentScore.length - 5 > nPos)
{
{
strPercentScore = strPercentScore.substring(0, nPos + 5);
strPercentScore = strPercentScore.substring(0, nPos + 5);
}
}
blnResult = SCORM2004_CallSetValue("cmi.score.raw", intScore);
blnResult = SCORM2004_CallSetValue("cmi.score.raw", intScore);
blnResult = SCORM2004_CallSetValue("cmi.score.max", intMaxScore) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.score.max", intMaxScore) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.score.min", intMinScore) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.score.min", intMinScore) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.score.scaled", strPercentScore) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.score.scaled", strPercentScore) && blnResult;
WriteToDebug("Returning " + blnResult);
WriteToDebug("Returning " + blnResult);
return blnResult;
return blnResult;
}
}


function SCORM2004_GetScore(){
function SCORM2004_GetScore(){


WriteToDebug("In SCORM2004_GetScore");
WriteToDebug("In SCORM2004_GetScore");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
return SCORM2004_CallGetValue("cmi.score.raw");
return SCORM2004_CallGetValue("cmi.score.raw");


}
}


function SCORM2004_GetScaledScore(){
function SCORM2004_GetScaledScore(){


WriteToDebug("In SCORM2004_GetScaledScore");
WriteToDebug("In SCORM2004_GetScaledScore");
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
return SCORM2004_CallGetValue("cmi.score.scaled");
return SCORM2004_CallGetValue("cmi.score.scaled");


}
}


function SCORM2004_RecordInteraction(strID, strResponse, blnCorrect, strCorrectResponse, strDescription, intWeighting, intLatency, strLearningObjectiveID, dtmTime, SCORM2004InteractionType){
function SCORM2004_RecordInteraction(strID, strResponse, blnCorrect, strCorrectResponse, strDescription, intWeighting, intLatency, strLearningObjectiveID, dtmTime, SCORM2004InteractionType){
var blnResult;
var blnResult;
var intInteractionIndex;
var intInteractionIndex;
var strResult;
var strResult;
blnCorrect = new String(blnCorrect); //have to cast as string to support false
blnCorrect = new String(blnCorrect); //have to cast as string to support false
SCORM2004_ClearErrorInfo();
SCORM2004_ClearErrorInfo();
intInteractionIndex = SCORM2004_CallGetValue("cmi.interactions._count");
intInteractionIndex = SCORM2004_CallGetValue("cmi.interactions._count");
WriteToDebug("intInteractionIndex=" + intInteractionIndex);
WriteToDebug("intInteractionIndex=" + intInteractionIndex);
if (intInteractionIndex == ""){
if (intInteractionIndex == ""){
WriteToDebug("Setting Interaction Index to 0");
WriteToDebug("Setting Interaction Index to 0");
intInteractionIndex = 0;
intInteractionIndex = 0;
}
}
//need to leave support for blnCorrect=t/f for legacy implementations of RSECA
//need to leave support for blnCorrect=t/f for legacy implementations of RSECA
if (blnCorrect == true || blnCorrect =="true" || blnCorrect == INTERACTION_RESULT_CORRECT){
if (blnCorrect == true || blnCorrect =="true" || blnCorrect == INTERACTION_RESULT_CORRECT){
strResult = SCORM2004_RESULT_CORRECT;
strResult = SCORM2004_RESULT_CORRECT;
}
}
else if (String(blnCorrect) == "false" || blnCorrect == INTERACTION_RESULT_WRONG){ //compare against the string "false" because ("" == false) evaluates to true
else if (String(blnCorrect) == "false" || blnCorrect == INTERACTION_RESULT_WRONG){ //compare against the string "false" because ("" == false) evaluates to true
strResult = SCORM2004_RESULT_WRONG;
strResult = SCORM2004_RESULT_WRONG;
}
}
else if (blnCorrect == INTERACTION_RESULT_UNANTICIPATED){
else if (blnCorrect == INTERACTION_RESULT_UNANTICIPATED){
strResult = SCORM2004_RESULT_UNANTICIPATED;
strResult = SCORM2004_RESULT_UNANTICIPATED;
}
}
else if (blnCorrect == INTERACTION_RESULT_NEUTRAL){
else if (blnCorrect == INTERACTION_RESULT_NEUTRAL){
strResult = SCORM2004_RESULT_NEUTRAL;
strResult = SCORM2004_RESULT_NEUTRAL;
}
}
else{
else{
strResult = "";
strResult = "";
}
}
WriteToDebug("strResult=" + strResult);
WriteToDebug("strResult=" + strResult);
strID = CreateValidIdentifier(strID);
strID = CreateValidIdentifier(strID);
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".id", strID);
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".id", strID);
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".type", SCORM2004InteractionType) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".type", SCORM2004InteractionType) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".learner_response", strResponse) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".learner_response", strResponse) && blnResult;
if (strResult != undefined && strResult != null && strResult != ""){
if (strResult != undefined && strResult != null && strResult != ""){
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".result", strResult) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".result", strResult) && blnResult;
}
}
if (strCorrectResponse != undefined && strCorrectResponse != null && strCorrectResponse != ""){
if (strCorrectResponse != undefined && strCorrectResponse != null && strCorrectResponse != ""){
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".correct_responses.0.pattern", strCorrectResponse) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".correct_responses.0.pattern", strCorrectResponse) && blnResult;
}
}
if (strDescription != undefined && strDescription != null && strDescription != ""){
if (strDescription != undefined && strDescription != null && strDescription != ""){
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".description", strDescription) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".description", strDescription) && blnResult;
}
}
if (intWeighting != undefined && intWeighting != null && intWeighting != ""){
if (intWeighting != undefined && intWeighting != null && intWeighting != ""){
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".weighting", intWeighting) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".weighting", intWeighting) && blnResult;
}
}


if (intLatency != undefined && intLatency != null && intLatency != ""){
if (intLatency != undefined && intLatency != null && intLatency != ""){
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".latency", ConvertMilliSecondsIntoSCORM2004Time(intLatency)) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".latency", ConvertMilliSecondsIntoSCORM2004Time(intLatency)) && blnResult;
}
}
if (strLearningObjectiveID != undefined && strLearningObjectiveID != null && strLearningObjectiveID != ""){
if (strLearningObjectiveID != undefined && strLearningObjectiveID != null && strLearningObjectiveID != ""){
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".objectives.0.id", strLearningObjectiveID) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".objectives.0.id", strLearningObjectiveID) && blnResult;
}
}
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".timestamp", ConvertDateToIso8601TimeStamp(dtmTime)) && blnResult;
blnResult = SCORM2004_CallSetValue("cmi.interactions." + intInteractionIndex + ".timestamp", ConvertDateToIso8601TimeStamp(dtmTime)) && blnResult;
WriteToDebug("Returning " + blnResult);
WriteToDebug("Returning " + blnResult);
return blnResult;
return blnResult;
}
}


function SCORM2004_RecordTrueFalseInteraction(strID, blnResponse, blnCorrect, blnCorrectResponse, strDescription, intWeighting, intLatency, strLearningObjectiveID, dtmTime){
function SCORM2004_RecordTrueFalseInteraction(strID, blnResponse, blnCorrect, blnCorrectResponse, strDescription, intWeighting, intLatency, strLearningObjectiveID, dtmTime){
WriteToDebug("In SCORM2004_RecordTrueFalseInteraction strID=" + strID + ", strResponse=" + strResponse +
WriteToDebug("In SCORM2004_RecordTrueFalseInteraction strID=" + strID + ", strResponse=" + strResponse +
", blnCorrect=" + blnCorrect + ", strCorrectResponse=" + strCorrectResponse +
", blnCorrect=" + blnCorrect + ", strCorrectResponse=" + strCorrectResponse +
", strDescription=" + strDescription + ", intWeighting=" + intWeighting + ", intLatency=" + intLatency +
", strDescription=" + strDescription + ", intWeighting=" + intWeighting + ", intLatency=" + intLatency +
", strLearningObjectiveID=" + strLearningObjectiveID + ", dtmTime=" + dtmTime);
", strLearningObjectiveID=" + strLearningObjectiveID + ", dtmTime=" + dtmTime);


var strResponse = "";
var strResponse = "";
var strCorrectResponse = null;
var strCorrectResponse = null;
if (blnResponse){
if (blnResponse){
strResponse = "true";
strResponse = "true";
}
}
else{
else{
strResponse = "false";
strResponse = "false";
}
}
if (blnCorrectResponse == true){
if (blnCorrectResponse == true){
strCorrectResponse = "true";
strCorrectResponse = "true";
}
}
else if(blnCorrectResponse == false){ //test for false b/c it could be null in which case we want to leave it as ""
else if(blnCorrectResponse == false){ //test for false b/c it could be null in which case we want to leave it as ""
strCorrectResponse = "false";
strCorrectResponse = "false";
}
}
return SCORM2004_RecordInteraction(strID, strResponse, blnCorrect, strCorrectResponse, strDescription, intWeighting, intLatency, strLearningObjectiveID, dtmTime, SCORM2004_INTERACTION_TYPE_TRUE_FALSE);
return SCORM2004_RecordInteraction(strID, strResponse, blnCorrect, strCorrectResponse, strDescription, intWeighting, intLatency, strLearningObjectiveID, dtmTime, SCORM2004_INTERACTION_TYPE_TRUE_FALSE);
}
}




function SCORM2004_RecordMultipleChoiceInteraction(strID, aryResponse, blnCorrect, aryCorrectResponse, strDescription, intWeighting, intLatency, strLearningObjectiveID, dtmTime){
function SCORM2004_RecordMultipleChoiceInteraction(strID, aryResponse, blnCorrect, aryCorrectResponse, strDescription, intWeighting, intLatency, strLearningObjectiveID, dtmTime){
WriteToDebug("In SCORM2004_RecordMultipleChoiceInteraction strID=" + strID + ", aryResponse=" + aryResponse +
WriteToDebug("In SCORM2004_RecordMultipleChoiceInteraction strID=" + strID + ", aryResponse=" + aryResponse +
", blnCorrect=" + blnCorrect + ", aryCorrectResponse=" + aryCorrectResponse +
", blnCorrect=" + blnCorrect + ", aryCorrectResponse=" + aryCorrectResponse +
", strDescription=" + strDescription + ", intWeighting=" + intWeighting + ", intLatency=" + intLatency +
", strDescription=" + strDescription + ", intWeighting=" + intWeighting + ", intLatency=" + intLatency +
", strLearningObjectiveID=" + strLearningObjectiveID + ", dtmTime=" + dtmTime);
", strLearningObjectiveID=" + strLearningObjectiveID + ", dtmTime=" + dtmTime);
var strResponse = "";
var strResponse = "";
var strCorrectResponse = "";
var strCorrectResponse = "";
for (var i=0; i < aryResponse.length; i++){
for (var i=0; i < aryResponse.length; i++){
if (strResponse.length > 0) {strResponse += "[,]";}
if (strResponse.length > 0) {strResponse += "[,]";}
strResponse += aryResponse[i].Long;
strResponse += aryResponse[i].Long;
}
}


for (var i=0; i < aryCorrectResponse.length; i++){
for (var i=0; i < aryCorrectResponse.length; i++){
if (strCorrectResponse.length > 0) {strCorrectResponse += "[,]";}
if (strCorrectResponse.length > 0) {strCorrectResponse += "[,]";}
strCorrectResponse += aryCorrectResponse[i].Long;
strCorrectResponse += aryCorrectResponse[i].Long;
}
}
return SCORM2004_RecordInteraction(strID, strResponse, blnCorrect, strCorrectResponse, strDescription, intWeighting, intLatency, strLearningObjectiveID, dtmTime, SCORM2004_INTERACTION_TYPE_CHOICE);
return SCORM2004_RecordInteraction(strID, strResponse, blnCorrect, strCorrectResponse, strDescription, intWeighting, intLatency, strLearningObjectiveID, dtmTime, SCORM2004_INTERACTI
}


function SCORM2004_RecordFillInInteraction(strID, strResponse, blnCorrect, strCorrectResponse, strDescription, intWeighting, intL