2 //JCROSS-SPECIFIC SCORM-RELATED JAVASCRIPT CODE
4 function SetScormScore(){
5 //Reports the current score and any other information back to the LMS
7 API.LMSSetValue('cmi.core.score.raw', Score);
9 //Now send a detailed reports on the item
10 var ItemLabel = 'Crossword';
11 API.LMSSetValue('cmi.objectives.0.id', 'obj'+ItemLabel);
12 API.LMSSetValue('cmi.interactions.0.id', 'int'+ItemLabel);
13 if (Finished == true){
14 API.LMSSetValue('cmi.objectives.0.status', 'completed');
17 API.LMSSetValue('cmi.objectives.0.status', 'incomplete');
19 API.LMSSetValue('cmi.objectives.0.score.min', '0');
20 API.LMSSetValue('cmi.objectives.0.score.max', '100');
21 API.LMSSetValue('cmi.objectives.0.score.raw', Score);
22 //We're not sending any student response data, so we can set this to a non-standard value
23 API.LMSSetValue('cmi.interactions.0.type', 'crossword');
30 //JCROSS CORE JAVASCRIPT CODE
33 var CurrentBox = null;
35 var AcrossCaption = '';
37 var Correct = '[strCorrect]';
38 var Incorrect = '[strIncorrect]';
39 var GiveHint = '[strGiveHint]';
40 var YourScoreIs = '[strYourScoreIs]';
42 var BuiltExercise = '';
45 var InTextBox = false;
48 var CaseSensitive = [boolCaseSensitive];
50 var InputStuff = '<form method="post" action="" onsubmit="return false;"><span class="ClueNum">[strClueNum]: </span>';
51 InputStuff += '[strClue] <input onfocus="CurrentBox=this;InTextBox=true;" onblur="InTextBox=false;" id="[strBoxId]" type="edit" size="[strEditSize]" maxlength="[strMaxLength]"></input>';
52 InputStuff += '<button class="FuncButton" onfocus="FuncBtnOver(this)" onblur="FuncBtnOut(this)" onmouseover="FuncBtnOver(this)" onmouseout="FuncBtnOut(this)" onmousedown="FuncBtnDown(this)" onmouseup="FuncBtnOut(this)" onclick="EnterGuess([strParams])">[strEnterCaption]</button>';
53 InputStuff += '[inclHint]<button class="FuncButton" onfocus="FuncBtnOver(this)" onblur="FuncBtnOut(this)" onmouseover="FuncBtnOver(this)" onmouseout="FuncBtnOut(this)" onmousedown="FuncBtnDown(this)" onmouseup="FuncBtnOut(this)" onclick="ShowHint([strParams])">[strHintCaption]</button>[/inclHint]';
54 InputStuff += '</form>';
56 var CurrBoxElement = null;
60 RemoveBottomNavBarForIE();
61 //Show a keypad if there is one (added bugfix for 6.0.4.12)
62 if (document.getElementById('CharacterKeypad') != null){
63 document.getElementById('CharacterKeypad').style.display = 'block';
69 AcrossCaption = document.getElementById('CluesAcrossLabel').innerHTML;
70 DownCaption = document.getElementById('CluesDownLabel').innerHTML;
76 PreloadImages([PreloadImageList]);
85 function GetAnswerLength(Across,x,y){
88 while ((x<L.length)&&(L[x][y].length > 0)){
89 Result += L[x][y].length;
95 while ((y<L[x].length)&&(L[x][y].length > 0)){
96 Result += L[x][y].length;
103 function GetEditSize(Across,x,y){
104 var Len = GetAnswerLength(Across,x,y);
105 if (IsCJK(L[x][y].charCodeAt(0))){
111 function ShowClue(ClueNum,x,y){
115 var Clue = document.getElementById('Clue_A_' + ClueNum);
117 Temp = InputStuff.replace(/\[ClueNum\]/g, ClueNum);
118 Temp = Temp.replace(/\[strClueNum\]/g, AcrossCaption + ' ' + ClueNum);
119 strParams = 'true,' + ClueNum + ',' + x + ',' + y + ',\'[strBoxId]\'';
120 Temp = Temp.replace(/\[strParams\]/g, strParams);
121 Temp = Temp.replace(/\[strBoxId\]/g, 'GA_' + ClueNum + '_' + x + '_' + y);
122 Temp = Temp.replace(/\[strEditSize\]/g, GetEditSize(true,x,y));
123 Temp = Temp.replace(/\[strMaxLength\]/g, GetAnswerLength(true,x,y));
124 Temp = Temp.replace(/\[strClue\]/g, Clue.innerHTML, Temp);
127 Clue = document.getElementById('Clue_D_' + ClueNum);
129 Temp = InputStuff.replace(/\[ClueNum\]/g, ClueNum);
130 Temp = Temp.replace(/\[strClueNum\]/g, DownCaption + ' ' + ClueNum);
131 strParams = 'false,' + ClueNum + ',' + x + ',' + y + ',\'[strBoxId]\'';
132 Temp = Temp.replace(/\[strParams\]/g, strParams);
133 Temp = Temp.replace(/\[strBoxId\]/g, 'GD_' + ClueNum + '_' + x + '_' + y);
134 Temp = Temp.replace(/\[strEditSize\]/g, GetAnswerLength(false,x,y));
135 Temp = Temp.replace(/\[strClue\]/g, Clue.innerHTML, Temp);
138 document.getElementById('ClueEntry').innerHTML = Result;
141 function EnterGuess(Across,ClueNum,x,y,BoxId){
142 if (document.getElementById(BoxId) != null){
143 var Guess = document.getElementById(BoxId).value;
144 var AnsLength = GetAnswerLength(Across,x,y);
145 EnterAnswer(Guess,Across,AnsLength,x,y);
149 function SplitStringToPerceivedChars(InString, PC){
150 var Temp = InString.charAt(0);
151 if (InString.length > 1){
152 for (var i=1; i<InString.length; i++){
153 if (IsCombiningDiacritic(InString.charCodeAt(i)) == true){
154 Temp += InString.charAt(i);
158 Temp = InString.charAt(i);
165 function EnterAnswer(Guess,Across,AnsLength,x,y){
166 var PC = new Array();
167 SplitStringToPerceivedChars(Guess, PC);
172 while (Letter < AnsLength){
173 if (Letter < PC.length){
174 G[i][j] = PC[Letter];
175 if (document.getElementById('L_' + i + '_' + j) != null){
176 document.getElementById('L_' + i + '_' + j).innerHTML = PC[Letter];
189 function SetGridSquareValue(x,y,Val){
190 var GridId = 'L_' + x + '_' + y;
191 if (document.getElementById(GridId) != null){
192 document.getElementById(GridId).innerHTML = Val;
196 function ShowHint(Across,ClueNum,x,y,BoxId){
199 var LetterFromGuess = '';
200 var LetterFromKey = '';
203 while (j<L[i].length){
205 OutString += L[i][j];
206 if (CaseSensitive == true){
207 LetterFromKey = L[i][j];
208 LetterFromGuess = G[i][j];
211 LetterFromKey = L[i][j].toUpperCase();
212 LetterFromGuess = G[i][j].toUpperCase();
214 if (LetterFromGuess != LetterFromKey){
215 // if (G[i][j] != L[i][j]){
230 OutString += L[i][j];
231 if (CaseSensitive == true){
232 LetterFromKey = L[i][j];
233 LetterFromGuess = G[i][j];
236 LetterFromKey = L[i][j].toUpperCase();
237 LetterFromGuess = G[i][j].toUpperCase();
239 if (LetterFromGuess != LetterFromKey){
240 // if (G[i][j] != L[i][j]){
252 if (document.getElementById(BoxId) != null){
253 document.getElementById(BoxId).value = OutString;
266 function CheckAnswers(){
267 if (Locked == true){return;}
269 var AllCorrect = true;
271 var CorrectLetters = 0;
272 var LetterFromKey = '';
273 var LetterFromGuess = '';
276 for (var i=0; i<L.length; i++){
277 for (var j=0; j<L[i].length; j++){
280 if (CaseSensitive == true) {
281 LetterFromKey = L[i][j];
282 LetterFromGuess = G[i][j];
285 LetterFromKey = L[i][j].toUpperCase();
286 LetterFromGuess = G[i][j].toUpperCase();
288 if (LetterFromGuess != LetterFromKey){
290 //Blank that square in the grid
291 SetGridSquareValue(i,j,'');
301 Score = Math.floor(((CorrectLetters-Penalties) * 100)/TotLetters);
302 if (Score < 0){Score = 0;}
307 if (AllCorrect == true){
308 Output = Correct + '<br />';
311 Output += YourScoreIs + ' ' + Score + '%.<br />';
312 if (AllCorrect == false){
318 WriteToInstructions(Output);
320 if ((AllCorrect == true)||(TimeOver == true)){
322 setTimeout('SendResults(' + Score + ')', 50);
325 window.clearInterval(Interval);
330 setTimeout('Finish()', SubmissionTimeout);
333 if (AllCorrect == true){
337 SetScormIncomplete();
343 //If there's a form, fill it out and submit it
344 if (document.store != null){
345 Frm = document.store;
346 Frm.starttime.value = HPNStartTime;
347 Frm.endtime.value = (new Date()).getTime();
348 Frm.mark.value = Score;
353 function TypeChars(Chars){
354 if (CurrentBox != null){
355 CurrentBox.value += Chars;
361 document.getElementById('Timer').innerHTML = '[strTimesUp]';