Scenario 4

Programming raw scores can take quite a bit of code. For the next scenario, we did the logic for you.

The State has asked you to develop a standardized test as part of a new educational initiative. The test has 250 multiple-choice questions. If test-takers get a question right, they get a point. If they get a question wrong, they lose a 1/4 point. And if they skip a question, they get 0 points.

6. Complete the code below to calculate the raw and scaled scores:

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. . ", );

Click Submit after you complete the code.