When testing the program it is much easier
to be able to read the XML locally, and
then when it is on the WWW, the XML file
is read from a WWW site. This can be achieved
by testing to see if the XML object has
been loaded. This is achieved with:
urlXML
= new XML();
urlXML.onLoad = convertXML;
urlXML.load("questions.xml");
if (!XML.loaded)
urlXML.load("http://buchananweb.ac.uk/questions.xml");
The application can be then enhanced
by creating a symbol for the multiple
choice question. In this a symbol is created
and is named question. The text boxes
created are named title, q1, q2, q3 and
q4. A button on the main page will then
have the action of:
The random() function selects a random
number, with the maximum of the number
of questions in the XML file. The symbol
is then loaded with the values from the
arrays. The new application is:
Next proper questions
can be added to the questions, with:
<?xml
version="1.0" encoding="iso-8859-1"?><!DOCTYPE
questions>
<questions>
<quest id="000001">
<title> How many bits are
in a nibble:</title>
<q1>4</q1>
<q2>8</q2>
<q3>16</q3>
<q4>32</q4>
<q5>Answer a5</q5>
<correct>q1</correct>
<level>1</level>
</quest>
<quest id="000002">
<title>Which unit represents
1024 bytes:</title>
<q1>B</q1>
<q2>KB</q2>
<q3>MB</q3>
<q4>GB</q4>
<q5>Answer b5</q5>
<correct>q1</correct>
<level>2</level>
</quest>
<quest id="000003">
<title>Which unit represents
bits per second:</title>
<q1>bps</q1>
<q2>bs</q2>
<q3>bit</q3>
<q4>bsec</q4>
<q5>Answer c5</q5>
<correct>bps</correct>
<level>3</level>
</quest>
<quest id="000004">
<title> Which unit represents
a billion bytes:</title>
<q1>B</q1>
<q2>KB</q2>
<q3>MB</q3>
<q4>GB</q4>
<q5>Answer d5</q5>
<correct>q4</correct>
<level>4</level>
</quest>
<quest id="000005">
<title>Which of the following
is 1GB:</title>
<q1>1024KB</q1>
<q2>100KB</q2>
<q3>1024MB</q3>
<q4>1000MB</q4>
<q5>Answer e5</q5>
<correct>q1</correct>
<level>5</level>
</quest>
<quest id="000006">
<title> Which format is used
for humans to easily interpret binary
digits:<title>
<q1>Hexadecimal</q1><
<q2>Decimal</q2>
<q3>WWW</q3>
<q4>TCP/IP </q4>
<q5> </q5>
<correct>q1</correct>
<level>5</level>
</quest>
<quest id="000007">
<title>Which is the following
is not a data processing method:<title>
<q1>Prediction </q1><
<q2>Mathematical </q2>
<q3>Data sampling </q3>
<q4>Thresholding </q4>
<q5>TCP/IP</q5>
<correct>q2</correct>
<level>5</level>
</quest>
<quest id="000006">
<title> What type of computer
was popular in the 1960s based on:<title>
<q1>Values</q1><
<q2>Transistorized</q2>
<q3>Integrated circuit</q3>
<q4>Systems-on-a-chip</q4>
<q5>TCP/IP</q5>
<correct>q1</correct>
<level>5</level>
</quest>