﻿
/************************************************************************************************************************************************************************
** 
** Filename: lmsHelper Object
** File Description: This file contains the core functions require for communication between the LMS and the Flash Container via the SCORM API
** Author: James Jackson
**
/************************************************************************************************************************************************************************


	/*************************************************************************************************************************************
	** Constuctor
	*************************************************************************************************************************************/


		function lmsHelper()
		{
			
				/*************************************************************************************************************
				/** Methods 
				*************************************************************************************************************/
					try 
					{
						this.setUnitStatus=lmsHelper_setUnitStatus;
						this.getUnitStatus=lmsHelper_getUnitStatus;
						this.setUnitTestScores=lmsHelper_setUnitTestScores;
						this.getUnitTestScores=lmsHelper_getUnitTestScores;
						this.setUnitQuizScores=lmsHelper_setUnitQuizScores;
						this.getUnitQuizScores=lmsHelper_getUnitQuizScores;
						this.setBookmarkPosition=lmsHelper_setBookmarkPosition;
						this.getBookmarkPosition=lmsHelper_getBookmarkPosition;
						this.setLessonStatus=lmsHelper_setLessonStatus;
						this.getLessonStatus=lmsHelper_getLessonStatus;
						this.setFinalLessonStatus=lmsHelper_setFinalLessonStatus;
						this.setCourseStatus = lmsHelper_setCourseStatus;
						this.resetModule=lmsHelper_resetModule;
						this.setRawScore=lmsHelper_setRawScore;
						this.getStudentName=lmsHelper_getStudentName;
						this.setInteractionObject = lmsHelper_setInteractionObject; 
						this.setConfig = lmsHelper_setConfig;
						this.getSuspendDataBookmarkPosition = lmsHelper_getSuspendDataBookmarkPosition; 
						
						// LMS variables
						
						this.lmsInteractionErrors = 0;
						
					}catch(e)
					{
						errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> methods]");
					}
				
				
				/*************************************************************************************************************
				/** Properties 
				*************************************************************************************************************/
					
					try {	
					}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> properties]");}
					
					
				
		}


	/*************************************************************************************************************************************
	** Core Flash & SCORM LMS Communication Functions
	*************************************************************************************************************************************/

	/************************************************************************************************************************************
			**
			** Function: lmsHelper.setRawScore();
			** Description: Set the learners score to the LMS
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/
				
					function lmsHelper_setRawScore( __score ){
						try {
							
								if (useCookieTracking) {
								
									createCookie("rawScore",__score,100);
									
									// alert(useCookieTracking + ":KT.cookie == " + __score)
								
								} else {
								
									//Send the data to the LMS
									// alert(useCookieTracking + ":KT.lms == " + __score)
									
									_scormHelper.setRawScore( __score );
									
									if(Number(__score) >= 70)
									{
										setExamPassedDate()
										
									} else 
									{
										setExamFailedDate()
									}
									
									_scorm.doLMSCommit();
									
								}
								
						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> getStudentName()");}
					}
			
			
			/************************************************************************************************************************************
			**
			** Function: lmsHelper.lmsHelper_getStudentName();
			** Description: Sets the learners Name within the flash container
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/
				
					function lmsHelper_getStudentName(){
						
						try {								
								
								//Gets the learners name from LMS
								var myLearner = _scormHelper.getStudentName();
									
								//Sends the data to the flash Container
								
								thisMovie("container").returnStudentName( myLearner )
								
								// alert("Setting the learner name " + myLearner)
								
								// window.document.flashContainer.SetVariable("_level0.container.aicc.learnerName", myLearner);
								
						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> getStudentName()");}
					}
					
					
			/************************************************************************************************************************************
			**
			** Function: lmsHelper.lmsHelper_getBookmarkPosition();
			** Description: Sets the learners Name within the flash container
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/	
				
					function lmsHelper_getLessonStatus() 
					{
						try {
								// alert("getting Lesson Location")
								
								var b = _scormHelper.getIsShowConfigOptions(); 
								// _scormHelper.getStudentName();
								// true; // _scormHelper.getIsShowConfigOptions();
								
								// alert("getIsShowConfigOptions == " + b)
								
								
								// thisMovie("container").returnBookmarkPosition( data )
								
								thisMovie("container").returnLessonStatus( b )
								
								/*
								var lessonLocation = _scorm.doLMSGetValue( "cmi.core.lesson_location");
									
									// String manipulation to format correctly for the course
									
									//Since getBookmarkPosition() not called properly we have added the following script below

									var a = lessonLocation.split("|")
									
									var b = a[0].split("=")
									
									var c = b[1]
									
									var d = replace(c, "@", "|")
								thisMovie("container").returnLessonConfig( d )
								
								*/
								
								// window.document.flashContainer.SetVariable("_level0.container.aicc.learnerName", myLearner);
								
						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> getStudentName()");}
					}
					
			/************************************************************************************************************************************
			**
			** Function: lmsHelper.lmsHelper_getBookmarkPosition();
			** Description: Sets the learners Name within the flash container
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/
				
					function lmsHelper_getSuspendDataBookmarkPosition()
					{	
						try {
								_scormHelper.retrieveSuspendData();
								
								var data = _scormHelper.getSuspendDataElement("bookmark")
								
								//thisMovie("container").returnBookmarkPosition( data )
								thisMovie("container").returnBookmarkPosition( data )
								
								// window.document.flashContainer.SetVariable("_level0.container.aicc.learnerName", myLearner);
								
						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> getStudentName()");}
					}
					
					
					
					
					
			/************************************************************************************************************************************
			**
			** Function: lmsHelper.setUnitStatus();
			** Description: Get's the unit status's within the flash container, via directly accessing them via the _global property
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/
			
					
					function lmsHelper_setUnitStatus(__statusArray)
					{
						// alert("setUnitStatus : " + __statusArray)
						
						// // alert(__statusArray);
						try {
									
									//Gets the Suspend Data from LMS
										_scormHelper.retrieveSuspendData();
									
									//Convert the unit statuses argument from a string array into a JavaScript Array
										var statusArrayStr = new String(__statusArray);
										var UnitStatusArray = statusArrayStr.split("|");
										
									//Save Unit Statuses to the LMS
										for(var count in UnitStatusArray){	
											
											__unitNumber = parseInt(count) + 1;
											__status = UnitStatusArray[count].toLowerCase(); ;
											
											if(__status == "passed")
											{
												statusNumber = "5";
												
											} else if(__status == "failed")
											{
												statusNumber = "4";
												
											} else if(__status == "completed")
											{
												statusNumber = "3";
												
											} else if(__status == "incomplete" || __status == "started")
											{
												statusNumber = "2";
												
											} else if(__status == "not started" || __status == "available" )
											{
												statusNumber = "1";
												
											} else
											{
												statusNumber = "0";
											}
											
											_scormHelper.setSuspendDataElement("u" + __unitNumber, statusNumber);
											
											if(count == 0 && statusNumber == 2) setCourseStartDate()
											
											if(count == 2 && statusNumber == 3) setCourseCompleteDate()
											
											/*
											if(count == 3)
											{
												if(UnitStatusArray[count] != 5 && statusNumber >= 4)
												{
													setExamCompleteDate( true )
													
												} else 
												{
													setExamCompleteDate( false )
												}
											}
											*/
											
										}
										
										if(this.lmsInteractionErrors > 0) alert("LMS Error sending Assessment Data: " + this.lmsInteractionErrors)
										
										// this.lmsInteractionErrors
										//Saves Data to LMS
										_scormHelper.commitSuspendData();
										// _scorm.doLMSCommit();
										
										var isSuccess = _scorm.doLMSCommit();
										
										//commented by madhan if(isSuccess != "true") alert("Error with LMS connection")
										
										this.lmsInteractionErrors = 0;
										
								
						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> setUnitStatus()");}
					}
					
					
					function setCourseStartDate() 
					{
						try 
						{
							// Get the previous value from the suspend data and check whether it has been set or not
							// Gets the Suspend Data from LMS
								// _scormHelper.retrieveSuspendData();
								
							// Gets the number of units
								var previousDate = _scormHelper.getSuspendDataElement("courseStart");
								
								if(String(previousDate).length < 1)
								{
									var d = this.getCurrentDataAndTime();
									
									// "09/02/22";
									
									_scormHelper.setSuspendDataElement("courseStart", d);
									
									//Save data to the LMS
									// _scormHelper.commitSuspendData();
									// _scorm.doLMSCommit();
								}
								
							
						} catch(e)
						{ 
							errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> setCourseStartDate()");
						}
					}
					
					function setCourseCompleteDate() 
					{
						try 
						{
							// Get the previous value from the suspend data and check whether it has been set or not
							// Get the previous value from the suspend data and check whether it has been set or not
							// Gets the Suspend Data from LMS
								// _scormHelper.retrieveSuspendData();
								
							// Gets the number of units
								var previousDate = _scormHelper.getSuspendDataElement("courseEnd");
								
								if(String(previousDate).length < 1)
								{
									var d = this.getCurrentDataAndTime();
									
									// "09/02/22";
									_scormHelper.setSuspendDataElement("courseEnd", d);
									
									//Save data to the LMS
									// _scormHelper.commitSuspendData();
									// _scorm.doLMSCommit();
								}
							
						} catch(e)
						{ 
							errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> setCourseCompleteDate()");
						}
					}
					
					function setExamPassedDate( overwrite ) 
					{
						try 
						{
							// Gets the Suspend Data from LMS
								_scormHelper.retrieveSuspendData();
								
							// Gets the previous value
								var previousDate = _scormHelper.getSuspendDataElement("examPassed");
								
								if(String(previousDate).length < 1)
								{
									var d = this.getCurrentDataAndTime();
									
									// "09/02/22";
									_scormHelper.setSuspendDataElement("examPassed", d);
									
									//Save data to the LMS
									_scormHelper.commitSuspendData();
									_scorm.doLMSCommit();
								}
								
								// alert("setExamPassedDate : " + overwrite)
								
								// alert("setExamCompleteDate " + Number(score) + " >= " + Number(passMark) )
							
						} catch(e)
						{ 
							errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> setCourseCompleteDate()");
						}
					}
					
					function setExamFailedDate() 
					{
						try 
						{
							// Gets the Suspend Data from LMS
								_scormHelper.retrieveSuspendData();
								
								var d = this.getCurrentDataAndTime();
									
								// "09/02/22";
								_scormHelper.setSuspendDataElement("examFailed", d);
								
								//Save data to the LMS
								_scormHelper.commitSuspendData();
								_scorm.doLMSCommit();
								
								// alert("setExamFailedDate : " + overwrite)
								
								// alert("setExamCompleteDate " + Number(score) + " >= " + Number(passMark) )
							
						} catch(e)
						{ 
							errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> setExamFailedDate()");
						}
					}
					
					function getCurrentDataAndTime() 
					{
						try 
						{
							var d = new Date() 
							
							var year = d.getFullYear();
							var month = convertToDoubleDigit( d.getMonth()+1 );							
							var date = convertToDoubleDigit( d.getDate() );
							var hours = convertToDoubleDigit( d.getHours() );
							var mins = convertToDoubleDigit( d.getMinutes() );
							var secs = convertToDoubleDigit( d.getSeconds() );
							
							var s = year + "-" + month + "-" + date + " " + hours + ":" + mins + ":" + secs;
							
							return s;
							
						} catch(e)
						{ 
							errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> setCourseCompleteDate()");
						}
					}
					
					function convertToDoubleDigit( val ) 
					{
						var s = String(val);
						
						if(s.length == 1) s = "0"+s;
						
						return s;
					}

			/************************************************************************************************************************************
			**
			** Function: lmsHelper.getUnitStatus();
			** Description: Sets the unit status's within the flash container, via directly accessing them via the _global property
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/
					
					function lmsHelper_getUnitStatus()
					{					
						try {
								
								
								//Gets the Suspend Data from LMS
									_scormHelper.retrieveSuspendData();
								
								//Gets the number of units
									var unitCount = _scormHelper.getSuspendDataElement("unitNumber");

								//Creates a temporary array Variable to hold the unit statuses
									var unitStatusArray = [];
								
								//Gets the status from the LMS Suspend Data
									for(var count=0; count < unitCount; count++){
										__unitNumber = parseInt(count) + 1;
										unitStatusArray.push(_scormHelper.getSuspendDataElement("u" + __unitNumber));
									}
									
								//Converts the Unit Status Array into a String Array
									unitStatusArrayStr = unitStatusArray.join("|");
									
								//Sends the data to the flash Container	
								// window.document.flashContainer.SetVariable("_level0.container.aicc.cmiUnitStatus", unitStatusArrayStr);
									
									callExternalInterface( unitStatusArrayStr );
									
									lmsHelper_getStudentName();
									
									lmsHelper_getSuspendDataBookmarkPosition();
									
									// lmsHelper_getBookmarkPosition();
									
									// // alert("getUnitStatus() : " + unitStatusArrayStr);
									
									// alert( "unitStatusArrayStr : " + unitStatusArrayStr )
									
						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> getUnitStatus()");}
					}


			/************************************************************************************************************************************
			**
			** Function: lmsHelper.setUnitTestScores();
			** Description: Get's the unit status's within the flash container, via directly accessing them via the _global property
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/
			
					
					function lmsHelper_setUnitTestScores(__unitTestScoresArray){
						// // alert("setUnitTestScores");
						// // alert(__unitTestScoresArray);
						try {
									
									//Gets the Suspend Data from LMS
										_scormHelper.retrieveSuspendData();
									
									//Convert the unit statuses argument from a string array into a JavaScript Array
										var unitTestScoresArrayStr = new String(__unitTestScoresArray);
										var unitTestScoresArray = unitTestScoresArrayStr.split("|");
										
									//Save Unit Statuses to the LMS
										for(var count in unitTestScoresArray){	
											
											__unitNumber = parseInt(count) + 1;
											__status = unitTestScoresArray[count].toLowerCase(); 
											// // alert("for in count");
											// // alert(__status);
											_scormHelper.setSuspendDataElement("ut" + __unitNumber, __status);
										}
	
									//Saves Data to LMS
										_scormHelper.commitSuspendData();
										_scorm.doLMSCommit();
								
						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> setUnitStatus()");}
					}
					
			/************************************************************************************************************************************
			**
			** Function: lmsHelper.getUnitTestScores();
			** Description: Sets the unit status's within the flash container, via directly accessing them via the _global property
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/
				
					function lmsHelper_getUnitTestScores(){
						try {
								
								//Gets the Suspend Data from LMS
									_scormHelper.retrieveSuspendData();
								
								//Gets the number of units
									var unitCount = _scormHelper.getSuspendDataElement("unitNumber");

								//Creates a temporary array Variable to hold the unit statuses
									var unitTestScoresArray = [];
								
								//Gets the status from the LMS Suspend Data
									for(var count=0; count < unitCount; count++){
										__unitNumber = parseInt(count) + 1;
										unitTestScoresArray.push(_scormHelper.getSuspendDataElement("ut" + __unitNumber));
									}
									
								//Converts the Unit Status Array into a String Array
									unitTestScoresArrayStr = unitTestScoresArray.join("|");
									// // alert(unitTestScoresArrayStr);
									
								//Sends the data to the flash Container	
									window.document.flashContainer.SetVariable("_level0.container.aicc.cmiUnitTestScores", unitTestScoresArrayStr);
									
						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> getUnitTestScores()");}
					}					

		/************************************************************************************************************************************
			**
			** Function: lmsHelper.setUnitTestScores();
			** Description: Get's the unit status's within the flash container, via directly accessing them via the _global property
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/
			
					
					function lmsHelper_setUnitQuizScores(__unitTestScoresArray){
						// // alert("setUnitTestScores");
						// // alert(__unitTestScoresArray);
						try {
									
									//Gets the Suspend Data from LMS
										_scormHelper.retrieveSuspendData();
									
									//Convert the unit statuses argument from a string array into a JavaScript Array
										var unitTestScoresArrayStr = new String(__unitTestScoresArray);
										var unitTestScoresArray = unitTestScoresArrayStr.split("|");
										
									//Save Unit Statuses to the LMS
										for(var count in unitTestScoresArray){	
											
											__unitNumber = parseInt(count) + 1;
											__status = unitTestScoresArray[count].toLowerCase(); 
											// // alert("for in count");
											// // alert(__status);
											_scormHelper.setSuspendDataElement("uq" + __unitNumber, __status);
										}
	
									//Saves Data to LMS
										_scormHelper.commitSuspendData();
										_scorm.doLMSCommit();
								
						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> setUnitStatus()");}
					}
					
			/************************************************************************************************************************************
			**
			** Function: lmsHelper.getUnitTestScores();
			** Description: Sets the unit status's within the flash container, via directly accessing them via the _global property
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/
					
					function lmsHelper_getUnitQuizScores(){
						// // alert("getUnitQuizScores");
						try {
								
								//Gets the Suspend Data from LMS
									_scormHelper.retrieveSuspendData();
								
								//Gets the number of units
									var unitCount = _scormHelper.getSuspendDataElement("unitNumber");

								//Creates a temporary array Variable to hold the unit statuses
									var unitTestScoresArray = [];
								
								//Gets the status from the LMS Suspend Data
									for(var count=0; count < unitCount; count++){
										__unitNumber = parseInt(count) + 1;
										unitTestScoresArray.push(_scormHelper.getSuspendDataElement("uq" + __unitNumber));
									}
									
								//Converts the Unit Status Array into a String Array
									unitTestScoresArrayStr = unitTestScoresArray.join("|");
									
								//Sends the data to the flash Container	
									window.document.flashContainer.SetVariable("_level0.container.aicc.cmiUnitQuizScores", unitTestScoresArrayStr);
									
						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> getUnitTestScores()");}
					}					
					
			/************************************************************************************************************************************
			**
			** Function: lmsHelper.getBookmarkPosition();
			** Description: Gets the last slide Bookmarked and set it directly within the flash container
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/
			
					function lmsHelper_getBookmarkPosition(){
						try {

								// Getting the location for the lesson from the LMS.
									
									// alert("1")
									
									var lessonLocation = String(_scorm.doLMSGetValue( "cmi.core.lesson_location"));
									
									// lessonLocation = "Mobile device (notebooks, BlackBerry, etc.)";
									
									/*
									if(lessonLocation == undefined)
									{
										lessonLocation = "Mobile device (notebooks, BlackBerry, etc.)";
										// lessonLocation = "Multiple desktop monitors@Mobile device (notebooks, BlackBerry, etc.)";
									}
									*/
									
									
									// String manipulation to format correctly for the course
									
									var a = lessonLocation.split("|")
									
									var b = a[0].split("=")
									
									var c = b[1]
									
									var d = replace(c, "@", "|")
									
									// alert("2" + d)
									
									thisMovie("container").returnLessonConfig( d )
									
									// alert("lmsHelper_getBookmarkPosition.lessonLocation: " + lessonLocation)
									
									//Call's the relavent SCORM Connector Variable in the Flash Container
									//window.document.flashContainer.SetVariable("_level0.container.aicc.cmiLessonLocation",lessonLocation);
							
						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> getBookmarkPosition()");}
					}
			
					function replace(original, search, replace)
					{	
						// alert("original : " + original)
						
						if(original == "" || original == undefined) return "";
						
						if(original.indexOf(search) > 0)
						{
							var newText = original.split(search).join(replace);
							
						} else 
						{
							var newText = original;
						}
						
						return newText;
					}
			
			/************************************************************************************************************************************
			**
			** Function: lmsHelper.getBookmarkPosition();
			** Description: Sets the unit status's within the flash container, via directly accessing them via the _global property
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/
			

					function lmsHelper_setBookmarkPosition( val ) {
						try {	
									//Gets the Suspend Data from LMS
									_scormHelper.retrieveSuspendData();
										
									// bookmarks the students position within the course.
									_scormHelper.setSuspendDataElement("bookmark", val);
									
									//Save data to the LMS
									_scormHelper.commitSuspendData();
									_scorm.doLMSCommit();
									
									// alert("lmsHelper_setBookmarkPosition : " + val)
									

						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> setBookmarkPosition()");}
					}
					
					
				
			/************************************************************************************************************************************
			**
			** Function: lmsHelper.setConfig();
			** Description: Sets the the learner config for the assessment
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/
			
			
					function lmsHelper_setConfig(__location){
						try {
								// bookmarks the students position within the course.
								var currentStatus = _scormHelper.getStatus();
								
								if(currentStatus.toLowerCase() != "completed")
								{
									_scormHelper.setStatus("incomplete")
								}
								
								_scorm.doLMSSetValue( "cmi.core.lesson_location", __location);
								_scorm.doLMSCommit();
								
								// alert("lmsHelper.setConfig == " + currentStatus + " Config == " + __location)
								
								// alert("lmsHelper_setBookmarkPosition : " + val)
									
						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> setBookmarkPosition()");}
					}
					
					
					
					
			/************************************************************************************************************************************
			**
			** Function: lmsHelper.setLessonStatus();
			** Description: Sets the lesson status on the LMS
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/
			

					function lmsHelper_setLessonStatus(__status){
						// alert("LMS SET LESSON STATUS CALLED");
						try {
									_scormHelper.setStatus(__status);
									_scorm.doLMSCommit();

						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> setLessonStatus()");}
					}
					
					
					function lmsHelper_setFinalLessonStatus(__status){
						// alert("LMS SET FINAL LESSON STATUS CALLED");
						try {
								
									_scormHelper.setStatus("completed");
									_scorm.doLMSCommit();

						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> setLessonStatus()");}
					}
			
			
			
			/************************************************************************************************************************************
			**
			** Function: lmsHelper.setCourseStatus();
			** Description: Sets the status of course and also the overall score for the course
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/					
					
					function lmsHelper_setCourseStatus(_arguments){
						try{
									
									//Set local variables
										_courseStatus = _arguments.split(",")[1];
										_courseScore = _arguments.split(",")[0];
									
									//Sets lesson status to either passed or failed
										_scorm.doLMSSetValue( "cmi.core.lesson_status", _courseStatus);
									
									//Resets the user's last bookmarked postion	so the user will return to the coursemap	
									//	_scorm.doLMSSetValue( "cmi.core.lesson_location", "undefined");

									//Sets the Raw Score on the LMS
										_scorm.doLMSSetValue( "cmi.core.score.raw", _courseScore);
										
									//Save data to the LMS
										_scorm.doLMSCommit();
							
						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> setCourseStatus()" );}
					}
			
			

			/************************************************************************************************************************************
			**
			** Function: lmsHelper.resetModule();
			** Description: Rest's the Module Back to orginal state as if a user has never used this course before
			** Return: This function does not return anything.
			**
			*************************************************************************************************************************************/					

					function lmsHelper_resetModule(){
						try {

									//Gets the Suspend Data from LMS
										_scormHelper.retrieveSuspendData();

									//resets module status to "incomplete"
										_scorm.doLMSSetValue( "cmi.core.lesson_status", "incomplete");
									
									//Resets the user's last bookmarked postion	so the user will return to the coursemap	
										//_scorm.doLMSSetValue( "cmi.core.lesson_location", "undefined");

									//resets the Raw Score on the LMS
										_scorm.doLMSSetValue( "cmi.core.score.raw", 0);
										
									//resets the first unit status to "Available"
										_scormHelper.setSuspendDataElement("u1", 1);
										
									//resets all the rest of the unit statuses to "Unavailable"
										var unitCount = _scormHelper.getSuspendDataElement("unitNumber");
										for(var count=1; count < unitCount; count++){
											__unitNumber = parseInt(count) + 1;
											_scormHelper.setSuspendDataElement("u" + __unitNumber, 0);
										}
											
									//Save data to the LMS
										_scormHelper.commitSuspendData();
										_scorm.doLMSCommit();
									
								
						}catch(e){errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> resetModule()");}
					}
					
					
					
				/*
					cmi.interactions.0.type" ??? "choice", "fill-in", "matching", "performance", "sequencing"
				*/
				
				function lmsHelper_setInteractionObject( response ) 
				{
					try 
					{						
						var questionId = response[0];
						var questionResponse = response[1];
						var questionType = "performance"; //response[2];
						var questionWeighting = response[3];
						// var questionScore = "0"// response[4];
						var questionsResult = response[5];
						var uniqueId = response[6];
						
						var sep = " : ";
						
						// alert("set: " + questionId + sep + questionResponse + sep + questionWeighting + sep + questionsResult)
						
						// Set the question ID
						var result_id = _scorm.doLMSSetValue( "cmi.interactions." + questionId + ".id", uniqueId);
						
						// Set the questions type
						var result_type = _scorm.doLMSSetValue( "cmi.interactions." + questionId + ".type", questionType);
						
						// Set the question weighting
						var result_student_response = _scorm.doLMSSetValue( "cmi.interactions." + questionId + ".student_response", questionResponse);
						
						// Set the question weighting
						var result_weighting = _scorm.doLMSSetValue( "cmi.interactions." + questionId + ".weighting", questionWeighting);
						
						// Set the question result
						var result_result = _scorm.doLMSSetValue( "cmi.interactions." + questionId + ".result", questionsResult);
						
					} catch(e) 
					{
						errorReporter(e, errorLocation, "<b>file:</b> lmsHelper.js - <b>function:</b> setInteractionObject()")
					}
					
				}
					

