<p>
//
}
}
}
//CODE FOR HANDLING DISPLAY OF POPUP FEEDBACK BOX
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';
FDiv.style.display = 'block';
ShowElements(false, 'input');
ShowElements(false, 'select');
ShowElements(false, 'object');
ShowElements(true, 'object', 'FeedbackContent');
//Focus the OK button
setTimeout("document.getElementById('FeedbackOKButton').focus()", 50);
//
// RefreshImages();
//
}
function ShowElements(Show, TagName, ContainerToReverse){
// added third argument to allow objects in the feedback box to appear
//IE bug -- hide all the form elements that will show through the popup
//FF on Mac bug : doesn't redisplay objects whose visibility is set to visible
//unless the object's display property is changed
//get container object (by Id passed in, or use document otherwise)
TopNode = document.getElementById(ContainerToReverse);
var Els;
if (TopNode != null) {
Els = TopNode.getElementsByTagName(TagName);
} else {
Els = document.getElementsByTagName(TagName);
}
for (var i=0; i
ItemToDump = Math.floor(InArray.length*Math.random());
InArray.splice(ItemToDump, 1);
}
}
function Shuffle(InArray){
var Num;
var Temp = new Array();
var Len = InArray.length;
var j = Len;
for (var i=0; i
Longest = i;
}
}
return Longest;
}
//SELECTION OBJECT FOR TYPING WITH KEYPAD
var selObj = null;
SelObj = function(box){
this.box = box;
this.selStart = this.box.selectionStart;
this.selEnd = this.box.selectionEnd;
this.selText = this.box.value.substring(this.selStart, this.selEnd);
return this;
}
function setSelText(newText){
var caretPos = this.selStart + newText.length;
var newValue = this.box.value.substring(0, this.selStart);
newValue += newText;
newValue += this.box.value.substring(this.selEnd, this.box.value.length);
this.box.value = newValue;
this.box.setSelectionRange(caretPos, caretPos);
this.box.focus();
}
SelObj.prototype.setSelText = setSelText;
function setSelSelectionRange(start, end){
this.box.setSelectionRange(start, end);
}
SelObj.prototype.setSelSelectionRange = setSelSelectionRange;
//UNICODE CHARACTER FUNCTIONS
function IsCombiningDiacritic(CharNum){
var Result = (((CharNum >= 0x0300)&&(CharNum <= 0x370))||((CharNum >= 0x20d0)&&(CharNum <= 0x20ff)));
Result = Result || (((CharNum >= 0x3099)&&(CharNum <= 0x309a))||((CharNum >= 0xfe20)&&(CharNum <= 0xfe23)));
return Result;
}
function IsCJK(CharNum){
return ((CharNum >= 0x3000)&&(CharNum < 0xd800));
}
//SETUP FUNCTIONS
//BROWSER WILL REFILL TEXT BOXES FROM CACHE IF NOT PREVENTED
function ClearTextBoxes(){
var NList = document.getElementsByTagName('input');
for (var i=0; i
NList[i].value = '';
}
if (NList[i].id.indexOf('Chk') > -1){
NList[i].checked = '';
}
}
}
//JMATCH CORE JAVASCRIPT CODE
var CorrectIndicator = '✔';
var IncorrectIndicator = '✘';
var YourScoreIs = 'Your score is ';
var CorrectResponse = 'Correct! Well done.';
var IncorrectResponse = 'Sorry! Try again. ';
var TotalUnfixedLeftItems = 0;
var TotCorrectChoices = 0;
var Penalties = 0;
var Finished = false;
var TimeOver = false;
var Score = 0;
var Locked = false;
var ShuffleQs = false;
var QsToShow = 5;
function TimerStartUp(){
setTimeout('JsonEx.Setup()', 300);
}
/*
The new V7 JSON object replaces the arrays of old.
*/
var V7JsonEx = '{ "ShuffleLeftItems": false, "IsSimple": true, "ItemsToShow": -1, "LeftItems": [{"OrigPos": 0, "Group": 0}, {"OrigPos": 1, "Group": 1}, {"OrigPos": 2, "Group": 2}, {"OrigPos": 3, "Group": 3}, {"OrigPos": 4, "Group": 4}], "RightItems": [{"OrigPos": 0, "Groups": [0], "MatchedWith": -1}, {"OrigPos": 1, "Groups": [1], "MatchedWith": -1}, {"OrigPos": 2, "Groups": [2], "MatchedWith": -1}, {"OrigPos": 3, "Groups": [3], "MatchedWith": -1}, {"OrigPos": 4, "Groups": [4], "MatchedWith": -1}]}';
var JsonEx = JSON.parse(V7JsonEx);
JsonEx.GetLeftItemByOrigPos = function(Pos){
for (var i=0; i
while (this.LeftItems.length > this.ItemsToShow){
RemItem = Math.floor(this.LeftItems.length*Math.random());
OP = this.LeftItems[RemItem].OrigPos;
//Remove the whole table row which is the parent of this left item.
var row = this.LeftItems[RemItem].Cell.parentNode;
row.parentNode.removeChild(row);
this.LeftItems.splice(RemItem, 1);
//Having removed an item from the left, we must remove the corresponding
//one from the right if it exists. (There may not be a matching item if
//the one removed was a distractor.)
for (i = 0; i < this.RightItems.length; i++){
if (this.RightItems[i].OrigPos == OP){
//Before removing the item itself, we need to remove its option
//from all the select elements.
nList = document.querySelectorAll('option[data-origPos="R_' + OP + '"]');
for (var j=0; j
arrRows.push(this.tbody.removeChild(rows[i]));
}
arrRows = Shuffle(arrRows);
for (i=0; i
for (var j=0; j
for (i=0; i
//Mark this right
LI.MarkingCell.innerHTML = CorrectIndicator;
if ((this.IsSimple)&&(LI.Select.style.display !== 'none')){
//LI.Select.parentNode.innerHTML = LI.Select.options[LI.Select.options.selectedIndex].innerText;
LI.Select.parentNode.appendChild(document.createTextNode(LI.Select.options[LI.Select.options.selectedIndex].innerText));
LI.Select.style.display = 'none';
}
CorrectItems++;
}
else{
LI.MarkingCell.innerHTML = IncorrectIndicator;
Done = false;
}
}
}
}
if (!this.hasOwnProperty('Score')){
this.Score = 0;
}
this.Score = Math.round((100*(CorrectItems - this.Penalties))/ItemsToCount);
if (Done === false){
this.Penalties++;
}
return Done;
};
function CheckAnswers(){
if (Locked == true){return;}
var Feedback = '';
var AllDone = JsonEx.CheckAnswers();
Score = JsonEx.Score;
if (Score < 0){Score = 0;}
if (AllDone == true){
Feedback = YourScoreIs + ' ' + Score + '%.
' + CorrectResponse;
}
else {
if (TimeOver == true){
Feedback = YourScoreIs + ' ' + Score + '%.'
}
else{
Feedback = YourScoreIs + ' ' + Score + '%.' + '
' + IncorrectResponse;
}
}
ShowMessage(Feedback);
//If the exercise is over, deal with that
if ((AllDone == true)||(TimeOver == true)){
TimeOver = true;
Locked = true;
Finished = true;
WriteToInstructions(Feedback);
}
}
//-->
//]]>