Sry double post I'm on phone lol
Here is the whole script almost... I want to make the review page display the
quiz you just took and the answers you chose/what you got wrong and right.
This is the hardest part for me so far.
<script type="text/JavaScript">
function Questions(divname) {
this.QText * = new Array(11); // The questions
this.QAnswer = new Array(11); // The correct answers
this.QChoice = new Array(44); // The possible multi-choice values
this.thisAns = new Array(44); // The answers for this page
this.Answer *= new Array(10); // The user's answers
this.anchor = document.getElementById(divname);
this.QText[0] = "?";
this.QText[1] = "?";
this.QText[2] = "?";
this.QText[3] = "?";
this.QText[4] = "?";
this.QText[5] = "?";
this.QText[6] = "?";
this.QText[7] = "?";
this.QText[8] = "?";
this.QText[9] = "?";
this.QText[10] = "?";
this.QChoice[0] = "2";
this.QChoice[1] = "2";
this.QChoice[2] = "3";
this.QChoice[3] = "3";
this.QChoice[4] = "B";
this.QChoice[5] = "r";
this.QChoice[6] = "B";
this.QChoice[7] = "N";
this.QChoice[8] = "2";
this.QChoice[9] = "2";
this.QChoice[10] = "3";
this.QChoice[11] = "d";
this.QChoice[12] = "A";
this.QChoice[13] = "A";
this.QChoice[14] = "b";
this.QChoice[15] = "A";
this.QChoice[16] = "f";
this.QChoice[17] = "P";
this.QChoice[18] = "C";
this.QChoice[19] = "U";
this.QChoice[20] = "I";
this.QChoice[21] = "I";
this.QChoice[22] = "I";
this.QChoice[23] = "I";
this.QChoice[24] = "3";
this.QChoice[25] = "3";
this.QChoice[26] = "3";
this.QChoice[27] = "3";
this.QChoice[28] = "z";
this.QChoice[29] = "z";
this.QChoice[30] = "z";
this.QChoice[31] = "z";
this.QChoice[32] = "z";
this.QChoice[33] = "z";
this.QChoice[34] = "z";
this.QChoice[35] = "z";
this.QChoice[36] = "r";
this.QChoice[37] = "r";
this.QChoice[38] = "r";
this.QChoice[39] = "2";
this.QChoice[40] = "F";
this.QChoice[41] = "F";
this.QChoice[42] = "F";
this.QChoice[43] = "A";
this.QAnswer[0] = 1;
this.QAnswer[1] = 4;
this.QAnswer[2] = 2;
this.QAnswer[3] = 2;
this.QAnswer[4] = 1;
this.QAnswer[5] = 2;
this.QAnswer[6] = 3;
this.QAnswer[7] = 3;
this.QAnswer[8] = 4;
this.QAnswer[9] = 4;
this.QAnswer[10] = 1;
}
Questions.prototype.generateQuiz = function() {
var QCount = 0;
var QNumber = 0;
var QUsed = new Array(11);
for (QCount=0; QCount<11; QCount++) {
QUsed[QCount] = 1; // Marked as available
}
this.anchor.innerHTML = "";
var HTMLBlob = "<table>";
for (QCount=0; QCount<10; ) {
QNumber = Math.floor(11 * Math.random());
if (1 == QUsed[QNumber]) { // Still available?
HTMLBlob += this.AddQuestion(QNumber, QCount);
QCount++;
QUsed[QNumber] = 0; // Marked as unavailable
}}
HTMLBlob += "</table>";
this.anchor.innerHTML = HTMLBlob;
}
Questions.prototype.nukeExistingQuiz = function() {
if (null != this.anchor && null != this.anchor.childCount) {
while (this.anchor.childCount > 0) {
this.anchor.removeChild(this.anchor.childNodes[0]);
}}}
Questions.prototype.AddQuestion = function(QNum, EntryNum) {
var Ix;
var HTMLBlob = "<tr><td><input type=\"checkbox\" id=\"check" + EntryNum + "\"
checked=\"checked\"></td><td><br/>"
+ "<strong>" + this.QText[QNum] + "</strong></td><td><select id=\"answer" +
EntryNum + "\" size=\"1\">"
+ "<option selected=\"selected\" value=\"0\">-- Select an answer --</option>"
for (Ix=0; Ix<4; Ix++) {
HTMLBlob = HTMLBlob + "<option value=\"" + Ix + "\">" +
this.QChoice[QNum*4+Ix] + "</option>";
}
HTMLBlob = HTMLBlob + "</select></td></tr>";0
this.thisAns[EntryNum] = this.QAnswer[QNum]; * // this variable this.thisans
is the answeres user chose
return HTMLBlob;
}
Questions.prototype.AreQuestionsAnswered = function() {
var unanswered = 0;
for (var Ix=0; Ix<10; Ix++) {
this.Answer[Ix] = document.getElementById("answer" + Ix).selectedIndex;
if (this.Answer[Ix] == 0) {
unanswered++;
}}
return unanswered;
}
Questions.prototype.ScoreIt = function() {
var score = this.AreQuestionsAnswered();
if (score > 0) {
alert("You have left " + score + " questions unanswered. Please try again.");
document.getElementById("submit").disabled = false;
score = 0;
}
else {
for (var Ix=0; Ix<10; Ix++) {
if (this.Answer[Ix] == this.thisAns[Ix]) {
document.getElementById("check" + Ix).checked = true;
score++;
Ix = Ix+1
alert("you got question # " + Ix + " correct");
Ix = Ix-1
totalscore = score
}
else {
document.getElementById("check" + Ix).checked = false;
totalscore = score
}}
document.getElementById("submit").disabled = true;
var buttonToShow = document.getElementById("invisiButton");
buttonToShow.style.visibility = "visible";
var buttonToShow = document.getElementById("invisiButtona");
buttonToShow.style.visibility = "visible";
var buttonToShow = document.getElementById("invisiButtonb");
buttonToShow.style.visibility = "visible";
alert("You scored a " + score * 10 + "% on this quiz.");
if (totalscore <= 6 ) {
window.open("torefrences.html");
}}}
Questions.prototype.review = function() {
reviewscore = totalscore
document.location.href = "review.html";
}
function opento() {
document.location.href = "torefrences.html";
}
</script>
</head><body>
<div id="quizblock"></div>
<script type="text/JavaScript">
var MyQuiz = new Questions("quizblock");
MyQuiz.generateQuiz();
</script><br>
<button class='clickable' name='submit' onMouseOver='change(this,"btnFocus")'
onMouseOut='change(this,"normBtn")' id='normBtn' onClick="MyQuiz.ScoreIt();"
style="margin-right: 3px">Submit</button>
<button class='clickable' name='Test' onMouseOver='change(this,"btnFocus")'
onMouseOut='change(this,"normBtn")' id='normBtn' onClick="location.href='test
start page.html';" style="margin-right: 3px">Return to start</button>
<button class='clickable' name='invisiButton'
onMouseOver='change(this,"btnFocus")' onMouseOut='change(this,"normBtn")'
id='normBtn' onClick="MyQuiz.review();" style="visibility:hidden;"
style="margin-right: 3px">Review</button>
<button class='clickable' name='invisiButtona'
onMouseOver='change(this,"btnFocus")' onMouseOut='change(this,"normBtn")'
id='normBtn' onClick="document.location.reload(true);"
style="visibility:hidden;" style="margin-right: 3px">Retake Quiz</button>
<button class='clickable' name='invisiButtonb'
onMouseOver='change(this,"btnFocus")' onMouseOut='change(this,"normBtn")'
id='normBtn' onClick="opento();" style="visibility:hidden;"
style="margin-right: 3px">T.O. Refrences</button>
</FORM>
</body>
<p id="footnote" align="center">
</HEAD><BODY></html>