I've got this automated quiz working, but now the user's answers are not accurately graded according to the solutions. Can someone tell me what is wrong with my code from the attached js file and the html below?
<Head>
.
.
.
<script src="scripts/quiz1.js"></script>
<script>
/*Functions to score quiz.*/
function Engine(question, answer) {
yourAns[question]=answer;
}
</script>
</HEAD>
<BODY>
.
.
.
<!--Quiz Questions-->
<form name="myquiz">
<script>
for (i=1; i<question.length; i++) {
document.write (question[i] + "<br />");
document.write ("<input type='radio' value='a' name='choiceA' onClick='Engine(i, this.value)'> ");
document.write (choiceA[i] + "<br />");
document.write ("<input type='radio' value='b' name='choiceB' onClick='Engine(i, this.value)'> ");
document.write (choiceB[i] + "<br />");
document.write ("<input type='radio' value='c' name='choiceC' onClick='Engine(i, this.value)'> ");
document.write (choiceC[i] + "<br />");
document.write ("<input type='radio' value='d' name='choiceD' onClick='Engine(i, this.value)'> ");
document.write (choiceD[i] + "<br /><br />");
}
</script>
<input type=button onClick="score()" value="Well... How did I do?">
</form>
</BODY>
<Head>
.
.
.
<script src="scripts/quiz1.js"></script>
<script>
/*Functions to score quiz.*/
function Engine(question, answer) {
yourAns[question]=answer;
}
</script>
</HEAD>
<BODY>
.
.
.
<!--Quiz Questions-->
<form name="myquiz">
<script>
for (i=1; i<question.length; i++) {
document.write (question[i] + "<br />");
document.write ("<input type='radio' value='a' name='choiceA' onClick='Engine(i, this.value)'> ");
document.write (choiceA[i] + "<br />");
document.write ("<input type='radio' value='b' name='choiceB' onClick='Engine(i, this.value)'> ");
document.write (choiceB[i] + "<br />");
document.write ("<input type='radio' value='c' name='choiceC' onClick='Engine(i, this.value)'> ");
document.write (choiceC[i] + "<br />");
document.write ("<input type='radio' value='d' name='choiceD' onClick='Engine(i, this.value)'> ");
document.write (choiceD[i] + "<br /><br />");
}
</script>
<input type=button onClick="score()" value="Well... How did I do?">
</form>
</BODY>
Comment