I created a quiz with 3 different level in which you need to get 3 points to access the next one. I was wondering if it is possible to carry those points to the level in order to give a final score at the end.
<script language="JavaScript">
var ans = new Array;
var done = new Array;
var score = 0;
ans[1] = "c";
ans[2] = "d";
ans[3] = "a";
ans[4] = "b";
ans[5] = "a";
function Engine(question, answer) {
if (answer != ans[question]) {
if (!done[question]) {
done[question] = -1;
alert("Wrong!\n\nYour score is now: " + score);
}
else {
alert("You already answered that question!");
}
}
else {
if (!done[question]) {
done[question] = -1;
score++;
alert("Correct!\n\nYour score is now: " + score);
}
else {
alert("You already answered that one");
}
}
}
function NextLevel () {
if (score > 5) {
alert("Cheater!");
}
if (score >= 0 && score <= 0) {
alert("Sorry! You answered none of the question correctly")
}
if (score >= 3 && score <= 3) {
alert("Congratulation! You answered 3 questions correctly.")
(self.location="quiz2.htm")
}
if (score >= 4 && score <= 4) {
alert("Congratulation! You answered 4 questions correctly.")
(self.location="quiz2.htm")
}
if (score >= 1 && score <= 1) {
alert("Sorry! you need to answer 2 more questions correctly to move on")
}
if (score >= 2 && score <= 2) {
alert("Sorry! You need to answer 1 more questions correctly to move on")
}
if (score >= 5 && score <= 5) {
alert("Congratulation! You answer all the questions correctly!")
(self.location="quiz2.htm")
}
}
// End -->
</SCRIPT>
<script language="JavaScript">
var ans = new Array;
var done = new Array;
var score = 0;
ans[1] = "c";
ans[2] = "d";
ans[3] = "a";
ans[4] = "b";
ans[5] = "a";
function Engine(question, answer) {
if (answer != ans[question]) {
if (!done[question]) {
done[question] = -1;
alert("Wrong!\n\nYour score is now: " + score);
}
else {
alert("You already answered that question!");
}
}
else {
if (!done[question]) {
done[question] = -1;
score++;
alert("Correct!\n\nYour score is now: " + score);
}
else {
alert("You already answered that one");
}
}
}
function NextLevel () {
if (score > 5) {
alert("Cheater!");
}
if (score >= 0 && score <= 0) {
alert("Sorry! You answered none of the question correctly")
}
if (score >= 3 && score <= 3) {
alert("Congratulation! You answered 3 questions correctly.")
(self.location="quiz2.htm")
}
if (score >= 4 && score <= 4) {
alert("Congratulation! You answered 4 questions correctly.")
(self.location="quiz2.htm")
}
if (score >= 1 && score <= 1) {
alert("Sorry! you need to answer 2 more questions correctly to move on")
}
if (score >= 2 && score <= 2) {
alert("Sorry! You need to answer 1 more questions correctly to move on")
}
if (score >= 5 && score <= 5) {
alert("Congratulation! You answer all the questions correctly!")
(self.location="quiz2.htm")
}
}
// End -->
</SCRIPT>