[inclScorm1.2]
//JMIX-SPECIFIC SCORM-RELATED JAVASCRIPT CODE
function SetScormScore(){
//Reports the current score and any other information back to the LMS
if (API != null){
API.LMSSetValue('cmi.core.score.raw', Score);
//Now send a detailed reports on the item
var ItemLabel = 'Item_1';
API.LMSSetValue('cmi.objectives.0.id', 'obj'+ItemLabel);
API.LMSSetValue('cmi.interactions.0.id', 'int'+ItemLabel);
if (Finished == true){
API.LMSSetValue('cmi.objectives.0.status', 'completed');
}
else{
API.LMSSetValue('cmi.objectives.0.status', 'incomplete');
}
API.LMSSetValue('cmi.objectives.0.score.min', '0');
API.LMSSetValue('cmi.objectives.0.score.max', '100');
API.LMSSetValue('cmi.objectives.0.score.raw', Score);
//We can only use the performance type, because we're storing multiple responses of various types.
API.LMSSetValue('cmi.interactions.0.type', 'performance');
API.LMSSetValue('cmi.interactions.0.student_response', AnswersTried);
API.LMSCommit('');
}
}
[/inclScorm1.2]
//JMIX STANDARD OUTPUT FORMAT CODE
var CorrectResponse = '[strGuessCorrect]';
var IncorrectResponse = '[strGuessIncorrect]';
var TheseAnswersToo = '[strTheseAnswersToo]';
var ThisMuchCorrect = '[strThisMuch]';
var NextCorrect = '[strNextCorrect]';
var YourScoreIs = '[strYourScoreIs]';
var CapitalizeFirst = [boolCapitalizeFirst];
var Penalties = 0;
var Finished = false;
var TimeOver = false;
var Score = 0;
var strInstructions = '';
var AnswersTried = '';
var SegmentTemplate = ' [CurrentSegment] ';
var Exercise = '';
var Punctuation = '[strPunctuation]';
var Openers = '[strOpenPunctuation]';
var Guesses = new Array();
var Remaining = new Array();
var CorrectParts = new Array();
var ClosestMatch = 0;
var LowerString='';
var UpperString='';
var Output = '';
var Segments = new Array();
[SegmentArray]
var GuessSequence = new Array();
var Answers = new Array();
[AnswerArray]
function WriteToGuess(Feedback) {
document.getElementById('GuessDiv').innerHTML = Feedback;
[inclPreloadImages]
RefreshImages();
[/inclPreloadImages]
}
function Undo(){
if (GuessSequence.length < 1){
return;
}
GuessSequence.length = GuessSequence.length - 1;
BuildCurrGuess();
BuildExercise();
DisplayExercise(Exercise);
//Following line modified for 6.0.4.44 -- "remaining words" message removed, no longer needed
WriteToGuess('' + Output + '');
}
function AddSegment(SegNum){
[inclTimer]
if (TimeOver == true){return;}
[/inclTimer]
GuessSequence[GuessSequence.length] = SegNum;
BuildCurrGuess();
WriteToGuess('' + Output + '');
BuildExercise();
DisplayExercise(Exercise);
}
function BuildCurrGuess(){
var i = 0;
var j = 0;
var NewSeg = '';
//first, create arrays of all the segments guessed so far and those not yet used
GuessSegs = new Array();
GuessSegs.length = 0;
//set the "used" markers all to 0
for (i=0; i 0){
OutString = OutArray[0];
}
else{
OutString = '';
}
var Spacer = '';
for (i=1; i -1)||(Punctuation.indexOf(OutArray[i].charAt(0)) > -1)){
Spacer = '';
}
OutString = OutString + Spacer + OutArray[i];
}
//Capitalize the first letter if necessary
if (CapitalizeFirst == true){
i = 0;
if ((Openers.indexOf(OutString.charAt(i))>-1)||(OutString.charAt(i) == ' ')){
i++;
}
if ((Openers.indexOf(OutString.charAt(i))>-1)||(OutString.charAt(i) == ' ')){
i++;
}
var Temp = OutString.charAt(i);
Temp = Temp.toUpperCase();
OutString = OutString.substring(0, i) + Temp + OutString.substring(i+1, OutString.length);
}
return OutString;
}
function CheckAnswer(CheckType){
if (GuessSequence.length < 1){
if (CheckType == 1){
ShowMessage(NextCorrect + '
' + FindSegment(Answers[0][0]) + '');
Penalties++;
}
return;
}
var i = 0;
var j = 0;
var k = 0;
var WellDone = '';
var WhichCorrect = -1;
var TryAgain = '';
var LongestCorrectBit = '';
TempCorrect = new Array();
LongestCorrect = new Array();
var TempHint = '';
var HintToReturn = 1;
var OtherAnswers = '';
var AllDone = false;
for (i=0; i LongestCorrect.length){
LongestCorrect.length = 0;
for (k=0; k -1){
AllDone = true;
for (i=0; i' + CompileString(Answers[i]);
}
}
WellDone = '' + Output + '
' + CorrectResponse + '
';
if (AnswersTried.length > 0){AnswersTried += ' | ';}
AnswersTried += Output;
//Do score calculation here
Score = Math.floor(((Segments.length-Penalties) * 100)/Segments.length);
WellDone += YourScoreIs + ' ' + Score + '%.
';
[inclAlsoCorrect]
if (OtherAnswers.length > 0){
WellDone += TheseAnswersToo + '' + OtherAnswers + '';
}
[/inclAlsoCorrect]
WriteToGuess(WellDone);
ShowMessage(WellDone);
}
else{
var WrongGuess = CompileString(GuessSequence);
if (AnswersTried.length > 0){AnswersTried += ' | ';}
AnswersTried += WrongGuess;
TryAgain = '' + WrongGuess + '
';
if (CheckType == 0){
TryAgain += IncorrectResponse + '
';
}
if (LongestCorrect.length > 0){
LongestCorrectBit = CompileString(LongestCorrect);
GuessSequence.length = LongestCorrect.length;
TryAgain += ThisMuchCorrect + '
' + LongestCorrectBit + '
';
//These lines added for 6.0.3.44
WriteToGuess('' + LongestCorrectBit + '');
}
else{
GuessSequence.length = 0;
WriteToGuess('');
}
if (CheckType == 1){
TryAgain += NextCorrect + '
' + FindSegment(HintToReturn) + '';
}
BuildCurrGuess();
BuildExercise();
DisplayExercise(Exercise);
ShowMessage(TryAgain);
Penalties++; //Penalty for inaccurate check
[inclTimer]
if (TimeOver == true){
Score = Math.floor(((LongestCorrect.length-Penalties) * 100)/Segments.length);
if (Score < 0){Score = 0;}
ShowMessage(YourScoreIs + ' ' + Score + '%.
');
}
[/inclTimer]
}
//If the exercise is over, deal with that
if ((AllDone == true)||(TimeOver == true)){
[inclSendResults]
setTimeout('SendResults(' + Score + ')', 50);
[/inclSendResults]
[inclTimer]
window.clearInterval(Interval);
[/inclTimer]
TimeOver = true;
Locked = true;
Finished = true;
setTimeout('Finish()', SubmissionTimeout);
WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
}
[inclScorm1.2]
if (AllDone == true){
SetScormComplete();
}
else{
SetScormIncomplete();
}
[/inclScorm1.2]
}
function FindSegment(SegID){
var Seg = '';
for (var i=0; i