Over the weekend I was checking in on the Apple forums for DVD Studio Pro when a particular question caught my eye. The gist of it is that the poster wanted to create a quiz on a DVD where the questions were drawn at random. Easy enough, I hear you say… until we got into doing it and then it turned into a ‘random, but no repeats, please’ situation.
I decided to try to build a short project which did this with just five arbitrary questions. Using DVDSP v4 made things a bit easier since I could manually partition the memory register. I chose to use a very verbose scripting method which repeated sections of code.
In essence, the script first of all added 1 to the first register (I needed to count to five to make sure only five questions were asked) and then generated a random number (using 65,355 then modulo with a value of 5). Next it jumped to various lines depending on what the final random number was.
From there, within each section, I jumped on to the actual question *if* there was no value in the partitioned register which corresponded with that question. If there was a value there it meant the question had already been asked and so it went back to generate a new random number. If there wasn’t a value there I put one in place and then jumped to the question. Cunning, huh? 🙂
Keeping track of the score was easy – I simply had to see if the first register had been filled with a value of five. If it had I needed to jump to the exit screen, where I set up a button to clear all the registers and start again.
This was all pretty good to do, and as a proof of concept worked fine. However, with a lot of questions to ask (say, 50 or more) I would need to re-think the process – for two reasons:
1) first the questions were set into menu tiles, and whilst it is unlikely, it is possible to run out of space in the menu domain, which is limited to 1GB in DVDSP.
2) the scripting in sections would be far too long and unwieldy if there were many more questions to deal with. Also the regeneration of a new random number when a repeat was found could take a long time when you get to the end of a 50 question quiz. It would be better to use a system which generated a number and then altered it (by subtracting or adding ‘1’) until a unique number was arrived at. This would save a lot of time and re-iteration of the script.
The major problem with 2) is that when the random number generated is zero (as can happen with a mod command) you can still subtract ‘1’ from it, and end up with 65535 – which to all intents and purposes is an ‘illegal’ value for the script. It would need to add or subtract within a defined range for this to work securely every time.
Finally, a quiz needs a score. This is something I didn’t build in because I ran out of time. Since I have only used three registers it would be easy enough to do, but again there are things to consider. For example, would you only score a point if you got the answer right first time? The way I set this up was to give the user a repeating chance any time they were wrong. Eventually they would get it right (by process of elimination, if not dawning realisation), and then they could still score top marks… which would be a little misleading to say the least!
Anyway, if you want to have a look at the project file and scripting – or if you just want to play the quiz in your computer’s DVD player, click here to download.
Have fun with it, and remember it was written in a simplistic way – I am always happy to hear of better, shorter methods to do things, of course.