javascript quiz

javascript quiz

I am new to javascript but am trying to incorporate an interactive self grading quiz in my website

I recently saw th following code as a way of implementing it but I don't quite understand how it works;



< style type="text/css">
< !--
.bgclr {background-color: white; color: black; font-weight: bold;}
-->
< /style>

< script language="JavaScript">


< !-- Begin
// Insert number of questions
var numQues = 4;

// Insert number of choices in each question
var numChoi = 3;

// Insert number of questions displayed in answer area
var answers = new Array(4);

// Insert answers to questions
answers[0] = "United Nations Mine Action service";
answers[1] = "110 million";
answers[2] = "12,000";
answers[3] = "Apopo";

function getScore(form) {
var score = 0;
var currElt;
var currSelection;
for (i=0; i<numQues; i++) {
currElt = i*numChoi;
for (j=0; j<numChoi; j++) {
currSelection = form.elements[currElt + j];
if (currSelection.checked) {
if (currSelection.value == answers ) {
score++;
break;
}
}
}
}
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";
}
form.solutions.value = correctAnswers;
}
// End -->
< /script>

< /HEAD>


< BODY>

< h3>Landmine Quiz</h3>
< label> This form contains the 4 questions for the quiz with 3 possible choices per question </label>

< form name="quiz">
1. What does UNMAS stand for?
< ul style="margin-top: 1pt">
< label for="quiz question">Question one:</label>
<li><input type="radio" name="q1" value="United National Mine Action Service">United National Mine Action service</li>
<li><input type="radio" name="q1" value="United Nations Mine Action service">United Nations Mine Action service</li>
<li><input type="radio" name="q1" value="United Nations Mine awareness service">United Nations Mine awareness service</li>
< /ul>

2. How many landmines exsist in the world?
< ul style="margin-top: 1pt">
<li><input type="radio" name="q2" value="120 million">120 million</li>
<li><input type="radio" name="q2" value="60 million">60 million</li>
<li><input type="radio" name="q2" value="110 million">110 million</li>
< /ul>
3. How many people are killed by landmines anually?
< ul style="margin-top: 1pt">
<li><input type="radio" name="q3" value="30 thousand">30 thousand</li>
<li><input type="radio" name="q3" value="12,000">12,000</li>
<li><input type="radio" name="q3" value="5,000">5,000</li>
< /ul>
4. An example of an NGO involved in Mine Clearance is?
< ul style="margin-top: 1pt">
<li><input type="radio" name="q4" value="Apopo">Apopo</li>
<li><input type="radio" name="q4" value="United Nations">United Nations</li>
<li><input type="radio" name="q4" value="Care">Care</li>
< /ul>

< input type="button" value="Get score" onClick="getScore(this.form)">
< input type="reset" value="Clear answers">
< p> Score = <strong><input class="bgclr" type="text" size="5" name="percentage" disabled></strong><br><br>
Correct answers:<br>
< textarea class="bgclr" name="solutions" wrap="virtual" rows="4" cols="30" disabled>
< /textarea>
< /form>




From my understanding the script checks th number of write answers and wring answers take sthe number of write answers multiples them by 100 and divides them by the total number of questions to get a percentage? Can anyone help me to understand this script more?