home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2003 December
/
CMCD1203.ISO
/
Software
/
Shareware
/
Programare
/
toolkit
/
toolkitsetup.msi
/
Instal01.cab
/
_74421C2668504F5E870700B3FF8726FB
< prev
next >
Wrap
Text File
|
2003-10-15
|
11KB
|
273 lines
var correctAnswers = lastPage = currentPage = 0;
var evalCompleted = false;
var pageURL = hasQuery = queryString = queryParts = whatStep = evalUniqueID = "";
//OBJECT: Evaluation Question Object created by USER in inc_Questions and inc_Objectives
function objEvalQuestion(intUniqueID, txtQuestionType)
{
this.type = 'EvaluationQuestion';
this.evalUniqueID = intUniqueID;
this.name = "q"+intUniqueID;
this.evalQuestion = '';
this.evalQuestionType = txtQuestionType.toLowerCase();
this.evalPointValue = 1;
this.evalDistractors = new Array();
this.addDistractor = setDistractor;
this.answeredCorrectly = true;
var instrVerb = (this.evalQuestionType == "text") ? "Enter": "Select";
this.txtInstructions = "<b>" + instrVerb + " the appropriate answer 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 evalDisplay AND getStarted() to set all variables for the current page's use
function setEnvironment()
{
pageURL = parent.frames.surveyFrame.location.href;
hasQuery = (pageURL.indexOf("?") > 0) ? true: false;
queryString = (hasQuery) ? pageURL.split("?")[1]: "";
whatStep = (getQueryStringValue("whatStep") == "") ? "overview": getQueryStringValue("whatStep");
lastPage = (getQueryStringValue("currentPage") == "") ? 0: parseInt(getQueryStringValue("currentPage"));
currentPage = (whatStep == "next") ? lastPage + 1: lastPage;
evalUniqueID = getQueryStringValue("evalUniqueID");
}
//Called by User in Lesson Page, used to retrieve the CopyRight statement
function txtCopyRight()
{
var theReturn = (copyright != "") ? copyright: " ";
return theReturn;
}
///Called by surveyDisplay, evaluates the current state and draws the correct page
function getStarted()
{
setEnvironment();
var theReturn;
var evalToCheck = rtnEvalQuestion(evalUniqueID, arrQuestions);
var answerSubmitted = getQueryStringValue(evalToCheck.name);
answerSubmitted = (answerSubmitted) ? answerSubmitted: answerSubmitted = " ";
setSelected(answerSubmitted, evalToCheck);
evalCompleted = (intNumQuestions == currentPage) ? true: false;
if(whatStep == "overview")
{
theReturn = writeOverviewHTML();
}else{
theReturn = (intNumQuestions >= currentPage) ? writeQuestionHTML(arrQuestions[lastPage]): writeResultsHTML();
}
return(theReturn);
}
//Called by getStarted() AND setEnvironment(), used to extract a named value from Querystring
function getQueryStringValue(fieldName)
{
var theFieldName = fieldName + "=";
var rtnValue = "";
var tmpHolder = new Array();
var arrRtnValue = new Array();
if(hasQuery)
{
if(queryString.indexOf(theFieldName) > -1)
{
tmpHolder = queryString.split(theFieldName);
if(tmpHolder.length < 3)
rtnValue = tmpHolder[1].split("&")[0];
else
for(i = 1; i < tmpHolder.length; i++)
arrRtnValue[arrRtnValue.length] = tmpHolder[i].split("&")[0];
}
}
if(arrRtnValue.length < 1)
return(rtnValue);
else
return(arrRtnValue);
}
//Called by surveyDisplay to write the page title
function writePageTitle()
{
return(modTitle);
}
//Called by surveyDisplay to write the "page number of pages" images
function writePageInfo()
{
var txtPageInfo;
if(currentPage == 0)
{
txtPageInfo = 'Overview';
}else{
if(currentPage <= intNumQuestions)
{
txtPageInfo = 'Question ' + currentPage + ' of ' + intNumQuestions;
}else{
txtPageInfo = 'Results';
}
}
return(txtPageInfo);
}
//Called by getStarted(), uses to return a reference to an Evaluation Question Object by UniqueID
function rtnEvalQuestion(intTheUniqueID, arrEvalQuestions)
{
var found = false, evalQuestion;
for(evalQuestion in arrEvalQuestions)
if(arrEvalQuestions[evalQuestion].evalUniqueID == intTheUniqueID)
return(arrEvalQuestions[evalQuestion]);
return(found);
}
//Called by getStarted(), used to verify identify the answer provided
function setSelected(theSelectedAnswers, objQuestion)
{
var arrQuestionAnswers = objQuestion.evalDistractors;
var arrSelectedAnswers = new Array();
var questionType = objQuestion.evalQuestionType;
if(theSelectedAnswers[1])
arrSelectedAnswers = theSelectedAnswers;
else
arrSelectedAnswers[0] = theSelectedAnswers;
if(questionType == "text")
{
var thisTestValue;
thisTestValue = new RegExp(objQuestion.evalDistractors[0].txtValue,"gi");
theSelectedAnswers = cleanText(arrSelectedAnswers[0]);
objQuestion.evalDistractors[0].isSelected = true;
objQuestion.evalDistractors[0].txtDisplay = theSelectedAnswers;
objQuestion.evalDistractors[0].txtValue = "";
}else{
var thisDistractor, thisAnswer;
for(thisAnswer in arrSelectedAnswers)
for(thisDistractor in arrQuestionAnswers)
if(arrSelectedAnswers[thisAnswer] == arrQuestionAnswers[thisDistractor].txtValue)
arrQuestionAnswers[thisDistractor].isSelected = true;
}
return true;
}
//Called by setSelected(), used to format selected values
function cleanText(inText)
{
var theReturn = unescape(inText).replace(/\s|\+/gi, " ").replace("\"", """).replace(/\'/gi, "´");
return(theReturn);
}
//Called by objEvalQuestion(): addDistractor() method to create a Distractor (potential answer)
function setDistractor(blnCorrect)
{
this.evalDistractors[this.evalDistractors.length] = new buildDistractor(blnCorrect);
}
//Called by getStarted(), used to write the QUESTION pages
function writeQuestionHTML(theEvalQuestion)
{
var questionType = theEvalQuestion.evalQuestionType;
var writeThis = "<br clear='all'>\n<table width='100%' align='center' cellpadding=0 cellspacing=0 border=0>\n<form name='theForm'" + getValidation(theEvalQuestion) + "><tr>\n<td><b>Question " + currentPage + ": </b>" + theEvalQuestion.evalQuestion + "<br><br clear='all'>\n" +
theEvalQuestion.txtInstructions +
"<table width='100%' cellpadding=0 cellspacing=0><tr><td width=35 height=1><img src='./images/kleer.gif' width=35 height=1 border=0></td>" +
"<td width=35 height=1><img src='./images/kleer.gif' width=35 height=1 border=0></td>" +
"<td width='100%' height=1><img src='./images/kleer.gif' height=1 border=0></td>\n</tr>\n";
var distractorItem;
for(distractorItem in theEvalQuestion.evalDistractors)
{
switch(questionType)
{
case "radio":
case "checkbox":
writeThis += "<tr><td> </td><td valign='top'><input type='" + questionType + "' name='" + theEvalQuestion.name + "' value='" + theEvalQuestion.evalDistractors[distractorItem].txtValue + "'></td><td>" + theEvalQuestion.evalDistractors[distractorItem].txtDisplay + "</td></tr>\n";
break;
case "text":
writeThis += "<tr><td> </td><td valign='top'><input type='" + questionType + "' name='" + theEvalQuestion.name + "' value='' size=6 maxlength=6></td><td> <i>minutes</i></td></tr>\n";
break;
default:
break;
}
}
writeThis += "<input type='hidden' name='currentPage' value='" + currentPage + "'>\n" +
"<input type='hidden' name='whatStep' value='next'>\n" +
"<input type='hidden' name='evalUniqueID' value='" + theEvalQuestion.evalUniqueID + "'>\n" +
"</td>\n</tr>\n</table></td></tr>\n<tr><td align='right'><input type='submit' name='theButton' value='Submit'></td>" +
"</tr>\n</form>\n</table>";
return(writeThis);
}
//Called by writeQuestionHTML(), used to insert form validation code
function getValidation(objEvlQuestion)
{
var validationScript = "";
if(objEvlQuestion.evalQuestionType == "text")
validationScript = " onSubmit=\"return validateForm(theForm." + objEvlQuestion.name + ".value, '" + objEvlQuestion.evalDistractors[0].txtValue + "', 'Please enter a number.');\"";
return validationScript;
}
//Called by getStarted(), used to write the INSTRUCTIONS page
function writeOverviewHTML()
{
var writeThis = "<b>Instructions</b><br clear='all'><br>\n" +
"Thank you for choosing to complete this survey. All results are anonymous.<br><br>\n" +
"As you complete each question, click on the 'Submit' button.<br><br>\n" +
"Click 'Next' to begin.<br><br>\n" +
"<form name='theForm'>" +
"<input type='hidden' name='currentPage' value=0>\n" +
"<input type='hidden' name='whatStep' value='next'>\n" +
"<div align='right'><input type='submit' name='theButton' value='Next'></div>\n" +
"</form>\n";
return(writeThis);
}
//Called by getStarted(), used to write the RESULTS page
function writeResultsHTML()
{
var writeThis = "<br clear='all'><table width='100%' cellpadding=0 cellspacing=0 align='center'><form name='theForm'><tr><td><b>Results</b><br><br>\n" +
"<b>Thank you for participating in this survey.</b><br>\n";
if(useSCORM)
{
writeThis += "Please click to submit the results.<br><br></td></tr>\n" +
"<tr><td align='right'><input type='button' name='submitEval' value='Submit Results' onclick='parent.frames.codeFrame.SubmitCompletion();'></td>" +
"</tr></form></table>";
}else{
writeThis += "Please print this page and submit the results.<br><br></td></tr>\n";
var thisQuestion, thisAnswer;
for(thisQuestion in arrQuestions)
{
writeThis += "<tr><td align='left'>" + arrQuestions[thisQuestion].evalQuestion + "<ul>\n";
for(thisAnswer in arrQuestions[thisQuestion].evalDistractors)
{
if(arrQuestions[thisQuestion].evalDistractors[thisAnswer].isSelected)
{
if(arrQuestions[thisQuestion].evalDistractors[thisAnswer].evalQuestionType == "text")
{
writeThis += "<li type='disk'>" + arrQuestions[thisQuestion].evalDistractors[thisAnswer].txtDisplay + "<br>\n";
}else{
writeThis += "<li type='disk'>" + arrQuestions[thisQuestion].evalDistractors[thisAnswer].txtValue + " " + arrQuestions[thisQuestion].evalDistractors[thisAnswer].txtDisplay + "<br>\n";
}
}else{
if(arrQuestions[thisQuestion].evalDistractors[thisAnswer].evalQuestionType == "text")
{
writeThis += "<li type='circle'>" + arrQuestions[thisQuestion].evalDistractors[thisAnswer].txtDisplay + "<br>\n";
}else{
writeThis += "<li type='circle'>" + arrQuestions[thisQuestion].evalDistractors[thisAnswer].txtValue + " " + arrQuestions[thisQuestion].evalDistractors[thisAnswer].txtDisplay + "<br>\n";
}
}
}
writeThis += "</ul></td></tr>";
}
writeThis += "</form></table>";
}
return(writeThis);
}
var arrQuestions = new Array();
var EvalID, thisID, intNumQuestions, thisOpt;
//Called by surveyDisplay, used to detect if this file is loaded
var isEvalLoaded = true;