Update: The demo below now asks IBU and SRM questions in addition to ABV.
It’s been about a week since my last post. Don’t worry, I haven’t lost my interest in beer; I’ve just been busily working on my latest coding project, a Beer Quiz. I have pulled all the BJCP style guideline information into a database and written a script that uses the info to generate quiz questions.
This project is a exercise for me in concise coding, as I frequently find myself duplicating chunks of code that could easily be handled by a single routine. To keep the code as small as possible, I am using an XML file to hold all the question parameters. The script randomly selects a question type from the XML file. Using the information retrieved, a SQL query is executed to gather a handful of possible answers; one correct, the rest false. Since all the question information is held in the XML file, new question types can be added without any changes to the code.
Here is an example of the code in action. The script is running in an iframe, so if you are running ad blocker, you may need to turn it off.
In the demo above, only ABV range is being asked. When the script is finished, original gravity, final gravity, IBU and SRM range will also be included. As will BJCP aroma, appearance, flavor, mouthfeel, overall impression, comments and ingredients questions. Since there are 80 BJCP styles, and each of the twelve questions can be asked two ways (match a style to the information, or match information to a style), the Beer Quiz should contain over 1900 unique questions.
I am shooting to have the quiz finished in about a week or so. Once complete, I plan to to recreate it as an Android app; my first project on the platform. If you have any ideas for the Beer Quiz or notice any problems with the demo above, let me know.
Cheers!
Kevin