[inclScorm1.2] //JMMIX-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 DRAG-DROP OUTPUT FORMAT CODE var Punctuation = '[strPunctuation]'; var Openers = '[strOpenPunctuation]'; var CorrectResponse = '[strGuessCorrect]'; var IncorrectResponse = '[strGuessIncorrect]'; var ThisMuchCorrect = '[strThisMuch]'; var TheseAnswersToo = '[strTheseAnswersToo]'; var YourScoreIs = '[strYourScoreIs]'; var NextCorrect = '[strNextCorrect]'; var FeedbackWidth = 200; //default var ExBGColor = '[strExBGColor]'; var PageBGColor = '[strPageBGColor]'; var TextColor = '[strTextColor]'; var TitleColor = '[strTitleColor]'; var DropTotal = 3; // number of lines that will be available for dropping on var Gap = 4; //Gap between two segments when they're next to each other on a line var DropHeight = 30; var CapitalizeFirst = [boolCapitalizeFirst]; var CompiledOutput = ''; var TempSegment = ''; var FirstSegment = -1; var FirstDiv = -1; var Penalties = 0; var Score = 0; var TimeOver = false; var CurrDrag = -1; var topZ = 100; var Cds = new Array(); var L = new Array(); var Finished = false; var Locked = false; var DivWidth = 600; var LeftColPos = 100; var DragTop = 120; var DragNumber = -1; var AnswersTried = ''; Lines = new Array(); function CapFirst(InString){ var i = 0; if ((Openers.indexOf(InString.charAt(i))>-1)||(InString.charAt(i) == ' ')){ i++; } if ((Openers.indexOf(InString.charAt(i))>-1)||(InString.charAt(i) == ' ')){ i++; } var Temp = InString.charAt(i); Temp = Temp.toUpperCase(); InString = InString.substring(0, i) + Temp + InString.substring(i+1, InString.length); return InString; } function CheckResults(ChkType){ //Get sequence student has chosen GetGuessSequence(); //Compile the answer CompiledOutput = CompileString(GuessSequence); //Check the answer CheckAnswer(ChkType); } function GetGuessSequence(){ //Put pointers to draggables in arrays based on the lines they're sitting on var Drops = new Array(); for (var i=0; i -4)){ Drops[j][Drops[j].length] = Cds[i]; } } } //Sort the drop arrays based on the Left of each div for (i=0; i 0){ NewFirstDiv = Drops[i][0].index; break; } } return NewFirstDiv; } function CompDrags(a,b){ return a.GetL() - b.GetL(); } function FindSegment(SegID){ var Seg = ''; for (var 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){ OutString = CapFirst(OutString); } return OutString; } function CheckAnswer(CheckType){ if (Locked == true){return;} if (GuessSequence.length < 1){ if (CheckType == 1){ Penalties++; ShowMessage(NextCorrect + '

' + FindSegment(Answers[0][0])); } 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

' + CorrectResponse + '
'; if (AnswersTried.length > 0){AnswersTried += ' | ';} AnswersTried += CompiledOutput; //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] ShowMessage(WellDone); WriteToInstructions(YourScoreIs + ' ' + Score + '%.'); } else{ var WrongGuess = CompileString(GuessSequence); if (AnswersTried.length > 0){AnswersTried += ' | ';} AnswersTried += WrongGuess; TryAgain = '' + WrongGuess + '

'; if ((CheckType == 0)||(LongestCorrect.length==0)){ TryAgain += IncorrectResponse + '
'; } if (LongestCorrect.length > 0){ LongestCorrectBit = CompileString(LongestCorrect); GuessSequence.length = LongestCorrect.length; TryAgain += '
' + ThisMuchCorrect + '
' + LongestCorrectBit + '
'; } if (CheckType == 1){ TryAgain += '
' + NextCorrect + '
' + FindSegment(HintToReturn); } [inclTimer] if (TimeOver == true){ Score = Math.floor(((LongestCorrect.length-Penalties) * 100)/Segments.length); if (Score < 0){Score = 0;} TryAgain += YourScoreIs + ' ' + Score + '%.
'; } [/inclTimer] Penalties++; //Penalty for inaccurate check ShowMessage(TryAgain); } //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] } var Segments = new Array(); [SegmentArray] var GuessSequence = new Array(); var Answers = new Array(); [AnswerArray] function doDrag(e) { if (CurrDrag == -1) {return}; if (C.ie){var Ev = window.event}else{var Ev = e} var difX = Ev.clientX-window.lastX; var difY = Ev.clientY-window.lastY; var newX = Cds[CurrDrag].GetL()+difX; var newY = Cds[CurrDrag].GetT()+difY; Cds[CurrDrag].SetL(newX); Cds[CurrDrag].SetT(newY); window.lastX = Ev.clientX; window.lastY = Ev.clientY; return false; } function beginDrag(e, DragNum) { CurrDrag = DragNum; if (C.ie){ var Ev = window.event; document.onmousemove=doDrag; document.onmouseup=endDrag; } else{ var Ev = e; window.onmousemove=doDrag; window.onmouseup=endDrag; } Cds[CurrDrag].SwapColours(); topZ++; Cds[CurrDrag].css.zIndex = topZ; window.lastX=Ev.clientX; window.lastY=Ev.clientY; return true; } function endDrag(e) { if (CurrDrag == -1) {return}; Cds[CurrDrag].SwapColours(); if (C.ie){document.onmousemove=null}else{window.onmousemove=null;} onEndDrag(); CurrDrag = -1; return true; } function onEndDrag(){ //Snap to lines var i = 0; var SnapLine = Cds[CurrDrag].GetT(); var BiggestOverlap = -1; var OverlapRect = 0; for (i=0; i OverlapRect){ OverlapRect = Cds[CurrDrag].Overlap(L[i]); BiggestOverlap = i; } } if (BiggestOverlap > -1){ SnapLine = L[BiggestOverlap].GetB() - (Cds[CurrDrag].GetH() + 2); Cds[CurrDrag].SetT(SnapLine); CheckOver(-1); } if (CapitalizeFirst==true){ setTimeout('DoCapitalization()', 50); } } //Following function modified for 6.2.5.2; avoids image dragging bug. function DoCapitalization(){ //Capitalize first segment if necessary var FD = GetGuessSequence(); if ((FD == -1)&&(FirstDiv > -1)){ Cds[FirstDiv].SetHTML(Segments[FirstDiv][0]); } if (((FD != FirstDiv)&&(CapitalizeFirst == true))&&(FD > -1)){ if (FirstDiv > -1){ Cds[FirstDiv].SetHTML(Segments[FirstDiv][0]); } } if ((FD > -1)&&(CapitalizeFirst == true)){ var Temp = CapFirst(Segments[FD][0]); Cds[FD].SetHTML(Temp); FirstDiv = FD; } } function CheckOver(NoMove){ //This recursive function spreads out the Cards on a line if two of them are overlapping; //if the spread operation moves one beyond the end of a line, it wraps it to the next line. for (var i=0; i 0){ if ((i==NoMove)||(Cds[i].GetL() < Cds[j].GetL())){ Cds[j].DockToR(Cds[i]); if (Cds[j].GetR() > (LeftColPos + DivWidth)){ Cds[j].SetL(LeftColPos); Cds[j].SetT(Cds[j].GetT() + DropHeight); } CheckOver(j); } else{ Cds[i].DockToR(Cds[j]); if (Cds[i].GetR() > (LeftColPos + DivWidth)){ Cds[i].SetL(LeftColPos); Cds[i].SetT(Cds[i].GetT() + DropHeight); } CheckOver(i); } } } } } } function StartUp(){ [inclSendResults] GetUserName(); [/inclSendResults] [inclScorm1.2] ScormStartUp(); [/inclScorm1.2] [inclPreloadImages] PreloadImages([PreloadImageList]); [/inclPreloadImages] Segments = Shuffle(Segments); //Calculate page dimensions and positions pg = new PageDim(); DivWidth = Math.floor((pg.W*4)/5); LeftColPos = Math.floor(pg.W/10); DragTop = parseInt(document.getElementById('CheckButtonDiv').offsetHeight) + parseInt(document.getElementById('CheckButtonDiv').offsetTop) + 10; var CurrTop = DragTop + 10; //Position the drop divs for (var i=0; i