// cameron young - updated Jan 2003
function getScore(form) {
  var score = 0;
  var incorrect = ""; <!-- string variable to hold the list of incorrect questions -->
  var allDone = "0"; <!-- variable to store the done flag -->
  var questionIncorrect= new Array(numQues); // array to store the incorrect questions
  for (i=0; i<numQues; i++) {
    	
	<!-- check to see if the field is blank -->
	<!-- if it is - set the flag  -->

	if (form.elements[i].value == "") {
      	allDone++;
    	}

	if (form.elements[i].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 != 0){
		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
}
