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

Part XII: Question Types, Sounds, and Finish Buttons

Trivia Quiz Shell 2.5 introduces a wealth of new features designed to give you, the TQS author, numerous ways to enhance your applications. Parts XII through XIV of the tutorial will cover these new features.

Multiple-choice questions have been available since TQS 2.0; however, if you had other types of questions to present, there was little you could do short of converting them to multiple choice or creating a custom location type. TQS 2.5 extends the questions location type to support new types of question sets: true-false questions, type-in-answer questions, and question sets consisting of questions of mixed types.

It is very easy to begin using different question types within your application. Let's begin by making a set of true-false questions. Add the following location to a TQS document:

<LOC ID="1" TYPE="QUESTIONS">
  <HEADING>My True-False Questions</HEADING>
  <QUESTIONS TYPE="TF">
    <QUESTION>
      <Q>Madison is the capital of Wisconsin.</Q>
      <ANSWER>TRUE</ANSWER>
    </QUESTION>
    <QUESTION>
      <Q>Detroit is the capital of Michigan.</Q>
      <ANSWER>FALSE</ANSWER>
    </QUESTION>
  </QUESTIONS;
</LOC>

Notice how similar this syntax is to the normal multiple-choice question syntax. In fact, the only differences are the QUESTIONS element's TYPE attribute, and the existance of only one ANSWER element per question.

The TYPE attribute must be set to "TF" to specify that this is a set of true-false questions. (If the attribute does not exist, it will default to "MC", for multiple-choice questions.) The QUESTION elements must only include one ANSWER element, containing either TRUE or FALSE, to specify the correct answer.

All other options with which you are already familiar, such as left- and right-side images, the INORDER attribute, and the SHOWSCORE ability, work the same with all types of questions.

Next, let's take a look at type-in-answer questions. Here, the user is presented with a question and with a place in which to type the answer. Add the following location to your document:

<LOC ID="1" TYPE="QUESTIONS">
  <HEADING>My Type-In-Answer Questions</HEADING>
  <QUESTIONS TYPE="BLANKS">
    <QUESTION>
      <Q>What is the capital of Wisconsin?</Q>
      <ANSWER>Madison</ANSWER>
    </QUESTION>
    <QUESTION>
      <Q>What is the capital of Michigan?</Q>
      <ANSWER>Lansing</ANSWER>
    </QUESTION>
  </QUESTIONS>
</LOC>

Here, the TYPE attribute must be set to "BLANKS" to specify type-in-answer questions. Again, only one ANSWER element is supported, which must contain the correct answer.

By default, the answers are not case-sensitive, meaning the user can type mADIsOn for the first question and get it correct. To make answers case-sensitive, add the CASESENSITIVE attribute to the QUESTIONS element and set it equal to "1".

TQS 2.5 also allows you to create individual question sets containing different types of questions. Add this location to your TQS document:

<LOC ID="1" TYPE="QUESTIONS">
  <HEADING>My Mixed Questions</HEADING>
  <QUESTIONS TYPE="MIXED" SCRAMBLEANS="1">
    <QUESTION TYPE="MC">
      <Q>What is the capital of Wisconsin?</Q>
      <ANSWER CORRECT="1">Madison</ANSWER>
      <ANSWER>Milwaukee</ANSWER>
      <ANSWER>Green Bay</ANSWER>
      <ANSWER>Wausau</ANSWER>
    </QUESTION>
    <QUESTION TYPE="TF">
      <Q>Minneapolis is the capital of Minnesota.</Q>
      <ANSWER>FALSE</ANSWER>
    </QUESTION>
    <QUESTION TYPE="BLANKS">
      <Q>What is the capital of Michigan?</Q>
      <ANSWER>Lansing</ANSWER>
    </QUESTION>
  </QUESTIONS;
</LOC>

When the QUESTIONS element's TYPE attribute is set to "MIXED", the type of each individual question is determined by the QUESTION element's TYPE attribute.

Another new feature in TQS 2.5, requested by TQS authors, is the ability to associate sounds with questions, and with correct and incorrect answers. (Note that sound files must exist in the same folder as your TQS file; refer to the previous part of the tutorial for information on the data root and how to specify different paths.)

First, in order for TQS to play any sounds (except for the background sound), you must add the USESSOUNDS attribute to the TQS element and set it equal to "1", as shown:

<?xml version="1.0"?>
<TQS VERSION="2.5" USESSOUNDS="1" ...>
  ...
</TQS>

When a question is presented to the user, a sound can be specified to play. This is accomplished though the SOUND attribute of the QUESTION element:

<LOC ID="1" TYPE="QUESTIONS">
  <HEADING>Guess the Animal</HEADING>
  <QUESTIONS>
    <QUESTION SOUND="pig.wav">
      <Q>What animal is this?</Q>
      <ANSWER CORRECT="1">Pig</ANSWER>
      <ANSWER>Cow</ANSWER>
      <ANSWER>Horse</ANSWER>
    </QUESTION>
    ...
  </QUESTIONS;
</LOC>

Previous sections of the tutorial have covered using the CORRECT and INCORRECT elements to specify the message associated with correct and incorrect answers. TQS 2.5 adds the SOUND attribute to these elements to let you specify a sound to be played for correct and incorrect answers.

<QUESTIONS>
  <CORRECT SOUND="correct.wav">Good job!</CORRECT>
  <INCORRECT SOUND="wrong.wav">Wrong!</INCORRECT>
  <QUESTION>
    ...
  </QUESTION>
    ...
</QUESTIONS>

Note that no sounds are played by default.

Correct and incorrect sounds can also be specified for Hangman locations, and can even be used by your custom location types (more on this in Part XIV of this tutorial). The CORRECT and INCORRECT elements are now supported as immediate chilren of the GLOBAL element, and are used as the defaults for all correct and incorrect sounds. (They can be overridden either through a specific location type within global settings, or within an individual location.)

<GLOBAL>
  <CORRECT SOUND="correct.wav"/>
  <INCORRECT SOUND="wrong.wav"/>
  ...
</GLOBAL>

Note that when these elements are used in this manner, they are only used for their SOUND attributes, not for their text message.

The last TQS 2.5 feature covered in this part of the tutorial is the FINISH element. Requested by TQS authors, this feature allows you to display a text message and/or button(s) to the user when they have finished a location (answered all of the questions or guessed all the Hangman words). This way, after seeing the "Next Question" button consistently, the user will not be confused when suddenly the button does not appear because they are at the end.

As with most other TQS features, finish settings can be specifed on a global or per-location basis. Add the FINISH element to an existing questions location in your TQS document, as shown:

<LOC ID="1" TYPE="QUESTIONS">
  <FINISH PROMPT="You have finished this question set.">
    <BUTTON TITLE="Play Again" TARGET="1"/>
  </FINISH>
  <QUESTIONS>
    ...
  </QUESTIONS>
</LOC>

The prompt, which can include HTML formatting, can be used to present a message to the user, for instance asking them if they want to play again or return to a menu. Any BUTTON elements within the FINISH element will be displayed below the prompt. Both the prompt and the button appear on screen where the "Next Question" and "Next Word" buttons appear.

When used within global settings, the BUTTON elements can use the same rules as global navigation buttons to determine which buttons should be displayed:

<GLOBAL>
  <FINISH>
    <BUTTON
      TITLE="Restart"
      TARGET="LOCPOS:0,LOCPOS:1"
      APPLIESTO="GREATER"
      GREATER="LOCPOS:1&gt;0"
    />
    <BUTTON
      TITLE="Back to Menu"
      TARGET="LOCPOS:0,0"
      APPLIESTO="GREATER"
      GREATER="LOCPOS:1&gt;0"
    />
  </FINISH>
  ...
</GLOBAL>

More information on BUTTON elements can be found in Part IX of this tutorial, and in the Reference.

In this section of the tutorial, you have learned how to use several of TQS 2.5's new features, including new question types, sounds, and finish prompts and buttons. In the next part, you will be introduced to the rich scoring and reporting capabilities of TQS 2.5.

Part XIII: Reports, Scoring, and Location States

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