From 4b168cfabcffbc8d20b46893042ea8bb165d9b49 Mon Sep 17 00:00:00 2001 From: gbateson Date: Wed, 2 May 2007 23:49:59 +0000 Subject: [PATCH] add HP 6.2 templates; add compatability with Safari (Mac browser); microincrement version to 2006091202 (release 2.2.1) --- mod/hotpot/README.TXT | 2 +- mod/hotpot/hotpot-full.js | 200 ++++++++++++++---- mod/hotpot/template/default.php | 4 +- mod/hotpot/template/v6.php | 5 + mod/hotpot/template/v6/djmatch6.ht_ | 8 +- mod/hotpot/template/v6/djmatch6.js_ | 54 ++++- mod/hotpot/template/v6/djmix6.ht_ | 8 +- mod/hotpot/template/v6/djmix6.js_ | 57 ++++- mod/hotpot/template/v6/fjmatch6.ht_ | 7 +- mod/hotpot/template/v6/fjmatch6.js_ | 24 +++ mod/hotpot/template/v6/hp6.cs_ | 11 +- .../template/v6/hp6checkshortanswer.js_ | 7 +- mod/hotpot/template/v6/hp6objecttags.ht_ | 23 +- mod/hotpot/template/v6/hp6showmessage.js_ | 71 +++++-- mod/hotpot/template/v6/hp6utilities.js_ | 25 ++- mod/hotpot/template/v6/jcloze6.ht_ | 10 +- mod/hotpot/template/v6/jcloze6.js_ | 58 ++++- mod/hotpot/template/v6/jcross6.ht_ | 10 +- mod/hotpot/template/v6/jcross6.js_ | 88 +++++++- mod/hotpot/template/v6/jmatch6.ht_ | 8 +- mod/hotpot/template/v6/jmatch6.js_ | 58 +++++ mod/hotpot/template/v6/jmix6.ht_ | 8 +- mod/hotpot/template/v6/jmix6.js_ | 56 ++++- mod/hotpot/template/v6/jquiz6.ht_ | 8 +- mod/hotpot/template/v6/jquiz6.js_ | 67 +++++- mod/hotpot/template/v6/masher.ht_ | 4 + mod/hotpot/template/v6/testbrowsercheck.htm | 2 +- mod/hotpot/version.php | 4 +- 28 files changed, 752 insertions(+), 135 deletions(-) diff --git a/mod/hotpot/README.TXT b/mod/hotpot/README.TXT index 79dbfafb9ac..fbf846b3d8f 100644 --- a/mod/hotpot/README.TXT +++ b/mod/hotpot/README.TXT @@ -1,5 +1,5 @@ ================================================== -This is v2.2.0 of the HotPot module for Moodle 1.7 +This is v2.2.1 of the HotPot module for Moodle 1.7 ================================================== This module allows teachers to administer Hot Potatoes and TexToys quizzes via Moodle. diff --git a/mod/hotpot/hotpot-full.js b/mod/hotpot/hotpot-full.js index 7ee3428b9b7..45d3651f9c6 100644 --- a/mod/hotpot/hotpot-full.js +++ b/mod/hotpot/hotpot-full.js @@ -1014,9 +1014,23 @@ function GetJClozeQuestionDetails(hp, v) { if (r!=2.1) { // exclude Find-It 3a for (var i=0, ii=0; i=0) { + // special fix for "CheckAnswers" in JCloze + s = s.replace(/TotalChars-State\[i\]\.HintsAndChecks/g, '(TotalChars-State[i].HintsAndChecks)'); + } + if (s.indexOf('CorrectLetters-Penalties/')>=0) { + // special fix for "CheckAnswers" in JMatch + s = s.replace(/CorrectLetters-Penalties/g, '(CorrectLetters-Penalties)'); + } + if (s.indexOf('TotCorrectChoices-Penalties/')>=0) { + // special fix for "CheckAnswers" in JMix (v6) + s = s.replace(/TotCorrectChoices-Penalties/g, '(TotCorrectChoices-Penalties)'); + } + if (s.indexOf('TotalCorrect-Penalties/')>=0) { + // special fix for "CheckAnswers" in JMix (v6+) Drag-and_Drop + s = s.replace(/TotalCorrect-Penalties/g, '(TotalCorrect-Penalties)'); + } + } + if (s.indexOf('replace(\\[')>=0) { + s = s.replace(/\\\[/g, '/\\['); + s = s.replace(/\\\]/g, '\\]/g'); + } + if (s.indexOf('for (i')>=0) { + s = s.replace(/for \(/g, 'for (var '); + } + eval('window.' + f + '=function(' + getArgsStr(a) + '){' + s + '}'); + } else { + eval('window.' + f + '=new Function(' + getArgsStr(a, true) + 's);'); + } +} function hpInterceptFeedback() { // modify the function which writes feedback // v6: ShowMessage(Feedback) @@ -2165,7 +2263,7 @@ function hpInterceptFeedback() { if (a[0] && window.FEEDBACK && FEEDBACK[0]) { s = a[0] + "+='

" + '' + FEEDBACK[6] + "';" + s; } - eval('window.' + f + '=new Function(' + getArgsStr(a) + 's);'); + hpNewFunction(f, a, s); } } function hpInterceptHints() { @@ -2228,7 +2326,7 @@ function hpInterceptHints() { // add the e(x)tra code, if any, to the start of the hint (f)unction if (x) { var s = getFuncCode(f, x, '', true); - eval('window.' + f + '=new Function(' + getArgsStr(a) + 's);'); + hpNewFunction(f, a, s); } } function hpInterceptClues() { @@ -2283,7 +2381,8 @@ function hpInterceptClues() { // add the e(x)tra code, if any, to the start of the clue (f)unction if (x) { var s = getFuncCode(f, x, '', true); - eval('window.' + f + '=new Function(' + getArgsStr(a) + 's);'); + var s = getFuncCode(f, '', '', true); + hpNewFunction(f, a, s); } } function hpInterceptChecks() { @@ -2325,7 +2424,7 @@ function hpInterceptChecks() { if (x) { x = "if(!Finished&&State[QNum].length&&State[QNum][0]<0){" + x + "hpClick(3,args)}"; var s = getFuncCode(f[i], x, '', true); - eval('window.' + f[i] + '=new Function(' + getArgsStr(a) + 's);'); + hpNewFunction(f[i], a, s); } } } @@ -2365,7 +2464,7 @@ function hpInterceptChecks() { } if (f) { var s = getFuncCode(f, x, '', true); - eval('window.' + f + '=new Function(' + getArgsStr(a) + 's);'); + hpNewFunction(f, a, s); } // JMatch has three possible check functions, depending on the version // (NB: other quiz types also have these functions) @@ -2375,7 +2474,7 @@ function hpInterceptChecks() { var a = getFuncArgs(f[i], true); if (a.length==0) { var s = getFuncCode(f[i], "hpClick(3);", '', true); - eval('window.' + f[i] + '=new Function(' + getArgsStr(a) + 's);'); + hpNewFunction(f[i], a, s); break; // out of the loop } } @@ -2661,7 +2760,13 @@ function hpScore() { } else if (t==3) { // jcross if (v==3) x = hpScoreEngine(1, CorrectAnswers, "document.QuizForm.elements[i*2].selectedIndex==a[i]"); else if (v==4) x = hpScoreEngine(1, WinLetters, "ConvertCase(GetBoxValue(i),1).charAt(0)==a[i].charAt(0)"); - else if (v==5 || v==6) x = hpScoreEngine(1, L, "", "L[i]", "L[i][ii] && L[i][ii]==G[i][ii]", "L[i][ii]"); + else if (v==5 || v==6) { + if (window.CaseSensitive) { // HP 6.2 + x = hpScoreEngine(1, L, "", "L[i]", "L[i][ii] && L[i][ii]==G[i][ii]", "L[i][ii]"); + } else { + x = hpScoreEngine(1, L, "", "L[i]", "L[i][ii] && L[i][ii].toUpperCase()==G[i][ii].toUpperCase()", "L[i][ii]"); + } + } } else if (t==4) { // jmatch if (v==3) x = hpScoreEngine(1, CorrectAnswers, "document.QuizForm.elements[i*2].selectedIndex==a[i]"); else if (v==4) x = hpScoreEngine(1, Draggables, "a[i].correct=='1'"); @@ -2742,7 +2847,13 @@ function hpFinished() { } else if (t==3) { // jcross if (v==3) x = hpFinishedEngine(document.Crossword.elements, "ConvertCase(is.mac?unescape(MacStringToWin(a[i].value)):a[i].value,1)!=Letters[i]"); else if (v==4) x = hpFinishedEngine(WinLetters, "ConvertCase(GetBoxValue(i),1).charAt(0) != a[i].charAt(0)"); - else if (v==5 || v==6) x = hpFinishedEngine(L, "", "L[i]", "L[i][ii] && L[i][ii]!=G[i][ii]"); + else if (v==5 || v==6) { + if (window.CaseSensitive) { // 6.2 + x = hpFinishedEngine(L, "", "L[i]", "L[i][ii] && L[i][ii]!=G[i][ii]"); + } else { + x = hpFinishedEngine(L, "", "L[i]", "L[i][ii] && L[i][ii].toUpperCase()!=G[i][ii].toUpperCase()"); + } + } } else if (t==4) { // jmatch if (v==3) x = hpFinishedEngine(CorrectAnswers, "document.QuizForm.elements[i*2].selectedIndex != a[i]"); else if (v==4) x = hpFinishedEngine(Draggables, "a[i].correct!='1'"); @@ -2801,9 +2912,9 @@ function hpIsStrict() { // ************** // initialization // ************** -hpInterceptFeedback(); -hpInterceptHints(); -hpInterceptClues(); +//hpInterceptFeedback(); +//hpInterceptHints(); +//hpInterceptClues(); hpInterceptChecks(); function hpFindForm(formname, w) { if (w==null) w = self; @@ -2867,8 +2978,13 @@ if (DB[7] && DB[8] && !is_LMS()) { var p = getPrompt(window.GetUserName || window.StartUp); var c = getStartUpCode(window.StartUp); if (p && c) { - window.StartUp = new Function('QuizLogin("' + p + '")'); - window.StartQuiz = new Function(c); + if (window.C && C.safari) { + eval('window.StartUp=function(){QuizLogin("' + p + '")}'); + eval('window.StartQuiz=function(){' + c + '}'); + } else { + window.StartUp = new Function('QuizLogin("' + p + '")'); + window.StartQuiz = new Function(c); + } // "QuizLogin" finshes by calling "StartQuiz" } // reassign the SendResults function diff --git a/mod/hotpot/template/default.php b/mod/hotpot/template/default.php index 4f35b28e3f0..b570e4b3400 100644 --- a/mod/hotpot/template/default.php +++ b/mod/hotpot/template/default.php @@ -24,11 +24,11 @@ class hotpot_xml_template_default { // [1] the full block name (including optional leading 'str' or 'incl') // [2] leading 'incl' or 'str', if any // [3] the real block name ([1] without [2]) - $search = '/\[\/((incl|str)?(\w+))\]/'; + $search = '/\[\/((incl|str)?((?:\w|\.)+))\]/'; preg_match_all($search, $this->$tag, $names); $i_max = count($names[0]); for ($i=0; $i<$i_max; $i++) { - $method = $this->parent->template_dir.'_expand_'.$names[3][$i]; + $method = $this->parent->template_dir.'_expand_'.str_replace('.', '', $names[3][$i]); if (method_exists($this, $method)) { eval('$value=$this->'.$method.'();'); $search = '/\['.$names[1][$i].'\](.*?)\[\/'.$names[1][$i].'\]/s'; diff --git a/mod/hotpot/template/v6.php b/mod/hotpot/template/v6.php index 60e86274884..41092496168 100644 --- a/mod/hotpot/template/v6.php +++ b/mod/hotpot/template/v6.php @@ -324,6 +324,11 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default { return $this->v6_expand_NavButtons(); } + // switch off scorm + function v6_expand_Scorm12() { + return false; + } + // js files (all quiz types) function v6_expand_JSBrowserCheck() { diff --git a/mod/hotpot/template/v6/djmatch6.ht_ b/mod/hotpot/template/v6/djmatch6.ht_ index 37141ff76ff..04a96e16869 100644 --- a/mod/hotpot/template/v6/djmatch6.ht_ +++ b/mod/hotpot/template/v6/djmatch6.ht_ @@ -29,6 +29,10 @@ [inclNavButtons] @@ -80,7 +84,7 @@
-

[strInstructions]

+
[strInstructions]
diff --git a/mod/hotpot/template/v6/djmatch6.js_ b/mod/hotpot/template/v6/djmatch6.js_ index 2ca48f9aa97..65a148a9472 100644 --- a/mod/hotpot/template/v6/djmatch6.js_ +++ b/mod/hotpot/template/v6/djmatch6.js_ @@ -1,4 +1,32 @@ +[inclScorm1.2] +//JMATCH-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 = 'Matching'; + API.LMSSetValue('cmi.objectives.0.id', 'obj'+ItemLabel); + API.LMSSetValue('cmi.interactions.0.id', 'int'+ItemLabel); + API.LMSSetValue('cmi.objectives.0.status', API.LMSGetValue('cmi.core.lesson_status')); + 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] + +//JMATCH-SPECIFIC CORE JAVASCRIPT CODE + var CorrectResponse = '[strGuessCorrect]'; var IncorrectResponse = '[strGuessIncorrect]'; var YourScoreIs = '[strYourScoreIs]'; @@ -20,6 +48,7 @@ var LeftColPos = 100; var RightColPos = 500; var DragTop = 120; var Finished = false; +var AnswersTried = ''; //Fixed and draggable card arrays FC = new Array(); @@ -69,6 +98,10 @@ function DroppedOnFixed(DNum){ function StartUp(){ +[inclScorm1.2] + ScormStartUp(); +[/inclScorm1.2] + [inclSendResults] GetUserName(); [/inclSendResults] @@ -140,10 +173,9 @@ function StartUp(){ if (TempInt > WidestRight){WidestRight = TempInt;} } - var HeightToSet = Highest; - if (C.gecko||C.ie5mac){HeightToSet -= 12;} - var WidthToSet = WidestRight; - if (C.gecko||C.ie5mac){WidthToSet -= 12;} +//Fix for 6.2: the reduction by 12 seems to be required -- no idea why! + var HeightToSet = Highest-12; + var WidthToSet = WidestRight-12; for (i=0; i 0){AnswersTried += ' | ';} var i, j; for (i=0; i0){AnswersTried += ',';} + AnswersTried += D[i][1] + '.' + D[i][2] + ''; if ((D[i][2] == D[i][1])&&(D[i][2] > 0)){ TotalCorrect++; } @@ -307,6 +342,14 @@ function CheckAnswers(){ setTimeout('Finish()', SubmissionTimeout); WriteToInstructions(Feedback); } +[inclScorm1.2] + if (AllDone == true){ + SetScormComplete(); + } + else{ + SetScormIncomplete(); + } +[/inclScorm1.2] } [inclTimer] @@ -318,6 +361,9 @@ function TimesUp() { TimeOver = true; CheckAnswers(); Locked = true; +[inclScorm1.2] + SetScormTimedOut(); +[/inclScorm1.2] } [/inclTimer] diff --git a/mod/hotpot/template/v6/djmix6.ht_ b/mod/hotpot/template/v6/djmix6.ht_ index d954337e41d..1fb8c7c9fc2 100644 --- a/mod/hotpot/template/v6/djmix6.ht_ +++ b/mod/hotpot/template/v6/djmix6.ht_ @@ -29,6 +29,10 @@ [inclNavButtons] @@ -80,7 +84,7 @@
-

[strInstructions]

+
[strInstructions]
diff --git a/mod/hotpot/template/v6/djmix6.js_ b/mod/hotpot/template/v6/djmix6.js_ index 8059a7c0704..e568c046606 100644 --- a/mod/hotpot/template/v6/djmix6.js_ +++ b/mod/hotpot/template/v6/djmix6.js_ @@ -1,3 +1,35 @@ +[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]'; @@ -37,6 +69,7 @@ var DivWidth = 600; var LeftColPos = 100; var DragTop = 120; var DragNumber = -1; +var AnswersTried = ''; Lines = new Array(); @@ -211,6 +244,9 @@ function CheckAnswer(CheckType){ } } WellDone = '' + CompiledOutput + '

' + CorrectResponse + '
'; + + if (AnswersTried.length > 0){AnswersTried += ' | ';} + AnswersTried += CompiledOutput; //Do score calculation here Score = Math.floor(((Segments.length-Penalties) * 100)/Segments.length); @@ -227,7 +263,10 @@ function CheckAnswer(CheckType){ } else{ - TryAgain = '' + CompileString(GuessSequence) + '

'; + var WrongGuess = CompileString(GuessSequence); + if (AnswersTried.length > 0){AnswersTried += ' | ';} + AnswersTried += WrongGuess; + TryAgain = '' + WrongGuess + '

'; if ((CheckType == 0)||(LongestCorrect.length==0)){ TryAgain += IncorrectResponse + '
'; } @@ -267,6 +306,15 @@ function CheckAnswer(CheckType){ setTimeout('Finish()', SubmissionTimeout); WriteToInstructions(YourScoreIs + ' ' + Score + '%.'); } + +[inclScorm1.2] + if (AllDone == true){ + SetScormComplete(); + } + else{ + SetScormIncomplete(); + } +[/inclScorm1.2] } @@ -396,6 +444,10 @@ function StartUp(){ GetUserName(); [/inclSendResults] +[inclScorm1.2] + ScormStartUp(); +[/inclScorm1.2] + [inclPreloadImages] PreloadImages([PreloadImageList]); [/inclPreloadImages] @@ -517,5 +569,8 @@ function TimesUp() { TimeOver = true; CheckAnswer(0); Locked = true; +[inclScorm1.2] + SetScormTimedOut(); +[/inclScorm1.2] } [/inclTimer] diff --git a/mod/hotpot/template/v6/fjmatch6.ht_ b/mod/hotpot/template/v6/fjmatch6.ht_ index 3ec5d096b68..2a22c60e528 100644 --- a/mod/hotpot/template/v6/fjmatch6.ht_ +++ b/mod/hotpot/template/v6/fjmatch6.ht_ @@ -29,6 +29,9 @@ - + @@ -66,7 +69,7 @@
-

[strInstructions]

+
[strInstructions]
diff --git a/mod/hotpot/template/v6/fjmatch6.js_ b/mod/hotpot/template/v6/fjmatch6.js_ index 79db982d861..988ac5435a5 100644 --- a/mod/hotpot/template/v6/fjmatch6.js_ +++ b/mod/hotpot/template/v6/fjmatch6.js_ @@ -1,4 +1,17 @@ +[inclScorm1.2] +//JMATCH-SPECIFIC SCORM-RELATED JAVASCRIPT CODE + +function SetScormBrowseTime(){ +if (API != null){ + API.LMSSetValue('cmi.core.session_time', MillisecondsToTime((new Date()).getTime() - ScormStartTime)); + API.LMSCommit(''); + } +} +[/inclScorm1.2] + +//JMATCH-SPECIFIC CORE JAVASCRIPT CODE + var CurrItem = null; var Stage = 2; var QList = new Array(); @@ -34,6 +47,17 @@ function SetUpItems(){ function StartUp(){ SetUpItems(); + +[inclScorm1.2] + initAPI(window); + if (API != null){ + API.LMSInitialize(''); + API.LMSSetValue('cmi.core.lesson_status', 'browsed'); + API.LMSSetValue('cmi.comments', 'This exercise has no checking or scoring features.'); + API.LMSCommit(''); + } +[/inclScorm1.2] + [inclPreloadImages] PreloadImages([PreloadImageList]); diff --git a/mod/hotpot/template/v6/hp6.cs_ b/mod/hotpot/template/v6/hp6.cs_ index 2ea245bcda8..05c9b3e700e 100644 --- a/mod/hotpot/template/v6/hp6.cs_ +++ b/mod/hotpot/template/v6/hp6.cs_ @@ -6,6 +6,12 @@ /* Made with executable version [strFullVersionInfo] */ + +/* Hack to hide a nested Quicktime player from IE, which can't handle it. */ +* html object.MediaPlayerNotForIE { + display: none; +} + body{ font-family: [strFontFace]; [inclPageBGColor] background-color: [strPageBGColor];[/inclPageBGColor] @@ -381,6 +387,7 @@ div#ClueEntry{ div.Keypad{ text-align: center; display: none; /* initially hidden, shown if needed */ + margin-bottom: 0.5em; } div.Keypad button{ @@ -408,7 +415,9 @@ textarea{ } .QuestionText{ - + text-align: left; + margin: 0px; + font-size: 100%; } .Answer{ diff --git a/mod/hotpot/template/v6/hp6checkshortanswer.js_ b/mod/hotpot/template/v6/hp6checkshortanswer.js_ index ce7357f4e85..f3570d4d3a3 100644 --- a/mod/hotpot/template/v6/hp6checkshortanswer.js_ +++ b/mod/hotpot/template/v6/hp6checkshortanswer.js_ @@ -186,8 +186,13 @@ function CheckShortAnswer(QNum){ CA.GetBestMatch(); //Store any match in the state tracking field + if (State[QNum][5].length > 0){State[QNum][5] += ' | ';} if (CA.MatchNum > -1){ - State[QNum][5] += String.fromCharCode(65+CA.MatchNum) + ','; + State[QNum][5] += String.fromCharCode(65+CA.MatchNum); + } +//Else store the student's answer + else{ + State[QNum][5] += G; } //Add the percent correct value for this answer to the Q State (works for all diff --git a/mod/hotpot/template/v6/hp6objecttags.ht_ b/mod/hotpot/template/v6/hp6objecttags.ht_ index 50790285828..ad0e1577642 100644 --- a/mod/hotpot/template/v6/hp6objecttags.ht_ +++ b/mod/hotpot/template/v6/hp6objecttags.ht_ @@ -1,18 +1,7 @@ -[QuickTime Player] - - - - - - - - -[strContent] -[/QuickTime Player] +[QuickTime Player] [strContent] [/QuickTime Player] -[Windows Media Player] - +[Windows Media Player] [strContent] @@ -26,10 +15,4 @@ [strContent][/Real Player] -[Flash Player] - - -[strContent][/Flash Player] +[Flash Player] [strContent][/Flash Player] diff --git a/mod/hotpot/template/v6/hp6showmessage.js_ b/mod/hotpot/template/v6/hp6showmessage.js_ index 98a33c2b080..58dde4675f1 100644 --- a/mod/hotpot/template/v6/hp6showmessage.js_ +++ b/mod/hotpot/template/v6/hp6showmessage.js_ @@ -6,49 +6,74 @@ var topZ = 1000; function ShowMessage(Feedback){ var Output = Feedback + '

'; + document.getElementById('FeedbackContent').innerHTML = Output; + var FDiv = document.getElementById('FeedbackDiv'); + topZ++; + FDiv.style.zIndex = topZ; + FDiv.style.top = TopSettingWithScrollOffset(30) + 'px'; - var obj = document.getElementById('FeedbackContent'); - if (obj) { - obj.innerHTML = Output; - } - var obj = document.getElementById('FeedbackDiv'); - if (obj) { - topZ++; - obj.style.zIndex = topZ; - obj.style.top = TopSettingWithScrollOffset(30) + 'px'; - obj.style.display = 'block'; - } + FDiv.style.display = 'block'; ShowElements(false, 'input'); ShowElements(false, 'select'); ShowElements(false, 'object'); + ShowElements(true, 'object', 'FeedbackContent'); //Focus the OK button - var obj = document.getElementById('FeedbackOKButton'); - if (obj) { - setTimeout("document.getElementById('FeedbackOKButton').focus()", 50); - } + setTimeout("document.getElementById('FeedbackOKButton').focus()", 50); //[inclPreloadImages] // RefreshImages(); //[/inclPreloadImages] } -function ShowElements(Show, TagName){ -//Special for IE bug -- hide all the form elements that will show through the popup - if (C.ie){ - var Els = document.getElementsByTagName(TagName); - for (var i=0; i - + @@ -80,7 +84,7 @@
-

[strInstructions]

+
[strInstructions]
[inclReading] @@ -126,7 +130,7 @@ [inclKeypad] -
+
[strKeypad]
[/inclKeypad] diff --git a/mod/hotpot/template/v6/jcloze6.js_ b/mod/hotpot/template/v6/jcloze6.js_ index 95b0c53d0c9..3a22cce217c 100644 --- a/mod/hotpot/template/v6/jcloze6.js_ +++ b/mod/hotpot/template/v6/jcloze6.js_ @@ -1,4 +1,39 @@ +[inclScorm1.2] +//JCLOZE-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 detailed reports about each item + for (var i=0; i0){ThisItemGuesses += ' | ';} + ThisItemGuesses += State[i].Guesses[j]; + } + API.LMSSetValue('cmi.interactions.' + i + '.type', 'fill-in'); + API.LMSSetValue('cmi.interactions.' + i + '.student_response', ThisItemGuesses); + } + API.LMSCommit(''); + } +} +[/inclScorm1.2] + //JCLOZE CORE JAVASCRIPT CODE function ItemState(){ @@ -31,6 +66,14 @@ State = new Array(); function StartUp(){ RemoveBottomNavBarForIE(); +//Show a keypad if there is one (added bugfix for 6.0.4.12) + if (document.getElementById('CharacterKeypad') != null){ + document.getElementById('CharacterKeypad').style.display = 'block'; + } + +[inclScorm1.2] + ScormStartUp(); +[/inclScorm1.2] [inclSendResults] GetUserName(); @@ -62,7 +105,7 @@ function ShowClue(ItemNum){ } function SaveCurrentAnswers(){ - var Ans = '' + var Ans = ''; for (var i=0; i 0)&&(Ans != State[i].Guesses[State[i].Guesses.length-1])){ @@ -146,6 +189,7 @@ function CheckAnswers(){ CompileGuesses(); if ((AllCorrect == true)||(Finished == true)){ + [inclSendResults] setTimeout('SendResults(' + TotalScore + ')', 50); [/inclSendResults] @@ -157,6 +201,14 @@ function CheckAnswers(){ Finished = true; setTimeout('Finish()', SubmissionTimeout); } +[inclScorm1.2] + if (AllCorrect == true){ + SetScormComplete(); + } + else{ + SetScormIncomplete(); + } +[/inclScorm1.2] } function TrackFocus(BoxNumber){ @@ -299,6 +351,7 @@ function GetHint(GapNum){ } function ShowHint(){ + if (document.getElementById('FeedbackDiv').style.display == 'block'){return;} if (Locked == true){return;} var CurrGap = FindCurrent(); if (CurrGap < 0){return;} @@ -330,5 +383,8 @@ function TimesUp() { Finished = true; CheckAnswers(); Locked = true; +[inclScorm1.2] + SetScormTimedOut(); +[/inclScorm1.2] } [/inclTimer] \ No newline at end of file diff --git a/mod/hotpot/template/v6/jcross6.ht_ b/mod/hotpot/template/v6/jcross6.ht_ index 706af6956bb..bcaeea97680 100644 --- a/mod/hotpot/template/v6/jcross6.ht_ +++ b/mod/hotpot/template/v6/jcross6.ht_ @@ -29,6 +29,10 @@ @@ -80,7 +84,7 @@
-

[strInstructions]

+
[strInstructions]
[inclReading] @@ -102,7 +106,7 @@
[inclKeypad] -
+
[strKeypad]
[/inclKeypad] diff --git a/mod/hotpot/template/v6/jcross6.js_ b/mod/hotpot/template/v6/jcross6.js_ index 85b90e2bd7c..26c911ff05b 100644 --- a/mod/hotpot/template/v6/jcross6.js_ +++ b/mod/hotpot/template/v6/jcross6.js_ @@ -1,3 +1,31 @@ +[inclScorm1.2] +//JCROSS-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 = 'Crossword'; + 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're not sending any student response data, so we can set this to a non-standard value + API.LMSSetValue('cmi.interactions.0.type', 'crossword'); + + API.LMSCommit(''); + } +} +[/inclScorm1.2] //JCROSS CORE JAVASCRIPT CODE @@ -17,6 +45,7 @@ var Score = 0; var InTextBox = false; var Locked = false; var TimeOver = false; +var CaseSensitive = [boolCaseSensitive]; var InputStuff = '
[strClueNum]: '; InputStuff += '[strClue] '; @@ -29,6 +58,14 @@ var Finished = false; function StartUp(){ RemoveBottomNavBarForIE(); +//Show a keypad if there is one (added bugfix for 6.0.4.12) + if (document.getElementById('CharacterKeypad') != null){ + document.getElementById('CharacterKeypad').style.display = 'block'; + } +[inclScorm1.2] + ScormStartUp(); +[/inclScorm1.2] + AcrossCaption = document.getElementById('CluesAcrossLabel').innerHTML; DownCaption = document.getElementById('CluesDownLabel').innerHTML; [inclSendResults] @@ -126,8 +163,6 @@ function SplitStringToPerceivedChars(InString, PC){ } function EnterAnswer(Guess,Across,AnsLength,x,y){ - Guess = Guess.toUpperCase(); - var PC = new Array(); SplitStringToPerceivedChars(Guess, PC); @@ -161,12 +196,23 @@ function SetGridSquareValue(x,y,Val){ function ShowHint(Across,ClueNum,x,y,BoxId){ var i=x; var j=y; + var LetterFromGuess = ''; + var LetterFromKey = ''; var OutString = ''; if (Across==true){ while (j - + @@ -80,7 +84,7 @@
-

[strInstructions]

+
[strInstructions]
[inclReading] diff --git a/mod/hotpot/template/v6/jmatch6.js_ b/mod/hotpot/template/v6/jmatch6.js_ index a1153f4320f..1922189d8e2 100644 --- a/mod/hotpot/template/v6/jmatch6.js_ +++ b/mod/hotpot/template/v6/jmatch6.js_ @@ -1,4 +1,39 @@ +[inclScorm1.2] +//JMATCH-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 = 'Matching'; + API.LMSSetValue('cmi.objectives.0.id', 'obj'+ItemLabel); + API.LMSSetValue('cmi.interactions.0.id', 'int'+ItemLabel); + API.LMSSetValue('cmi.objectives.0.status', API.LMSGetValue('cmi.core.lesson_status')); + 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'); + + var AnswersTried = ''; + for (var i=0; i0){AnswersTried += ' | ';} + for (var j=0; j0){AnswersTried += ',';} + AnswersTried += j + '.' + Status[j][3][i]; + } + } + API.LMSSetValue('cmi.interactions.0.student_response', AnswersTried); + API.LMSCommit(''); + } +} +[/inclScorm1.2] + +//JMATCH CORE JAVASCRIPT CODE + var CorrectIndicator = '[strCorrectIndicator]'; var IncorrectIndicator = '[strIncorrectIndicator]'; var YourScoreIs = '[strYourScoreIs]'; @@ -19,6 +54,10 @@ var QsToShow = [QsToShow]; function StartUp(){ RemoveBottomNavBarForIE(); +[inclScorm1.2] + ScormStartUp(); +[/inclScorm1.2] + [inclSendResults] GetUserName(); [/inclSendResults] @@ -49,6 +88,7 @@ function CreateStatusArrays(){ Status[x][0] = 0; // Item not matched correctly yet Status[x][1] = 0; //Tries at this item so far Status[x][2] = Selects[x].id; //Store a ref to the original drop-down + Status[x][3] = new Array(); //Sequence of guesses for this item } } @@ -182,6 +222,8 @@ function CheckAnswers(){ //Get a pointer to the drop-down Select = document.getElementById(Status[i][2]); Key = GetKeyFromSelect(Select); +//Save the answer given + Status[i][3].push(Select.options[Select.selectedIndex].value); //Check the answer if (Select.options[Select.selectedIndex].value == Key){ @@ -198,6 +240,10 @@ function CheckAnswers(){ Parent.nextSibling.innerHTML = IncorrectIndicator; } } + else{ +//Add a copy of the last (correct) answer. + Status[i][3].push(Status[i][3][Status[i][3].length-1]); + } //If it's correct, count it if (Status[i][0] == 1){ TotCorrectChoices++; @@ -235,6 +281,15 @@ function CheckAnswers(){ //Show the feedback ShowMessage(Feedback); + +[inclScorm1.2] + if (AllDone == true){ + SetScormComplete(); + } + else{ + SetScormIncomplete(); + } +[/inclScorm1.2] } [inclTimer] @@ -247,6 +302,9 @@ function TimesUp() { Finished = true; CheckAnswers(); Locked = true; +[inclScorm1.2] + SetScormTimedOut(); +[/inclScorm1.2] } [/inclTimer] diff --git a/mod/hotpot/template/v6/jmix6.ht_ b/mod/hotpot/template/v6/jmix6.ht_ index a25997b1850..54c92d46dd2 100644 --- a/mod/hotpot/template/v6/jmix6.ht_ +++ b/mod/hotpot/template/v6/jmix6.ht_ @@ -29,6 +29,10 @@ @@ -80,7 +84,7 @@
-

[strInstructions]

+
[strInstructions]
[inclReading] diff --git a/mod/hotpot/template/v6/jmix6.js_ b/mod/hotpot/template/v6/jmix6.js_ index 18d1fe0de96..52dbd73ac61 100644 --- a/mod/hotpot/template/v6/jmix6.js_ +++ b/mod/hotpot/template/v6/jmix6.js_ @@ -1,5 +1,35 @@ -//JMIX STANDARD OUTPUT FORMAT CODE +[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]'; @@ -13,6 +43,7 @@ var Finished = false; var TimeOver = false; var Score = 0; var strInstructions = ''; +var AnswersTried = ''; var SegmentTemplate = '   [CurrentSegment]   '; @@ -209,6 +240,9 @@ function CheckAnswer(CheckType){ 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 + '%.
'; @@ -224,7 +258,10 @@ function CheckAnswer(CheckType){ } else{ - TryAgain = '' + CompileString(GuessSequence) + '

'; + var WrongGuess = CompileString(GuessSequence); + if (AnswersTried.length > 0){AnswersTried += ' | ';} + AnswersTried += WrongGuess; + TryAgain = '' + WrongGuess + '

'; if (CheckType == 0){ TryAgain += IncorrectResponse + '
'; } @@ -276,6 +313,14 @@ function CheckAnswer(CheckType){ setTimeout('Finish()', SubmissionTimeout); WriteToInstructions(YourScoreIs + ' ' + Score + '%.'); } +[inclScorm1.2] + if (AllDone == true){ + SetScormComplete(); + } + else{ + SetScormIncomplete(); + } +[/inclScorm1.2] } function FindSegment(SegID){ @@ -299,6 +344,10 @@ function StartUp(){ GetUserName(); [/inclSendResults] +[inclScorm1.2] + ScormStartUp(); +[/inclScorm1.2] + [inclPreloadImages] PreloadImages([PreloadImageList]); [/inclPreloadImages] @@ -353,5 +402,8 @@ function TimesUp() { Finished = true; CheckAnswer(0); Locked = true; +[inclScorm1.2] + SetScormTimedOut(); +[/inclScorm1.2] } [/inclTimer] \ No newline at end of file diff --git a/mod/hotpot/template/v6/jquiz6.ht_ b/mod/hotpot/template/v6/jquiz6.ht_ index b26834c2335..3cedaefe1f3 100644 --- a/mod/hotpot/template/v6/jquiz6.ht_ +++ b/mod/hotpot/template/v6/jquiz6.ht_ @@ -29,6 +29,10 @@ @@ -84,7 +88,7 @@
-

[strInstructions]

+
[strInstructions]
[inclReading] diff --git a/mod/hotpot/template/v6/jquiz6.js_ b/mod/hotpot/template/v6/jquiz6.js_ index 92f331bf84e..cf1a4f73cfa 100644 --- a/mod/hotpot/template/v6/jquiz6.js_ +++ b/mod/hotpot/template/v6/jquiz6.js_ @@ -1,4 +1,43 @@ +[inclScorm1.2] +//JQUIZ-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 detailed reports about each item + for (var i=0; i 0){ + ThisItemScore = Math.floor(State[i][0] * 100) + ''; + ThisItemStatus = 'completed'; + } + else{ + ThisItemScore = '0'; + ThisItemStatus = 'incomplete'; + } + API.LMSSetValue('cmi.objectives.' + i + '.score.raw', ThisItemScore); + API.LMSSetValue('cmi.objectives.' + i + '.status', ThisItemStatus); + API.LMSSetValue('cmi.interactions.' + i + '.weighting', I[i][0]); +//We can only use the performance type, because we're storing multiple responses of various types. + API.LMSSetValue('cmi.interactions.' + i + '.type', 'performance'); + API.LMSSetValue('cmi.interactions.' + i + '.student_response', State[i][5]); + } + } + + API.LMSCommit(''); + } +} +[/inclScorm1.2] + //JQUIZ CORE JAVASCRIPT CODE var CurrQNum = 0; @@ -24,6 +63,7 @@ var State = new Array(); var Feedback = ''; var TimeOver = false; var strInstructions = ''; +var Locked = false; //The following variable can be used to add a message explaining that //the question is finished, so no further marking will take place. @@ -153,7 +193,8 @@ function ShowSpecialReadingForQuestion(){ document.getElementById('ReadingDiv').innerHTML = ''; } if (QArray[CurrQNum] != null){ - var Children = QArray[CurrQNum].childNodes; +//Fix for 6.0.4.25 + var Children = QArray[CurrQNum].getElementsByTagName('div'); for (var i=0; i 0){State[QNum][5] += ' | ';} + State[QNum][5] += String.fromCharCode(65+ANum); //Should this answer be accepted as correct? if (I[QNum][3][ANum][2] < 1){ @@ -446,7 +492,7 @@ function CheckMultiSelAnswer(QNum){ var ShouldBeChecked; var Matches = 0; - State[QNum][5] += '|'; + if (State[QNum][5].length > 0){State[QNum][5] += ' | ';} //Check if there are any mismatches Feedback = ''; @@ -563,6 +609,16 @@ function CheckFinished(){ [inclTimer] window.clearInterval(Interval); [/inclTimer] + +[inclScorm1.2] + if (TimeOver == true){ + SetScormTimedOut(); + } + else{ + SetScormComplete(); + } +[/inclScorm1.2] + TimeOver = true; Locked = true; @@ -582,6 +638,11 @@ function CheckFinished(){ Detail += ''; setTimeout('Finish()', SubmissionTimeout); } +[inclScorm1.2] + else{ + SetScormIncomplete(); + } +[/inclScorm1.2] } [inclTimer] diff --git a/mod/hotpot/template/v6/masher.ht_ b/mod/hotpot/template/v6/masher.ht_ index d6755b708de..fa795d8f30f 100644 --- a/mod/hotpot/template/v6/masher.ht_ +++ b/mod/hotpot/template/v6/masher.ht_ @@ -11,6 +11,10 @@ + + +[strHeaderCode] +