Byers, J.A. 1999. Interactive Learning Using Expert System Quizzes on the Internet. Educational Media International 36:191-194. pdf

John A. Byers, Alnarp, Sweden


English: HTML and JavaScript web pages interactively pose questions at random with multiple choice answers. Questions are ranked for difficulty based on prior student tests. During a quiz, the system tracks the percentage of correct answers and adjusts the difficulty of questions appropriately. A compiled BASIC program allows teachers to make specialized web quizzes from text files of questions and answers, without the need to know HTML, JavaScript, and BASIC programming languages.
Review the operation at
Download the Software at
Français: HTML et les pages Web du script JAVA posent de façon interactive des questions au hasard avec des questions à choix multiples. Sur la base de tests passés antérieurement par les étudiants, les questions sont classées selon la difficulté. Lors d'une interrogation, le système localise les difficultés et ajuste les questions en conséquence. Un programme BASIC permet aux maitres de faire des interrogations spécialisées à partir de cartes de questions et réponses, sans le besoin de connaitre les langages de programmation HTML, JavaScript et BASIC.

Deutsch: HTML und JavaScript Webseiten stellen zufällig ausgewählte Fragen mit Multiple-Choice-Antworten interaktiv zusammen. Die Fragen werden auf Grund der Ergebnisse vorhergegangener Tests mit anderen Studenten nach Schwierigkeitsgrad geordnet. Das System stellt den Prozentsatz richtiger Antworten während der Durchführung einer Befragung fest und bewertet die Schwierigkeitseinstufung entsprechend neu. Ein kompiliertes BASIC Programm ermöglicht Lehrern nun, selbst spezifische textbasierte Frage -und Antwort-Programme zu entwickeln, ohne selbst HTML, JavaScript oder Basic Programmierkenntnisse besizen zu müssen.


Interactive quizzes are not common on the Internet because they require use of either embedded scripting languages, executable programs, or CGI server-side systems. Most interactive web pages use either JavaScript or Java programming languages that are similar to C/C++ languages (Goodman 1996; Stanek 1996). The JavaScript language is understood by all versions of Netscape (3.0 or greater) and Internet Explorer (4.0 or greater) and requires Windows 3.1 or higher on IBM-compatible computers. Java is the more powerful and complicated of the two languages but must be compiled into an "applet" and requires 32-bit Internet browsers on Windows NT or 95/98. Of the two then, JavaScript is understood by more browser versions and computer operating systems (Goodman 1996).

HTML (hypertext markup language) files of the Internet are text files that may contain JavaScript. An Internet browser such as Netscape loads the HTML page from the Internet (or from the computer's disk) and looks for JavaScript code. If any is found then the browser's JavaScript interpreter is ready to run and perform various tasks directed by the user's mouse clicks or keyboard input. Since an HTML file and its JavaScript code are all text that can be printed by the computer's keyboard, it is possible to combine a database of text with the JavaScript and HTML code to make unique interactive databases or quizzes. Virtually any quiz or test can be compiled in a word processor and saved as a text file. The compilation of the HTML pages with appropriate JavaScript and specific text of questions/answers is performed by an executable program (QUIZMAKE.EXE) compiled from QuickBASIC code. The software system described here will allow teachers and students in practically any subject to make interactive expert systems of quizzes on the Internet.

Building a database of questions and answers.

Students or the teacher make up multiple choice tests of five answers per question and give these to other students. Based on the success in answering questions, each is ranked for difficulty from 1 (easy) to 10 (difficult). The text file of questions and answers can be in any order although at least one question of each of the 10 difficulty levels must be present. It also is better to have a balance of questions among the difficulty levels but this is not required. Also, the more questions the better since this will mean that the same question is not picked too often. The text file of questions has a specific format as shown in Figure 1. There must be five answers < a> to < e> although some can be left blank except for the label. It is best to have five answers because if only two filled-in answers are used, a student on average should get 50% correct without any knowledge, and thus the difficulty levels less than 5 would rarely apply.

Fig. 1. Text file of the format codes, at left of each line in brackets, and text of questions and answers.

< ?> any question of 1 or 2 lines of about 80 characters, there could even be 3
< ?> lines but one may need to scroll, so it is better to just have 2 lines.
< level> 6
< answer> c
< a> a possible answer [a]; Note the number 6 under the < level> , this means the
< b> a second answer [b]; difficulty level of the question (from 1 to 10).
< c> a third possible answer - which in this case is the correct one.
< d> the fourth possible answer, keep each answer to a line of ó 83 characters.
< e> the fifth possible answer
< ?> The second question of 1 or 2 lines of about 80 characters.
< ?> second question continued...
< level> 3
< answer> a
< a> a possible answer [a], in this case the correct answer, as indicated above
< b> a second answer [b]
< c> a third possible answer
< d> the fourth possible answer
< e> the fifth possible answer

Integrating text files of questions and answers with the JavaScript-HTML pages.

A compiled QuickBASIC program, QUIZMAKE.EXE, takes a text file of question sets made above, each with five possible answers, a correct answer, as well as the difficulty rating for each question (1 to 10), and incorporates this into several HTML files containing JavaScript. Netscape will not function if the size of JavaScript memory arrays with text strings are larger than 32,000 bytes (my experience). Therefore, a large text file of questions and answers must be split into pieces of less than 32K (including all HTML and JavaScript code). It turns out that about 40 questions and 200 answers of maximum 80 characters each will easily fit within the 32K limit. The compiled program divides any text file database into the necessary number of web pages and also incorporates the JavaScript code. The main control page is also made each time the database is expanded or modified since the number of pages and questions in each page (40 except the last page) must be fixed when the pages are written.

QUIZMAKE.EXE requires the following inputs:

(1) the name of the text file with questions
(2) up to five letters for the parent name of the quiz system, e.g. "flowr"
(3) the title of the quiz.

In addition, the name of the HTML file that will be visited by the browser upon exiting from the quiz is input.

The HTML link to this page can be relative (the page must be on the same server) or absolute (another URL "http://www" address, Stanek 1996). Only relative links will work when running the quiz from the hard disk. For example, to go to the menu in an upper directory use, "../menu.htm", or if in the same directory use, "menu.htm", while if in a subdirectory named java use, "java/menu.htm". Finally, a number from 1 to 365 is input to control how many days the browser will remember the test status.

The compiled program then loads QUIZ.TXT and makes the web frame setup page, flowr-f.htm, using the parent name example above. This file is the page that is linked to from the main menu page. Flowr-f would then have the names of the three frame HTML files: flowr-1.htm, flowr-2.htm, and flowr-3.htm. Flowr-1.htm would contain the main control and expert system code (made from QUIZ1.TXT) and be shown in the upper left rectangular frame (Fig. 2). Flowr-2.htm is just the answer frame in the upper right corner (Fig. 2) while flowr-3.htm (made from QUIZ-3.TXT) shows blank answers and buttons and gives some instructions on how to begin. This frame during testing will look similar but contain answers in the bottom frame (Fig. 2).

Fig. 2. Picture of Netscape with interactive expert quiz

Before flowr-1.htm can be completed, the text file with the questions and answers must be read to calculate the required number of web pages to hold 40 questions per page so this information can be put into flowr-1.htm. The text file of questions and answers is read again and incorporated at 40 questions/answers per page into pages named, flowr1.htm, flowr2.htm etc. for as many as required. The JavaScript code for these pages is read from the file QUIZP.TXT and incorporated by QUIZMAKE.EXE. Thus, all files are made automatically except the text file with specific questions and answers.

All the .htm files would then be uploaded to the Internet server so that anyone could use the system via the Internet. Alternatively, one can use the system without an Internet connection via the hard drive. Simply open the flowr-f.htm file in the appropriate directory using Netscape. This "open file" facility is located in the "file" menu at the top left of Netscape 3.0, or "open page" then "choose file" in Netscape 4.5.

The JavaScript and HTML code.

Three frames are used, with the top left frame controlling which question and answer frame in the bottom will be shown (Fig. 2). The bottom frame determines whether the answer chosen is correct and returns this to the top left frame as well as updates the top right frame with the selection and whether it is right or wrong. This means that data must be transferred between HTML frames and pages. This can only be done by using "cookies" (Goodman 1996), a way of storing data on the user's hard drive in the file COOKIES.TXT using the Netscape browser. The expiration date of the information in the cookies file is set up to 365 days in the future each time a question is posed and answered. Therefore, the test status is saved on the individuals computer hard disk between Internet sessions. However, a reset button allows the user to begin the quiz again.

The expert system in the top left frame selects questions with ratings equal to the proportion of questions answered correctly. Thus, if 5 of 12 questions have been answered right, the difficulty would be Math.floor(5/12 * 10)+1 = 5. The "Math.floor" means to round off the result to the lowest whole integer. Then the range is taken into consideration, for example ± 1 would mean that questions with difficulty of 4, 5 or 6 could be selected. The range is also constrained by not being less than 1 or more than 10. The program selects a question by picking at random both a starting page and starting question from those existing, and then preforming a linear search down through the database until finding a question with a difficulty level included in the range. If necessary, the search continues to the next page and from the last page to the first and then to the second and so on. When a question of correct difficulty is found it is presented and waits for the user to select an answer in the bottom frame. Upon clicking a button, the answer is compared to the correct one and the result, right or wrong, is shown in the top right frame with the correct answer. Control is then returned to the top left frame and the percentage of correct answers is updated along with a bar of correct to incorrect answers (green:red colored, respectively). The current status of the test results are remembered for up to 365 days in the "cookies" unless reset by the user.


The system is flexible in that specific names can be given to each quiz system, the title can be chosen, and a link can be designated to go to when leaving the site. The questions can consist of only a few words on one line to several lines (but usually two). Answers, however, must only be on one line (usually under 80 characters) and there must be five for each question. There is hardly any limit to the number of question-answer sets since the database is split into the necessary number of HTML files so that none are larger than 32K (larger can crash Netscape). The DOS file name length of 8 characters limits this to 999 files, 39,960 questions, and about 30 megabytes for a parent name of 5 letters. Using fewer than 5 letters allows even larger databases of from 10 to 1000 times (4 and 3 letters, respectively). However, regardless of the number of pages in the database, the time required to select a question at random is the same since the file to begin a search is called by name (e.g. flowr678.htm). An appropriate question would likely be found in this file or the next one (flowr679.htm).

Question sets of various difficulty levels can be listed with no particular order since a linear search will find the appropriate level of difficulty. Of course if all questions of each difficulty are put in separate files then the search will take longer than if the difficulty levels are mixed in each file. Since the entry into the database is random, the first appropriate difficulty level will also be chosen at random. However, the correct answers to questions must be chosen in a balanced way so that there are not too many a's or other letter in proportion to the others, as on all multiple choice tests.

The system allows for many subject areas to be presented as an interactive exam. The system can be used from the Internet or from the hard drive. The compiled program and supporting text files makes it easy for anyone to make a specialized database of questions and answers ready to run on the Internet. The software can be downloaded from the Internet at the address The zip file needs to be uncompressed by PKUNZIP.EXE or similar program. The system can also be evaluated on the Internet: .


Goodman, D. (1996) Danny Goodman's JavaScript Handbook. IDG Books Worldwide, Inc., Foster City, California.

Stanek, W. (1996) Web Publishing Unleashed., Indianapolis, Indiana.

Biographical note

John Byers was educated at Colorado State University (B.S. and M.S.) and University of California at Berkeley (Ph.D.) before becoming an Associate Professor of Insect Chemical Ecology at the Swedish University of Agricultural Sciences at Alnarp. His main research interests are in insect behavior and chemical ecology, and in computer simulation of behavioral and ecological models.

Address for correspondence:
home page