home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2003 December
/
CMCD1203.ISO
/
Software
/
Shareware
/
Programare
/
toolkit
/
toolkitsetup.msi
/
Instal01.cab
/
_5ED5CEB7E5D64103AA892EBF6EE02F0E
< prev
next >
Wrap
Text File
|
2003-10-07
|
9KB
|
211 lines
//Called by processActivity() , used to display Activity Popup window
function showActPopup(theActivityQuestion, widthVal, heightVal)
{
closePopup();
var labelText = (theActivityQuestion.answeredCorrectly) ? "Correct": "Incorrect";
var htmlHeader = "<br clear='all'>\n<table width='90%' border=0 cellpadding=4 cellspacing=0 align='center' class='popupTable'>\n<tr>\n" +
"<td bgcolor='#336699' class='popupTitle'>\n"
var htmlTween = "</td>\n</tr>\n<tr>\n<td valign='middle' class='popupBorder'><br clear='all'>\n";
var actDef = (theActivityQuestion.actRationale != "") ? theActivityQuestion.actRationale: "That is " + labelText;
var htmlFooter = "<p align='right'><a href='javascript: window.close();'>Close Window</a> </p></td>\n</tr>\n</table>";
window.popupWindowContents = htmlHeader + labelText + htmlTween + actDef + htmlFooter;
window.setTimeout("openPopup(" + widthVal + ", " + heightVal + ")", 500);
return true;
}
//OBJECT: Activity Object created by USER in inc_Activities
function objActQuestion(uniqueID, txtQuestionType)
{
this.type = 'ActivityQuestion';
this.uniqueID = uniqueID;
this.name = "q"+uniqueID;
this.actQuestion = '';
this.actQuestionType = txtQuestionType.toLowerCase();
this.actRationale = '';
this.actDistractors = new Array();
this.addDistractor = setDistractor;
this.shuffleDistractors = randomizeDistractors;
this.answeredCorrectly = false;
var instrVerb = (this.actQuestionType == "text") ? "Enter": "Select";
this.answerVerb = instrVerb.toLowerCase();
var instrNum = (this.actQuestionType == "checkbox") ? "s": "";
this.txtInstructions = "<b>" + instrVerb + " the correct answer" + instrNum + " and click the 'Submit' button.</b>\n";
return(this);
}
//OBJECT: Question Distractor Object created by setDistractor()
function buildDistractor(blnCorrect)
{
this.isCorrect = blnCorrect;
this.txtValue = '';
this.txtDisplay = '';
this.isSelected = false;
this.txtInput = '';
return(this);
}
//Called by objActQuestion(): addDistractor() method to create a Distractor (potential answer)
function setDistractor(blnCorrect)
{
this.actDistractors[this.actDistractors.length] = new buildDistractor(blnCorrect);
}
//Called by objActQuestion(): shuffleDistractors() used to shuffle the order of the Distractors
function randomizeDistractors()
{
shuffle(this.actDistractors);
}
//Called by randomizeDistractors() and inc_Activities, used to shuffle the order of Distractors
function shuffle(arrToShuffle)
{
var j, tempHolder;
for(var i = 0; i < arrToShuffle.length; i++)
{
j = Math.floor(Math.random() * arrToShuffle.length);
tempHolder = arrToShuffle[i];
arrToShuffle[i] = arrToShuffle[j];
arrToShuffle[j] = tempHolder;
}
return(arrToShuffle);
}
//Called by writeActivityHTML() and processActivity(), used to return a reference to an Activity Question Object by UniqueID
function rtnActQuestion(uniqueID)
{
var actQuestion;
var theID = uniqueID.toString();
for(actQuestion = 0; actQuestion < arrActObjects.length; actQuestion++)
if(arrActObjects[actQuestion].uniqueID.toString() == theID)
return(arrActObjects[actQuestion]);
return false;
}
//Called by processActivity(), used to return the answer provided
function setSelected(theActFormField, objQuestion)
{
var arrSelectedAnswers = new Array();
if(theActFormField.length)
{
var thisElement;
for(thisElement = 0; thisElement < theActFormField.length; thisElement++)
if(((theActFormField[thisElement].checked) || (theActFormField[thisElement].selected)))
arrSelectedAnswers[arrSelectedAnswers.length] = theActFormField[thisElement].value;
}else{
arrSelectedAnswers[arrSelectedAnswers.length] = theActFormField.value;
}
if(arrSelectedAnswers.length > 0)
{
var arrQuestionAnswers = objQuestion.actDistractors;
var questionType = objQuestion.actQuestionType;
var thisDistractor, thisSelValue, thisTestValue, theSetValue;
for(thisDistractor = 0; thisDistractor < arrQuestionAnswers.length; thisDistractor++)
arrQuestionAnswers[thisDistractor].isSelected = false;
for(thisElement = 0; thisElement < arrSelectedAnswers.length; thisElement++)
for(thisDistractor = 0; thisDistractor < arrQuestionAnswers.length; thisDistractor++)
{
thisSelValue = arrSelectedAnswers[thisElement];
thisTestValue = arrQuestionAnswers[thisDistractor].txtValue;
if(questionType == "text")
{
thisTestValue = new RegExp(thisTestValue,"gi");
theSetValue = thisSelValue.match(thisTestValue);
}else{
theSetValue = (thisSelValue == thisTestValue);
}
if(theSetValue)
arrQuestionAnswers[thisDistractor].isSelected = true;
}
return true;
}else{
return false;
}
}
//Called by processActivity(), used to verify if answer provided for a given question is correct
function checkCorrect(objQuestion)
{
var theReturn = true, thisDistractor;
var arrQuestionDistractors = objQuestion.actDistractors;
for(thisDistractor = 0; thisDistractor < arrQuestionDistractors.length; thisDistractor++)
if(!arrQuestionDistractors[thisDistractor].isSelected == arrQuestionDistractors[thisDistractor].isCorrect)
theReturn = false;
objQuestion.answeredCorrectly = theReturn;
return(theReturn);
}
//Called by writeQuestionHTML(), used to determine the number of correct values for the provided Question
function getCorrect(objActQuestion)
{
var arrCorrectAnswers = new Array();
var distractorItem;
for (distractorItem = 0; distractorItem < objActQuestion.actDistractors.length; distractorItem++)
if(objActQuestion.actDistractors[distractorItem].isCorrect)
arrCorrectAnswers[arrCorrectAnswers.length] = objActQuestion.actDistractors[distractorItem].txtValue;
return(arrCorrectAnswers);
}
//Called by User in Lesson page to write the Activity Question
function writeActivityHTML(uniqueID)
{
var theActQuestion = rtnActQuestion(uniqueID);
var writeThis = "";
if(!theActQuestion)
return(writeThis);
var questionType = theActQuestion.actQuestionType;
var fieldName = theActQuestion.name;
writeThis = "<br clear='all'>\n<table width='100%' align='center' cellpadding=5 cellspacing=0 border=0 class='popupTable'>\n<form name='theForm' id='theForm' onSubmit='return parentRef.processActivity(this, \"" + fieldName + "\", " + theActQuestion.uniqueID + ");'><tr><td class='popupTitle'><b>Q&A</b></td></tr><tr><td>" + theActQuestion.actQuestion + "<br><br>" +
theActQuestion.txtInstructions +
"<br clear='all'><table width='100%' align='center' cellpadding=3 cellspacing=0 border=0><tr><td width=35 height=1><img src='./images/kleer.gif' width=35 height=1 border=0></td>" +
"<td width=1 height=1><img src='./images/kleer.gif' width=1 height=1 border=0></td>" +
"<td width='100%' height=1><img src='./images/kleer.gif' height=1 border=0></td></tr>\n";
if(questionType == "select")
{
var actAnswers = getCorrect(theActQuestion);
var multiAttribute = (actAnswers.length > 1) ? " MULTIPLE size='" + (theActQuestion.actDistractors.length) + "'": "";
writeThis += "<tr><td> </td><td align='left' colspan=2 width='100%'>\n<select name='" + fieldName + "' id='" + fieldName + "'" + multiAttribute + ">";
}
var distractorItem;
for(distractorItem in theActQuestion.actDistractors)
{
switch(questionType)
{
case "select":
writeThis += "<option value='" + theActQuestion.actDistractors[distractorItem].txtValue + "'>" + theActQuestion.actDistractors[distractorItem].txtDisplay + "</option>\n";
break;
case "checkbox":
case "radio":
writeThis += "<tr><td> </td><td valign='top'><input type='" + questionType + "' name='" + fieldName + "' id='" + fieldName + "' value='" + theActQuestion.actDistractors[distractorItem].txtValue + "'></td><td width='100%'>" + theActQuestion.actDistractors[distractorItem].txtDisplay + "</td></tr>\n";
break;
case "text":
writeThis += "<tr><td> </td><td valign='top' width='100%'><input type='" + questionType + "' name='" + fieldName + "' id='" + fieldName + "' value='' size=20></td><td> </td></tr>\n";
break;
default:
break;
}
}
if(questionType == "select")
writeThis += "</select><br><br></td></tr>\n";
writeThis += "</table>\n</td></tr>\n<tr><td align='right'><input type='submit' name='theButton' id='theButton' value='Submit'></td></tr>\n</form></table><br clear='all'>";
return(writeThis);
}
//Called by User Submit Button, used to determine activity outcome and report results
function processActivity(formField, fieldName, uniqueID)
{
var theField = formField[fieldName];
var theActivityQuestion = rtnActQuestion(uniqueID);
var didSelect = setSelected(theField, theActivityQuestion);
if(didSelect)
{
var theResult = checkCorrect(theActivityQuestion);
var didShow = showActPopup(theActivityQuestion, 260, 200);
}else{
alert("Please " + theActivityQuestion.answerVerb + " an answer");
}
return false;
}
var ActID, thisID, thisOpt;
var arrActObjects = new Array();