// cameron young - updates Jan 2003
function getScore(form) {
  var score = 0;
  var currElt;
  var currSelection;
  var incorrect = ""; <!-- string variable to hold the list of incorrect questions -->
  var allDone = 0; <!-- variable to see  if all questions have been answered -->
  var questionIncorrect= new Array(numQues); // array to store the incorrect questions
  
for (i=0; i<numQues; i++) {
    currElt = form.elements[i];
    currSelection = currElt.selectedIndex;

if (currElt.options[currSelection].value != "") {
      allDone++;
    }


    if (currElt.options[currSelection].value == answers[i]) {
      score++;
      questionIncorrect[i] = ""; // if the answer is correct, put a place holder in the array to prevent undefined
    }

	else{   <!-- if the answer is not correct: -->
		questionIncorrect[i]= i+1; // write the number of the incorrect question into the array
	}

  }

<!-- check to see if all the questions have been done -->
	if(allDone != numQues){
		alert("You have not answered all the questions")
	return;
	}
  
  score = Math.round(score/numQues*100);
  form.percentage.value = score + "%";

  var correctAnswers = "";
  for (i=1; i<=numQues; i++) {
    correctAnswers += i + ". " + answers[i-1] + "\r\n";
  }

//build the string for the incorrect questions 
  var incorrectAnswers = "";

  	for (i=1; i<=numQues; i++) {
    	incorrectAnswers  += questionIncorrect[i-1] +" ";
  	}	


form.solutions.value = correctAnswers;
form.incorrect.value = incorrectAnswers; // prints the incorrect answers
}
