Creating An Online Quiz
There seems to be a boom in the online quiz, similar to those in magazines it appears that the Internet community are hooked on answering them. Rather than look for the systems which other people are using or directly ripping off their code I thought that making my own quiz would be a simple first project.
The quiz itself is not, at this exact moment in time, finished so the theme, questions and graphics are still a secret (shhh). Hopefully this documenting of the making of my quiz will help you to write your own.
A File To Store The Questions In
The first decision I made was that I wanted this code to be easy to modify and add to, I did not want the writer to be limited to the amount of questions he could ask and I wanted a central place to add new questions and information.
The format of the code is pretty simple;
First we set a variable which will later be used to hold the score of the person taking the test;
The next variable sets how many questions are in the quiz;
The following six arrays are defined to contain one element for each question;
var quz = new Array(qnum);First choice.
var ansA= new Array(qnum);Second choice.
var ansB = new Array(qnum);Points given for choosing the first answer.
var valA = new Array(qnum);Points given for choosing the second answer.
var valB = new Array(qnum);Choice made by testee.
var ansgiven = new Array(qnum);
quz="1 + 1 = ?"; ansA="2"; ansB="1"; valA="1"; valB="0"; ansgiven="";