The easiest way to write a quiz program is to use questions that have a multiple choice answer. The advantage of using multiple choice is that any answer the user gives is either definitely wrong or definitely right. There is no ambiguity. Computer programs hate ambiguity. The problem is that the quiz compilers are required to create the alternative different answers, which adds to their work. Free-text input is prone to errors. A quiz that allows free-text input for the answers must have answers that are very easy to input. Numerical answers are the least prone to error. If the answer is ‘3’, how do you respond to an answer of ‘three’? Both answers are correct but if the code is checking for ‘3’ and finds ‘three’ then the player could easily be marked wrong. Free-text input is very demanding to code; you must mark as correct many answers that are incorrectly spelt. But how do you allow for that? One way is to compare the player’s answer with the correct answer using a table of allowed, wrongly spelt answers. However you approach it, the problem is complex and can result in ‘obvious’ wrong answers being marked correct and vice versa. In this chapter we are therefore only going to consider the multiple choice option. In the database of quiz questions we will keep the correct answer and
Databases come in many shapes and forms. In this chapter we will concentrate on using SQL Server. This is a relational database management system for Windows NT servers. If you intend to do much work using SQL Server then you will need to get a copy of the developer edition. Unfortunately, this costs about the same as a copy of
Flash, although a trial evaluation version is available. A simpler alternative is to use an Access-based database and much of the material in this chapter applies to both databases. The major difference between the two options is in the way the server implements the database access. The SQL Server route is much more flexible and results in a smoother experience for the users. In the end, the cost
Figure 14.1 SQL Server Enterprise Manager.