home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2003 December
/
CMCD1203.ISO
/
Software
/
Shareware
/
Programare
/
toolkit
/
toolkitsetup.msi
/
Instal01.cab
/
_DD2FF7660D144EF3ADA8DC9AD8DE8805
< prev
next >
Wrap
Text File
|
2003-10-15
|
19KB
|
452 lines
var correctAnswers = lastPage = currentPage = 0;
var evalCompleted = false;
//Declare needed variables
var pageURL = hasQuery = queryString = queryParts = whatStep = nextStep = evalUniqueID = "";
var usedQuestions = new Array();
//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.evalRationale = '';
this.evalPointValue = 1;
this.evalDistractors = new Array();
this.addDistractor = setDistractor;
this.shuffleDistractors = randomizeDistractors;
this.answeredCorrectly = false;
var instrVerb = (this.evalQuestionType == "text") ? "Enter": "Select";
var instrNum = (this.evalQuestionType == "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.incorrectRationale = "";
this.isSelected = false;
this.txtInput = "";
return(this);
}
//Called by User in Lesson Page, used to retrieve the CopyRight statement
function txtCopyRight()
{
var theReturn = (copyright != "") ? copyright: " ";
return theReturn;
}
//Called by evalDisplay AND getStarted() to set all variables for the current page's use
function setEnvironment()
{
pageURL = parent.frames.evalFrame.location.href;
hasQuery = (pageURL.indexOf("?") > 0) ? true: false;
queryString = (hasQuery) ? pageURL.split("?")[1]: "";
whatStep = (getQueryStringValue("whatStep") == '') ? "overview": getQueryStringValue("whatStep");
nextStep = (whatStep == "next") ? "check": "next";
lastPage = (whatStep == "overview") ? 0: parseInt(getQueryStringValue("currentPage"));
currentPage = (whatStep == "next") ? lastPage+1: lastPage;
evalUniqueID = getQueryStringValue("evalUniqueID");
}
///Called by evalDisplay, evaluates the current state and draws the correct page
function getStarted()
{
setEnvironment();
var theReturn;
if(whatStep == "check")
{
var evalToCheck = rtnEvalQuestion(evalUniqueID, arrQuestions);
var answerSubmitted = getQueryStringValue(evalToCheck.name);
answerSubmitted = (answerSubmitted) ? answerSubmitted: answerSubmitted = " ";
setSelected(answerSubmitted, evalToCheck);
theReturn = writeAnswerHTML(evalToCheck, answerSubmitted);
evalCompleted = (intNumQuestions == currentPage) ? true: false;
}else{
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 evalDisplay to write the page title
function writePageTitle()
{
return(modTitle);
}
//Called by evalDisplay to write the "Question number of questions" 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 theReturn;
var arrQuestionAnswers = objQuestion.evalDistractors;
var arrSelectedAnswers = new Array();
var questionType = objQuestion.evalQuestionType;
if(theSelectedAnswers[1])
arrSelectedAnswers = theSelectedAnswers;
else
arrSelectedAnswers[0] = theSelectedAnswers;
var thisTestValue, theSetValue;
if(questionType == "text")
{
thisTestValue = new RegExp(objQuestion.evalDistractors[0].txtValue,"gi");
theReturn = arrSelectedAnswers[0].match(thisTestValue);
theReturn = (theReturn != null) ? true: false;
objQuestion.evalDistractors[0].isSelected = theReturn;
theSelectedAnswers = cleanText(theSelectedAnswers);
objQuestion.evalDistractors[0].txtInput = theSelectedAnswers;
}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() and writeAnswerHTML(), 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 objEvalQuestion(): shuffleDistractors() used to shuffle the order of the Distractors
function randomizeDistractors()
{
shuffle(this.evalDistractors);
}
//Called by randomizeDistractors() and inc_Questions, used to shuffle the order of Distractors or Evaluation Questions
function shuffle(arrToShuffle)
{
var i, j, tempHolder;
for(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 writeAnswerHTML(), used to return negative feedback for incorrect selections
function getIndivRationale(theDistractor)
{
var theReturn = "";
if(theDistractor.incorrectRationale)
if(theDistractor.isCorrect != theDistractor.isSelected)
theReturn = "<font color='#ff3300'> - " + theDistractor.incorrectRationale + "</font>\n";
return(theReturn);
}
//Called by writeAnswerHTML(), used to verify if answer provided for a given question is correct
function checkCorrect(objQuestion)
{
var theReturn = true, thisDistractor;
var arrQuestionDistractors = objQuestion.evalDistractors;
for(thisDistractor in arrQuestionDistractors)
if(arrQuestionDistractors[thisDistractor].isSelected != arrQuestionDistractors[thisDistractor].isCorrect)
theReturn = false;
objQuestion.answeredCorrectly = theReturn;
return(theReturn);
}
//Called by checkCorrect(), used to determine the correct values for the provided Question
function getCorrect(objEvlQuestion)
{
var arrCorrectAnswers = new Array();
var distractorItem;
for (distractorItem in objEvlQuestion.evalDistractors)
if(objEvlQuestion.evalDistractors[distractorItem].isCorrect)
arrCorrectAnswers[arrCorrectAnswers.length] = objEvlQuestion.evalDistractors[distractorItem].txtValue;
return(arrCorrectAnswers);
}
//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'><tr><td height=37><b>Question " + currentPage + ": </b>" + theEvalQuestion.evalQuestion + "<br clear='all'><br>\n" +
theEvalQuestion.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 evalAnswers = getCorrect(theEvalQuestion);
var multiAttribute = (evalAnswers.length > 1) ? " MULTIPLE size='" + (theEvalQuestion.evalDistractors.length + 1) + "'": "";
writeThis += "<tr><td> </td><td align='center' colspan=2 width='100%'>\n<select name='" + theEvalQuestion.name + "'" + multiAttribute + isDisabled + ">" +
"<option value=0>Select a value...</option>\n";
}
var distractorItem, isDisabled;
isDisabled = oneOrOther(findValInArr(theEvalQuestion.evalUniqueID, usedQuestions), ' disabled', '');
for(distractorItem in theEvalQuestion.evalDistractors)
{
switch(questionType)
{
case "select":
writeThis += "<option value='" + theEvalQuestion.evalDistractors[distractorItem].txtValue + "'>" +
theEvalQuestion.evalDistractors[distractorItem].txtDisplay + "</option>\n";
break;
case "checkbox":
case "radio":
writeThis += "<tr><td> </td><td valign='top'><input type='" + questionType + "' name='" + theEvalQuestion.name + "' value='" + theEvalQuestion.evalDistractors[distractorItem].txtValue + "'" + isDisabled + "></td><td width='100%'>" +
theEvalQuestion.evalDistractors[distractorItem].txtDisplay + "</td></tr>\n";
break;
case "text":
writeThis += "<tr><td> </td><td valign='top' width='100%'><input type='" + questionType + "' name='" + theEvalQuestion.name + "' value='' size=20" + isDisabled + "></td><td> </td></tr>\n";
break;
default:
break;
}
}
if(questionType == "select")
writeThis += "</select><br><br></td></tr>\n";
writeThis += "<input type='hidden' name='currentPage' value='" + currentPage + "'>\n" +
"<input type='hidden' name='whatStep' value='" + nextStep + "'>\n" +
"<input type='hidden' name='evalUniqueID' value='" + theEvalQuestion.evalUniqueID + "'>\n" +
"</td></tr>\n</table>\n</td></tr>\n<tr><td align='right'><input type='submit' name='theButton' value='Submit'></td></tr>\n" +
"</form></table>";
return(writeThis);
}
//Called by getStarted(), used to write the ANSWER pages
function writeAnswerHTML(theEvalQuestion, answerSubmitted)
{
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'><tr><td><b>Question " + currentPage + ": </b>" + theEvalQuestion.evalQuestion + "<br clear='all'><br>\n" +
"<table width='100%' align='center' cellpadding=3 cellspacing=0 border=0>";
if((questionType != "select") && (questionType != "text"))
writeThis += "<tr><td width=35 align='center'><img src='./images/correctanswer3.gif' width=35 height=37></td><td width=35 align='center'><img src='./images/youranswer3.gif' width=35 height=37></td><td width='100%'> </td></tr>\n";
if(questionType == "select")
writeThis += "<tr><td> </td><td align='center' valign='top'>\n<select name='" + theEvalQuestion.name + "' size=" + (theEvalQuestion.evalDistractors.length + 1) + " MULTIPLE>\n" +
"<option value=0>Select a value...</option>\n";
var distractorItem;
for(distractorItem in theEvalQuestion.evalDistractors)
{
switch(questionType)
{
case "select":
writeThis += "<option value='" + theEvalQuestion.evalDistractors[distractorItem].txtValue + "'" +
oneOrOther(theEvalQuestion.evalDistractors[distractorItem].isCorrect, ' selected', '') +
">" + theEvalQuestion.evalDistractors[distractorItem].txtDisplay + "</option>\n";
break;
case "checkbox":
case "radio":
writeThis += "<tr><td align='center' valign='top'><img src='./images/" + questionType +
oneOrOther(theEvalQuestion.evalDistractors[distractorItem].isCorrect, 'true', 'false') +
".gif' width=12 height=12></td><td align='center' valign='top'><img src='./images/" + questionType +
oneOrOther(theEvalQuestion.evalDistractors[distractorItem].isSelected, 'true', 'false') +
".gif'></td><td valign='top' width='100%'>" + theEvalQuestion.evalDistractors[distractorItem].txtDisplay +
getIndivRationale(theEvalQuestion.evalDistractors[distractorItem]) +
"</td></tr>\n";
break;
case "text":
writeThis += "<tr><td align='center'><img src='./images/correctanswer-horiz.gif' width=44 height=26></td>" +
"<td valign='top' width='100%'><input type='" + questionType + "' name='" + theEvalQuestion.name + "' value='" + cleanText(theEvalQuestion.evalDistractors[distractorItem].txtDisplay) + "' size=30 disabled></td><td> </td></tr>\n" +
"<tr><td align='center'><img src='./images/youranswer-horiz.gif' width=44 height=26></td>" +
"<td valign='top' width='100%'><input type='" + questionType + "' name='" + theEvalQuestion.name + "' value='" + cleanText(answerSubmitted) + "' size=30 disabled>" +
getIndivRationale(theEvalQuestion.evalDistractors[distractorItem]) +
"</td><td> </td></tr>\n";
break;
default:
break;
}
}
if(questionType == "select")
{
writeThis += "\n</select>\n</td><td align='center' valign='top'>\n<select name='" + theEvalQuestion.name + "' size=" + (theEvalQuestion.evalDistractors.length + 1) + " MULTIPLE>\n" +
"<option value='0'" +
oneOrOther(findValInArr(0, answerSubmitted), ' selected', '') +
">Select a value...</option>\n";
for(distractorItem in theEvalQuestion.evalDistractors)
{
writeThis += "<option value='" + theEvalQuestion.evalDistractors[distractorItem].txtValue + "'" +
oneOrOther(theEvalQuestion.evalDistractors[distractorItem].isSelected, ' selected', '') + ">" +
theEvalQuestion.evalDistractors[distractorItem].txtDisplay + "</option>\n";
}
writeThis += "</td></tr>\n";
}
writeThis += "</table>\n<br clear='all'>\n";
if(checkCorrect(theEvalQuestion))
{
writeThis += "<font color='#339900'><b>Correct.</b></font><br>\n";
if(!findValInArr(theEvalQuestion.evalUniqueID, usedQuestions))
correctAnswers++;
}else{
writeThis += "<font color='#ff3300'><b>Incorrect.</b></font><br>\n";
}
if(!findValInArr(theEvalQuestion.evalUniqueID, usedQuestions))
usedQuestions[usedQuestions.length] = theEvalQuestion.evalUniqueID;
writeThis += theEvalQuestion.evalRationale + "<br><br>\n";
var nextButtonText = (window.currentPage == window.intNumQuestions) ? "My Score": "Next";
writeThis += "<b>Click '" + nextButtonText + "' to continue</b><br><br>\n" +
"<input type='hidden' name='currentPage' value='" + currentPage + "'>\n" +
"<input type='hidden' name='whatStep' value='" + nextStep + "'>\n" +
"</td></tr>\n<tr><td align='right'><input type='submit' name='theButton' value='" + nextButtonText + "'></td>" +
"</tr>\n</form></table>";
return(writeThis);
}
//Called by getStarted(), used to write the OVERVIEW page
function writeOverviewHTML()
{
var writeThis = "<b>Overview of evaluation module</b><br clear='all'>\n" +
"<br>\n" +
"Three different types of questions may be used in this evaluation:\n" +
"<ol>\n" +
"<li>True/false</li>\n" +
"<li>Multiple-choice with a single correct answer</li>\n" +
"<li>Multiple-choice with more than one correct answer</li>\n" +
"</ol>\n" +
"For true/false and multiple-choice questions, use the mouse to make, or to change your selection(s)." +
"<br><br>\n" +
"As you complete each question, click on the 'Submit' button. " +
"When you are ready to move on to the next question, click on the 'Next' button. " +
"When you complete all of the questions, click the 'My Score' " +
"button to view the results of your evaluation." +
"<br><br>\n" +
"At this time, you can repeat the evaluation to try to improve your score, or you may submit " +
"your results as part of your final score." +
"<br><br>\n" +
"When you are ready to begin, click on the 'Next' button.\n" +
"<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 newIntNumQuestions = (intNumQuestions < 1) ? 1: intNumQuestions;
var finalScore = (correctAnswers / newIntNumQuestions * 100);
var txtFinalScore = finalScore.toString();
var intDecPos = txtFinalScore.indexOf(".");
if(intDecPos > 0)
if(txtFinalScore.length > 4)
txtFinalScore = txtFinalScore.substring(0, (intDecPos + 3));
var writeThis = "<br><table width='100%' align='center' cellpadding=0 cellspacing=0 border=0><form name='theForm'><tr><td><b>Results</b><br><br>" +
"Here are your results:<br><br>" +
"<div align='center'><b>You answered " + correctAnswers + " out of " + intNumQuestions + " correctly, " +
"giving you a score of " + txtFinalScore + "%.</b></div><br><br>";
if(useSCORM)
writeThis += "You can now choose either to submit this score or repeat the evaluation.<br><br>" +
"</td></tr>\n<tr><td align='right'><input type='button' name='restartEval' value='Repeat Evaluation' onclick='parent.frames.codeFrame.resetEval();'> " +
"<input type='button' name='submitEval' value='Submit Results' onclick='parent.frames.codeFrame.SubmitCompletion();'></td>" +
"</tr>\n</form></table>";
else
writeThis += "You can now print this score or repeat the evaluation.<br><br>" +
"</td></tr>\n<tr><td align='right'><input type='button' name='restartEval' value='Repeat Evaluation' onclick='parent.frames.codeFrame.resetEval();'>" +
"</td></tr>\n</form></table>";
return(writeThis);
}
//Called from Results page by USER to reset and restart the evaluation
function resetEval()
{
parent.location.reload(true);
}
//Called by writeQuestion() AND writeAnswer(), used to return thisOne if testVal is true or thatOne if false
function oneOrOther(testVal, thisOne, thatOne)
{
theReturn = (testVal) ? thisOne: thatOne;
return(theReturn);
}
//Called by writeQuestion() AND writeAnswer(), used to look for a specific value in an array- returns True if value is found
function findValInArr(inValue, arrObj)
{
var thisItem;
var theArr = new Array();
if(arrObj[0])
theArr = arrObj;
else
theArr[0] = arrObj;
for(thisItem in theArr)
if(inValue.toString() == theArr[thisItem].toString())
return(true);
return(false);
}
var arrQuestions = new Array();
var EvalID, thisID, thisOpt;
//Called by evalDisplay, used to detect if this file is loaded
var isEvalLoaded = true;