oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Building Custom iQuiz Data

by Erica Sadun

If you spend any time over at iTunes, you might have noticed a new iPod game called iQuiz. Apple is promoting it heavily now. It retails for just $0.99, a bargain by anyone's standards. iQuiz offers interactive trivia challenges that play like TV game shows. Very flashy, very easy to use, and a big step up from the iPod's built-in and rather worn out Music Quiz.

What sets iQuiz apart from the ordinary (beyond its especially affordable price and its great interactive style) is that it allows end-users to create their own custom games and run them using the iQuiz interface. This means that you can create your own question database to play with on your iPod or to distribute to friends, colleagues, or students to play on their iPods. In this article, you'll discover how to create your own custom data sets for iQuiz.

Building Basic iQuizzes

If you pop over to Apple's iQuiz web page, you will find a link to game maker Aspyr. Aspyr just introduced a free utility that allows end-users to design iQuizzes. Its iQuiz Maker utility interactively builds iQuiz-compatible files (Figure 1). You add a new question. You type in the question text. You add some answer text. You indicate which answer is correct. Lather. Rinse. Repeat. Save to disk. iQuiz Maker is easy to use and offers all the flexibility and configurability of your average rock.

iQuiz Maker
Figure 1. Aspyr's iQuiz Maker program offers a GUI that allows you to interactively create quiz questions.

If you want to convert an existing trivia database to an iQuiz or to programmatically create test material, iQuiz Maker is not the answer. You must type in each question using Aspyr's UI. There's no way to import data files. Sure, that's fine for a 5- or 10-question quiz (and it's a wee bit tedious even for short quizzes), but it's not so fine for quizzes that run longer than that and involve more customization of iQuiz UI features.

Custom Quiz Materials

Fortunately Apple offers a way to make an end-run around iQuiz Maker. Apple provides a basic markup language that lets you build quiz materials without a GUI. iQuiz can parse and execute certain text files. This lets you build your questions programmatically, automating much of the iQuiz creation process to produce more robust and interesting databases.

The text-based data files you create are not compiled or put into any unreadable form. That means that this is not a particularly good way to produce a for-pay product, but it works well for recreational and educational users. Two target areas that work particularly well in this arena are trivia games and training drills. Drills can include mathematics, languages, history, and any other fact-based academic subject.

iQuiz also lets you add customized TARGA graphics files. These files can supplement or replace nearly all the graphics in the iQuiz game. Customizable images include backgrounds, buttons, arrows, and even the spinning countdown images shown at the start of the game. Whenever iQuiz detects an image with a certain name in your quiz folder (e.g., lost_background.tga is the background image for the "You Lose" screen), it replaces the standard picture with the custom one. You don't have to update or change the iQuiz graphics, but the functionality is there if it so suits you.

Tip: The iQuiz language is superficially similar to the one used for iPod Notes, which you can read about in Mac DevCenter's Building Interactive iPod Experiences.

Creating the Quiz File

Custom quizzes are stored in a file called trivia.txt. This file consists of a header followed by a list of questions. The header provides basic information about how the quiz operates including the name of the quiz, the number of questions to ask for any session, and so forth. The questions offer the text of the challenge and their possible answers. You do not have to add questions in any particular order, as iQuiz selects them randomly from your text file.

The Header

The iQuiz header consists of key/value pairs. Each key, or "tag" as Apple calls them, appears in uppercase on a single line. The next line sets the value for the tag. Here's the header for a quiz I recently wrote. It's called "Multiplication Adept" as I state in the TITLE tag, and it drills children on multiplication math facts from 2 x 2 up to 10 x 10. It's one of several multiplication quizzes that I wrote, all of which appear in the iQuiz menu under a "Math Quizzes" heading, i.e., the GROUP tag. In the quiz, children are asked 10 multiplication questions, set by the ASK tag. If they get three questions wrong (the LOSE tag), the game ends and they are prompted to try again (LOST MESSAGE).

Multiplication Adept (2 - 10)

Math Quizzes



You're a Multiplication Genius!

Sorry! Too many wrong answers. Try again next time!


Game Tags

Here's a quick rundown of the game tags you can use in your trivia.txt file:

  • TITLE: The name of your trivia pack. Defaults to "Untitled."
  • GROUP: The optional group of your trivia pack. If you do not include a group, the TITLE of your game appears directly in the New Game menu.
  • ASK: The number of questions to ask each game. You can ask between 1 and 1000 questions. Defaults to 10.
  • LOSE: The number of wrong answers at which point a user loses the game. Legal values range from 0 to 7. You can disable this feature by setting it to 0; users will be asked the full complement of game questions set by ASK. Defaults to 3.
  • WON MESSAGE: A line of text that appears when a user finishes a game. Defaults to "You won!"
  • LOST MESSAGE: A line of text that appears when a user reaches the maximum number of wrong answers specified by LOSE. Defaults to "You lost!"
  • VERSION: Any non-negative integer. When iQuiz detects a version change, it will reload custom artwork. Otherwise artwork changes are ignored. Defaults to 0.
  • HIDDEN: When set to YES, prevents a trivia pack from appearing in the New Game menu. Defaults to NO.

Tip: I'm not a big fan of the "LOSE" feature. I find that disabling it (set the LOSE value to 0) leads to better trivia game play especially for challenging trivia sets.

Color Tags

In addition to the game control tags listed above, iQuiz lets you specify optional color tags to control the text color for various UI text elements. Colors are comma-separated RGB triplets using values between 0 (darkest) and 255 (brightest). For example, to set the score color to a medium green:

0, 128, 0

Color tags include the following:

QUESTION COLOR (defaults to black: 0, 0, 0),
ANSWER COLOR (black: 0, 0, 0),
EXPLANATION COLOR (white: 255, 255, 255),
SCORE COLOR (light grey: 191, 191, 191),
COUNT COLOR (light grey: 191, 191, 191),
MENU TITLE COLOR (bright blue-green: 50, 255, 255),
MENU BUTTON COLOR (black: 0, 0, 0),
MENU TITLE COLOR (dark grey: 64, 64, 64),
STAT LABEL COLOR (black: 0, 0, 0), and
END MESSAGE COLOR (black: 0, 0, 0).

The Questions

A list of questions follows the header and forms the rest of the trivia.txt file. You can add up to a thousand questions per game. A multiple-choice game of, say, 500 questions with 4 answers each might run as long as 4,000 lines of text.

iQuiz supports three kinds of questions: multiple choice, true/false questions where the answer is TRUE, and true/false questions where the answer is FALSE. In the latter case, you provide an explanation of why the answer was false. This explanation displays after a choice is made, regardless of whether the answer was correct or not. Pedagogically that's a great thing. Not only do you respond to the user's choice, but you reinforce the correct fact at the same time.

Here are examples of all three kinds of questions. Multiple-choice questions start with the MC tag on a single line. This is followed by two to four answers. The last line is a number with the correct answer choice. Leave an empty line before the next question.

What color is the 5 ball in pool?

True/false questions start with the TF tag on a single line followed by the question on another line. If the answer is true, the next line is TRUE followed by an empty line. If the answer is false, the next line is (theoretically optional) text that explains the correct answer. This is followed by FALSE and then an empty line.

Is 2 multiplied by 3 equal to 6?

What do you get if you multiply 2 by 4? Is it 10?
2 X 4 = 8

Feel free to mix and match question types in your trivia.txt file, in any order you like. You can include all true/false questions, all multiple choice, or any combination of the two.

Tip: Internationalize your game by providing localized trivia files. Just add the standard Apple two-letter language tag to a translated trivia.txt file. For example, trivia-it.txt for the Italian version, trivia-fr.txt for the French version, and so on. You can localize game materials to any standard Apple language. The built-in Apple iQuiz menus, however, can only be localized to English, Dutch, French, German, Italian, Japanese, and Spanish.

Pages: 1, 2

Next Pagearrow