TQS Home
Trivia Quiz Shell Version 2.8 Now Available!Bot Productions Home
 

Part VI: Adding and Customizing Trivia Questions

So far, we have explored the use of two of the three built-in location types, "HANGMAN" and "MENU". The third type, the original sole purpose of TQS, is the Trivia Questions location type.

Trivia Questions provides you with functionality to present a series of multiple choice questions to the user. You have many options, including scrambling of questions, number of answers, scrambling of answers, image display, and use of HTML formatting. Also, TQS can display the user's score, keeping track of number of questions asked, number correct, number wrong, and percent correct.

To specify a Trivia Questions location, we set the TYPE attribute of the LOC element to "QUESTIONS". All question-specific data is stored in the QUESTIONS element, inside of the LOC element, just as menus and hangman games store information in their own specific elements.

We will add a third option to our menu, and a corresponding LOC element with ID of 3, for United States Trivia. Thus, our menu will now look like this:

<MENU CENTER="1">
  <MENUITEM
    TITLE="United States Hangman"
    TARGET="1"
  />
  <MENUITEM
    TITLE="European Hangman"
    TARGET="2"
  />
  <MENUITEM
    TITLE="United States Trivia"
    TARGET="3"
  />
</MENU>

The following LOC element, placed inside the LOCATIONS element, shows the framework for using Trivia Questions:

<LOC ID="3" TYPE="QUESTIONS">
  <HEADING>United States Trivia</HEADING>
  <BUTTON TITLE="Restart" TARGET="3"/>
  <BUTTON TITLE="Main Menu" TARGET="0"/>
  <QUESTIONS>
    ...
  </QUESTIONS>
</LOC>

Individual questions are added to the TQS document as QUESTION elements inside of the QUESTIONS element. The code below shows the syntax and placement of a simple QUESTION element:

<QUESTIONS>
  <QUESTION>
    <Q>What is the capital of Wisconsin?</Q>
    <ANSWER CORRECT="1">Madison</ANSWER>
    <ANSWER>Milwaukee</ANSWER>
    <ANSWER>Green Bay</ANSWER>
    <ANSWER>Wausau</ANSWER>
  </QUESTION>
  ...
</QUESTIONS>

The Q element specifies the question to be asked, while ANSWER elements specify the choices presented to the user. The correct answer is the one which has the CORRECT attribute set to "1". When displayed on-screen, each answer is given a letter to identify it; each question can have up to 26 answers (although most situations would not need that many).

By default, the answers are displayed on-screen in the order given in the TQS document. To randomize the order of the answers, add the following attribute to the QUESTIONS element. Note that this will affect all questions in the set:

SCRAMBLEANS="1"

TQS will, by default, go through the questions in a particular set in a random order. To specify that the questions should be presented in the order that they are given in the TQS document, add the following attribute to the QUESTIONS element:

INORDER="1"

Each question can be accompanied by one or two pictures, to be displayed on the left and/or right side of the question. To add a picture, add the LIMG and/or RIMG element to the QUESTION element to specify a left-side or right-side picture, respectively:

<QUESTION>
  <Q>What state is this?<Q>
  <LIMG SRC="wi.gif"/>
  <ANSWER CORRECT="1">Wisconsin</ANSWER>
  <ANSWER>Minnesota</ANSWER>
  ...
</QUESTION>

As with heading images, the image file, specified by the SRC attribute, must be located in the same directory as the TQS document file, by default. This can be changed in TQS 2.1 or newer; see the Reference for more information.

TQS supports use of HTML tags in the text of Q and ANSWER elements. However, remember that tags must be coded properly: &lt; for < (less than signs) and &gt; for > (greater than signs).

A common use of HTML in questions is to display Roman Numeral questions. Line breaks, <BR>, can be coded as follows:

<QUESTION>
  <Q>Which of the following cities are located in
  Wisconsin?&lt;br&gt;&lt;br&gt;I.
  Rockford&lt;br&gt;II. Wausau&lt;br&gt;
  III. Green Bay</Q>
  <ANSWER>I only</ANSWER>
  <ANSWER>I and II only</ANSWER>
  <ANSWER CORRECT="1">II and III only</ANSWER>
  <ANSWER>I, II, and III</ANSWER>
</QUESTION>

The Q element will thus contain the following in HTML text:

Which of the following cities are located in
Wisconsin?<br><br>I. Rockford<br>II. Wausau
<br>Green Bay

It will be displayed on screen as follows:

Which of the following cities are located in Wisconsin?

I. Rockford
II. Wausau
III. Green Bay

HTML formatting tags, such as bold, underline, superscript, and subscript, are available for use.

By default, TQS displays the text strings "Correct!" and "Incorrect!" after the user has selected an answer. You can change these defaults, and specify that the letter of the correct answer be displayed upon an incorrect answer. The following code shows how to do this:

<QUESTIONS>
  <CORRECT>Right answer!</CORRECT>
  <INCORRECT INSERT="@">Wrong! The correct answer
    is @.</INCORRECT>
  <QUESTION>
    ...
  </QUESTION>
  ...
</QUESTIONS>

Note the use of the INCORRECT element's INSERT attribute. It specifies a character or string which should be replaced with the letter of the correct answer. The INSERT attribute is optional.

The Trivia Questions location type has built-in support to keep track of score and display it above the navigation buttons. To do so in TQS 2.1 or newer, add the SHOWSCORE attribute to the QUESTIONS element and set it equal to "1". Another way to access this feature, compatible with TQS 2.0, will be covered in Part IX of the tutorial.

You now have a thorough understanding of using the Trivia Questions location type to present multiple-choice questions to the users. This concludes Part VI of the tutorial. In the next part, we will introduce a number of options for customizing the look and feel of the TQS window, including color, font, and window size.

Part VII: Customizing the TQS Window


©2016 Bot Productions. All rights reserved.Last Updated: September 9, 2007