Scenario 4

Your Code
var totalQuestions = 250;
var numCorrect = 0;
//set the point values for each type of result
var correctValue = 1;
var incorrectValue =
;
var skippedValue =
;
for (i=0; i<=totalQuestions; i++){
result = GetValue ( "cmi.
."+i+".
" );
if(result == "correct")
{
numCorrect++;
}
else if( result == "incorrect")
{
numIncorrect++;
}
else
{
numSkipped++;
}
}
//calculate the raw score
rawScore = numCorrect/totalPossible;
//set the raw score
SetValue ( "cmi.
.
", rawScore );
//calculate the points received
correctPoints = numCorrect * correctValue;
skippedPoints = numSkipped * skippedValue;
incorrectPoints = numIncorrect * incorrectValue;
totalPointsPossible = totalQuestions * correctValue;
//calculate scaled score
scaledScore = (correctPoints + skippedPoints + incorrectPoints) / totalPointsPossible;
//set the scaled score
SetValue ( "cmi.
.
",
);
Code Example
var totalQuestions = 250;
var numCorrect = 0;
//set the point values for each type of result
var correctValue = 1;
var incorrectValue = -.25;
var skippedValue = 0;
for (i=0; i<=totalQuestions; i++){
result = GetValue ( "cmi.interactions."+i+".result" );
if(result == "correct")
{
numCorrect++;
}
else if( result == "incorrect")
{
numIncorrect++;
}
else
{
numSkipped++;
}
}
//calculate the raw score
rawScore = numCorrect/totalPossible;
//set the raw score
SetValue ( "cmi.score.raw", rawScore );
//calculate the points received
correctPoints = numCorrect * correctValue;
skippedPoints = numSkipped * skippedValue;
incorrectPoints = numIncorrect * incorrectValue;
totalPointsPossible = totalQuestions * correctValue;
//calculate scaled score
scaledScore = (correctPoints + skippedPoints + incorrectPoints) / totalPointsPossible;
//set the scaled score
SetValue ( "cmi.score.scaled", scaledScore );