3 //JMATCH-SPECIFIC SCORM-RELATED JAVASCRIPT CODE
5 function SetScormScore(){
6 //Reports the current score and any other information back to the LMS
8 API.LMSSetValue('cmi.core.score.raw', Score);
11 //Now send a detailed reports on the item
12 var ItemLabel = 'Matching';
13 API.LMSSetValue('cmi.objectives.0.id', 'obj'+ItemLabel);
14 API.LMSSetValue('cmi.interactions.0.id', 'int'+ItemLabel);
15 API.LMSSetValue('cmi.objectives.0.status', API.LMSGetValue('cmi.core.lesson_status'));
16 API.LMSSetValue('cmi.objectives.0.score.min', '0');
17 API.LMSSetValue('cmi.objectives.0.score.max', '100');
18 API.LMSSetValue('cmi.objectives.0.score.raw', Score);
19 //We can only use the performance type, because we're storing multiple responses of various types.
20 API.LMSSetValue('cmi.interactions.0.type', 'performance');
21 API.LMSSetValue('cmi.interactions.0.student_response', AnswersTried);
28 //JMATCH-SPECIFIC CORE JAVASCRIPT CODE
30 var CorrectResponse = '[strGuessCorrect]';
31 var IncorrectResponse = '[strGuessIncorrect]';
32 var YourScoreIs = '[strYourScoreIs]';
33 var DivWidth = 600; //default value
34 var FeedbackWidth = 200; //default
35 var ExBGColor = '[strExBGColor]';
36 var PageBGColor = '[strPageBGColor]';
37 var TextColor = '[strTextColor]';
38 var TitleColor = '[strTitleColor]';
43 var ShuffleQs = [boolShuffleQs];
44 var QsToShow = [QsToShow];
48 var RightColPos = 500;
51 var AnswersTried = '';
53 //Fixed and draggable card arrays
58 //Is it dropped on any of the fixed cards?
60 var DropTarget = DroppedOnFixed(CurrDrag);
62 //If so, send home any card that is currently docked there
63 for (var i=0; i<DC.length; i++){
64 if (DC[i].tag == DropTarget+1){
70 //Dock the dropped card
71 DC[CurrDrag].DockToR(FC[DropTarget]);
72 D[CurrDrag][2] = F[DropTarget][1];
73 DC[CurrDrag].tag = DropTarget+1;
78 DC[CurrDrag].GoHome();
84 function DroppedOnFixed(DNum){
88 for (var i=0; i<FC.length; i++){
89 Temp = DC[DNum].Overlap(FC[i]);
90 if (Temp > OverlapArea){
110 PreloadImages([PreloadImageList]);
113 //Calculate page dimensions and positions
115 DivWidth = Math.floor((pg.W*4)/5);
116 DragWidth = Math.floor((DivWidth*3)/10);
117 LeftColPos = Math.floor(pg.W/15);
118 RightColPos = pg.W - (DragWidth + LeftColPos);
119 DragTop = parseInt(document.getElementById('CheckButtonDiv').offsetHeight) + parseInt(document.getElementById('CheckButtonDiv').offsetTop) + 10;
125 //Reduce array if required
126 if (QsToShow < F.length){
130 //Shuffle the left items if required
131 if (ShuffleQs == true){
135 //Shuffle the items on the right
138 var CurrTop = DragTop;
142 var CardContent = '';
143 for (var i=0; i<F.length; i++){
144 CardContent = F[i][0];
145 FC[i] = new Card('F' + i, 10);
146 FC[i].elm.innerHTML = CardContent;
147 if (FC[i].GetW() > Widest){
148 Widest = FC[i].GetW();
152 if (Widest > DragWidth){Widest = DragWidth;}
156 DragWidth = Math.floor((DivWidth-Widest)/2) - 24;
157 RightColPos = DivWidth + LeftColPos - (DragWidth + 14);
161 for (i=0; i<D.length; i++){
162 DC[i] = new Card('D' + i, 10);
163 CardContent = D[i][0];
164 // if (CardContent.indexOf('<img ') > -1){CardContent += '<br clear="all" />';} //used to be required for Navigator rendering bug with images
165 DC[i].elm.innerHTML = CardContent;
166 if (DC[i].GetW() > DragWidth){DC[i].SetW(DragWidth);}
167 DC[i].css.cursor = 'move';
168 DC[i].css.backgroundColor = '[strExBGColor]';
169 DC[i].css.color = '[strTextColor]';
170 TempInt = DC[i].GetH();
171 if (TempInt > Highest){Highest = TempInt;}
172 TempInt = DC[i].GetW();
173 if (TempInt > WidestRight){WidestRight = TempInt;}
176 //Fix for 6.2: the reduction by 12 seems to be required -- no idea why!
177 var HeightToSet = Highest-12;
178 var WidthToSet = WidestRight-12;
180 for (i=0; i<D.length; i++){
182 DC[i].SetL(RightColPos);
183 if (DC[i].GetH() < Highest){
184 DC[i].SetH(HeightToSet);
186 if (DC[i].GetW() < WidestRight){
187 DC[i].SetW(WidthToSet);
191 CurrTop = CurrTop + DC[i].GetH() + 5;
196 for (var i=0; i<F.length; i++){
198 if (FC[i].GetH() < Highest){
199 FC[i].SetH(HeightToSet);
202 FC[i].SetL(LeftColPos);
204 TempInt = FC[i].GetH();
205 CurrTop = CurrTop + TempInt + 5;
209 //Slide any elements that should be in position over
210 for (i=0; i<D.length; i++){
215 //Find the right target element
217 for (var j=0; j<F.length; j++){
218 if (F[j][1] == D[i][1]){
222 var TargetLeft = FC[TargItem].GetR() + 5;
223 var TargetTop = FC[TargItem].GetT();
225 if (TargetTop < DC[i].GetT()){
229 if (TargetTop > DC[i].GetT()){
233 Slide(i, TargetLeft, TargetTop, TopChange);
234 D[i][2] = F[TargItem][1];
235 DC[i].tag = TargItem+1;
245 function Slide(MoverNum, TargL, TargT, TopChange){
246 var TempInt = DC[MoverNum].GetL();
247 if (TempInt > TargL){
248 DC[MoverNum].SetL(TempInt - 5);
250 TempInt = DC[MoverNum].GetT();
251 if (TempInt != TargT){
252 DC[MoverNum].SetT(TempInt + TopChange);
254 if ((DC[MoverNum].GetL() > TargL)||(DC[MoverNum].GetT() != TargT)){
255 setTimeout('Slide('+MoverNum+','+TargL+','+TargT+','+TopChange+')', 1);
258 DC[MoverNum].SetL(TargL);
269 function ReduceItems2(){
272 while (F.length > QsToShow){
273 ItemToDump = Math.floor(F.length*Math.random());
274 for (j=ItemToDump; j<(F.length-1); j++){
277 for (j=ItemToDump; j<(D.length-1); j++){
280 F.length = F.length-1;
281 D.length = D.length-1;
285 function TimerStartUp(){
286 setTimeout('StartUp()', 300);
289 function CheckAnswers(){
290 if (Locked == true){return;}
291 //Set the default score and response
292 var TotalCorrect = 0;
296 //for each fixed, check to see if the tag value for the draggable is the same as the fixed
297 if (AnswersTried.length > 0){AnswersTried += ' | ';}
299 for (i=0; i<D.length; i++){
300 if (i>0){AnswersTried += ',';}
301 AnswersTried += D[i][1] + '.' + D[i][2] + '';
302 if ((D[i][2] == D[i][1])&&(D[i][2] > 0)){
306 //Change made for version 6.0.3.41: don't send wrong items home,
307 //show them in a more conspicuous way.
309 DC[i].SetL(DC[i].GetL() + 10);
314 Score = Math.floor((100*(TotalCorrect-Penalties))/F.length);
318 if (TotalCorrect == F.length) {
322 if (AllDone == true){
323 Feedback = YourScoreIs + ' ' + Score + '%.';
324 ShowMessage(Feedback + '<br />' + CorrectResponse);
327 Feedback = IncorrectResponse + '<br />' + YourScoreIs + ' ' + Score + '%.';
328 ShowMessage(Feedback);
329 Penalties++; // Penalty for inaccurate check
331 //If the exercise is over, deal with that
332 if ((AllDone == true)||(TimeOver == true)){
334 setTimeout('SendResults(' + Score + ')', 50);
337 window.clearInterval(Interval);
342 setTimeout('Finish()', SubmissionTimeout);
343 WriteToInstructions(Feedback);
346 if (AllDone == true){
350 SetScormIncomplete();
357 document.getElementById('Timer').innerHTML = '[strTimesUp]';