Back

Quiz Description, and Customisation Instructions

This quiz can be completely customised. It only needs a set of questions, with answers, a "jpg" image and 4 changes to the coding.

This quiz contains the following files:

  1. index.htm
  2. customise.htm
  3. random_numbers.js
  4. quiz_questions.js
  5. display_questions.js
  6. check_answer.js
  7. mail_result.js
  8. Images

1. index.htm

This is the main file to run the quiz. No changes need to be made to this file.

2. customise.htm

This file, no changes need to be made to this file.

3. random_numbers.js

This script is actioned when the quiz is started. The only customisable part of this script is the variable requiredNos. This sets the value for how many questions there are to answer in the quiz.

The variables value must be equal to or below the total number of questions you have in your quiz. (<= question.length).

The value set for this quiz, var requiredNos = 5;

Only 1 change needs to be made to this file.

4. quiz_questions.js

This script contains all the questions used in the quiz. It also contains four possible answers and the correct answer, for all the questions.

Your questions must follow the same format and naming conventions, for the quiz to work. This quiz can have as many questions as you like.

The format used is as follows, changes that can be made: (bold italics)

question = new Array();

question[0] = new Array(); //Question 0 Array
question[0][0] = "Can you name Barts best friend?"; // Question 0
question[0][1] = "a) Nelson."; // Possible answer a)
question[0][2] = "b) Milhouse."; // Possible answer b)
question[0][3] = "c) Ralph."; // Possible answer c)
question[0][4] = "d) Smithers."; // Possible answer d)
question[0][5] = "images/0.jpg"; // Image used
question[0][6] = "b"; // Answer to question

question[1] = new Array(); //Question 1 Array
question[1][0] = "What would you buy from this Simpsons character?"; // Question 1
question[1][1] = "a) Groceries."; // Possible answer a)
question[1][2] = "b) Insurance."; // Possible answer b)
question[1][3] = "c) Comics."; // Possible answer c)
question[1][4] = "d) Beer."; // Possible answer d)
question[1][5] = "images/1.jpg"; // Image used
question[1][6] = "c"; // Answer to question

question[2] ect.
question[3] ect.

5. display_questions.js

This script uses the randomly generated numbers, and then writes a new page containing the questions and possible answers. It also contains a text box to enter your name and buttons to check your answers, and to e-mail your score.

Changes that can be made: (bold italics)
Line 5: document.writeln("<title>Nick Miles - Simpsons Quiz</title>");
Line 11: document.writeln("<h2>Simpsons Quiz</h2>");
Line 51: document.writeln("<form name='the_quiz' method='post' action='mailto:nick-miles@ntlworld.com'>");

Only 3 changes need to be made to this file.

6. check_answer.js

This script checks that the user has entered a name, then checks the answers to the randomly set questions. When checked, the user is prompted to which questions they have got right or wrong. A score is given in the format:

name scored x out of y = z %

No changes need to be made to this file.

7. mail_result.js

This script checks out if the user has checked their answers, if so then the users name and score is e-mailed to the address on line 51 of display_questions.js.

Line 51: document.writeln("<form name='the_quiz' method='post' action='mailto:nick-miles@ntlworld.com'>");

No changes need to be made to this file.

Images

The quiz images used, are numbered according to their position in the file quiz_questions.js.

So image "0.jpg" relates to:

question[0] = new Array(); //Question 0 Array
question[0][5] = "images/0.jpg"; // Image used

And "9.jpg" relates to:

question[9] = new Array(); //Question 9 Array
question[9][5] = "images/9.jpg"; // Image used