Building a Quiz – an A level Computer Science Project

Spread the love

This project was designed to support Sixth Form students studying for either the
OCR A-level Computer Science (H446) or AQA A-level Computer Science (7517), specifically the non examinable programming element.

In order to prepare a group of Lower Sixth CS students for the programming component that they will complete next year, we asked them to work in pairs on the sections of the project described below.

The idea was to give them: an insight into the work of software development teams, a feel for the complexity of code required by AQA and OCR, and the opportunity to create code for and work on a project that meets the complexity requirements necessary for A-level that also included hardware elements.


Overview


This is a fully functional quiz game, complete with buttons for players, lights showing the current status, and a scoring system.

The game will also query an online database to provide a large number of questions that can be asked during the course of the game.

A block diagram showing the separate elements of the game is shown below.


Quiz Sequence

The Quiz has two teams each of four competitors and a ninth person acting as Question Master. Each competitor has a button to press and a light in front of them.  Two large panels show the team scores.

When the game starts all of the individual lights are on, making a total of 8 lit lamps. The easiest way to understand how the game operates is go through the slides in the User Interface section that follows (or watch the video – press the + on the bar below).

IT WORKS LIKE THIS!



User Interface

The game is controlled by a screen for use by the Question Master, who is likely to be non technical. A key requirement then is that the system must manage all of the various elements: lighting, scoring etc. All the Question Master should have to do is read the question, wait for the answer and then use the ? and ? buttons (Ideally the screen will be on a touch sensitive device so that s/he can just touch the buttons). The game should then automatically calculate the scores and control the scoring and lighting subsystems.

In addition, it is inevitable that at some point the Question Master will press the wrong button, so an ‘Undo’ function needs to be incorporated.

The slide sequence below show the Question Master’s screen. It is intended that the neccessary code to create the screen will run on a Raspberry Pi.


Button & Lighting System

Combined switch & lamp

The Button & Lighting System controls what happens as each question is asked and answered. It controls 8 output signals (2 x 4 individual lights) and receives notifications from 8 input push buttons. To reduce the number of physical boxes, each player’s lamp and button is combined into one unit.


Scoring System

The scoring system is described in the Quiz Sequence and User Interface sections above. The scores are presented to the players and to the audience using large 250mm high 7 segment displays. These displays are driven by an Arduino controller. Two sets of code are required, one running on the Arduino to control the 7 segment displays and the other for the Raspberry Pi to transmit score codes to the Arduino.


Question Database

Open Trivia database screenshotThe question database is OPENTRIVIA,  an open source, free to use, database of trivia questions. To quote: ” The Open Trivia Database provides a completely free JSON API for use in programming projects. Use of this API does not require a API Key, just generate the URL below use it in your own application to retrieve trivia questions.”

The box below shows a live response generated by the open trivia database. The data in the box changes every few seconds.

Code

The programming languages used to create the code for the Quiz project include Python, Javascript, C++ and others. Unlike other projects on this site, the code required for the project really needs to be managed in a version control system. We have added everything required as a Github repository. Feel free to use and/or fork the code.


Hardware

The hardware arrangement is shown below. There are eight combined button/lamp player boxes, two Team Boxes and a Question Master console (Control Box C).

The two data signals from the Control Box C to the Team Box A are combined into one multicore cable (a 25 Way D cable). A similar cable is used for the A to B box connection.

The two team boxes are constructed of 9mm MDF. Build instructions are at Instructables.com