macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Building Custom iQuiz Data
Pages: 1, 2

Custom Graphics

iQuiz looks for custom graphic files in the same trivia pack folder it finds trivia.txt. When it finds files with certain names, it replaces the default graphics with the custom ones. You can only use TARGA images with iQuiz, and Apple specifies the allowable dimensions for each kind. It's very easy to put these files together using an image editor like Photoshop but it's also a lot of work. I'd recommend you skip custom graphics unless you have a pressing need to create a unique visual signature for your quizzes.



You'll find a complete list of file names and specifications at the Apple iQuiz web page.

Tip: The iQuiz 1.0.ipg file in your iPod Games folder is actually a zip archive. Copy it to a new folder and unzip it to gain instant access to the original source images (and lots of other source material). Use these graphics as a jumping-off point for your adaptations.

Building Questions Programmatically

Now that you've seen how to create the trivia.txt file for custom game packs, the next challenge comes from filling that file with compelling content. Educational material in an existing digital form provides a rich source of questions. (Apple Learning Interchange 2007 seems to agree.) For example, with a list of foreign language words and their proper gendered form (la mano, i bimbi, lo zoo), you can easily build a program or script to scramble the forms with possible errors, e.g.:

MC
Which is correct?
la scuola
il scuola
lo scuola
le scuola
1

Here are a few key factors that will help you put together effective quizzes.

  • Use several question forms. Avoid using the same kind of prompt for every question. "Which is correct?", "Which is correct?", "Which is correct?" grows old fast. Build a collection of prompts and randomly select from them for each question.
  • Use "smart" mistakes. For multiple-choice questions, try to generate wrong answers that make sense. To create a multiplication quiz, I picked a series of common one-off errors as the basis for the wrong answers.
  • // Seven "wrong answer" patterns based on common mistakes
    ans[0] = (x * y) - 1;
    ans[1] = (x * y) + 1;
    ans[2] = ((x + 1) * y);
    ans[3] = ((x - 1) * y);
    ans[4] = (x * (y + 1));
    ans[5] = (x * (y - 1));
    ans[6] = ((int) ((x * y) / 10)) + ((int) ((x * y) % 10) * 10);
  • Use more kinds of wrong answers than slots. iQuiz allows you to include up to four answers per multiple-choice question. That means each question has one correct answer and three wrong ones. Try to use more than three "kinds" of wrong answers if possible to keep the questions fresh. The example code shown above uses seven mistake generators.
  • Shuffle the answers. When you build wrong answers programmatically, don't let your end-user know which kind of wrong answer appears in each slot. Add a shuffle after generating those answers so, for example, answer "B" isn't always "one too many."
  • Move the answer around. Just as you shuffle around the wrong answers, keep the correct answer random. Don't let your user build a "when in doubt, pick D" mentality.
  • Be redundant. Particularly for language and mathematics drills, feel free to add more than one variation of your question. Don't let your end-user learn that "3 times 4 is answer B." The correct answer is 12, not "B." By providing several variations of the question you force the user to search for the correct answer, even with the static databases used by iQuiz.

Quiz Generation Example

Here is the C source of my multiplication quiz, demonstrating all of the above points in turn. (And yes, my use of variable names is terrible.) To use, compile and then paste the results into the bottom of a trivia.txt file.

// Erica Sadun
// April 2007
// 
// makequiz -- makes a Multiplication quiz with question variations
//

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

//
// Provide 4 answers for every question. Include an answer key.
//

void fourAnswers(x, y)
int x, y;
{
   int ans[7], i, a, b, tmp;

   // Seven "wrong answer" patterns based on common mistakes
   ans[0] = (x * y) - 1;
   ans[1] = (x * y) + 1;
   ans[2] = ((x + 1) * y);
   ans[3] = ((x - 1) * y);
   ans[4] = (x * (y + 1));
   ans[5] = (x * (y - 1));
   ans[6] = ((int) ((x * y) / 10)) + ((int) ((x * y) % 10) * 10);

   // Allow dupes of wrong answers but not of right ones by adding 
   // random, positive number to answers that dupe the correct one
   for (i = 0; i < 7; i++)
      if (ans[i] == x * y) 
         {ans[i] += (rand() % 80) + 1;}

   // Shuffle answers randomly multiple times
   for (i = 0; i < 30; i++)
   {
      a = (int)(rand() % 7);
      b = (int)(rand() % 7);
      tmp = ans[a]; ans[a] = ans[b]; ans[b] = tmp;
   }

   // Insert correct answer randomly into one of first 4 items
   a = (int)(rand() % 4);
   ans[a] = x * y;

   // Print question in trivia.txt format using one of four styles.
   printf("MC\n");
   b = (int)(rand() % 4);
   if (b == 0) 
      {printf("What is %d X %d?\n", x, y);}
   else if (b == 1) 
      {printf("What do you get if you multiply %d by %d?\n", x, y);}
   else if (b == 2) 
      {printf("What is %d times %d?\n", x, y);}
   else 
      {printf("What is %d multiplied by %d?\n", x, y);}

   // Print out answers. 4 per question, one per line.
   for (i = 0; i < 4; i++) {printf("%d\n", ans[i]);}

   // Print the correct answer index and extra CR
   printf("%d\n\n", a + 1);
}

main()
{
   int x, y, z;
   srand(time(NULL));

   for (z = 0; z < 3; z++) // three sets of questions
     for (x = 2; x <= 12; x++) // multiply 2x2 up to 12x12
      for (y = 2; y <= 12; y++)
      {
        fourAnswers(x,y);
      }
}

Other Sources for Questions

If you do not have data sources on hand, you can easily google up data sets for both educational and entertainment trivia. Search, for example, for free public-domain or open source "pub quizzes" and "trivia databases." These, when put into the proper format, make excellent iQuiz games. In my searches, I found several open source trivia databases including these sets, which are part of the MisterHouse project.

Assembling and Installing Trivia Packs

To install a game, start by creating a new folder. Name it with the title of your trivia pack. Place the trivia.txt folder inside along with any custom TARGA image files.

After purchasing and downloading iQuiz, iTunes automatically creates an iPod Games/iQuiz 1.0 folder inside your iTunes folder (typically found in ~/Music). Drag the trivia pack folder you just created into the iQuiz 1.0 folder and then sync your iPod. iTunes will automatically load your new trivia pack onto your iPod.

Unmount your iPod and launch iQuiz. Your new trivia packs appear in iQuiz's "new game" menu (if didn't enable the "HIDDEN" tag, that is). As you wait for your Quiz to load, you'll see a pulsing iQuiz logo. If you mess a little bit with the scroll wheel when you see this, you'll be pleasantly surprised by the rubber-band-like results.

Tip: If you're curious and you've enabled disk access, you'll find your games in /Volumes/(name-of-your-iPod)/iPod_Control/GameData_RO. One of the folders in that directory--possibly 11002--contains the iQuiz game. In that folder, look under UserTrivia/Packs to discover your user-installed game sets.

Examples

I've put together a bunch of sample files to accompany this article. These include three variations on the multiplication game, the C source used to create them, and a set of six trivia packs built using trivia data from the Net that was represented as open source and/or public domain on the sites I downloaded from. (If anyone knows otherwise, please let me know and I'll remove them.)

Conclusions

In this article, you've seen how to create custom iQuiz files. You can go the simple route by using Aspyr's easy-to-use iQuiz Maker utility, or you can go the slightly harder but ultimately more rewarding route by building your data files from scratch. Once again, Apple has provided a flexible and useful tool that goes way beyond expectations and offers exciting possibilities for anyone willing to get up to speed.

If this article inspires you to build your own trivia packs, please leave a link and a description in the comments.

Erica Sadun has written, co-written, and contributed to almost two dozen books about technology, particularly in the areas of programming, digital video, and digital photography.


Return to Mac DevCenter.