MATLAB Community

MATLAB, community & more

Building a Quiz for MATLAB EXPO

Earlier this month, I was lucky to attend the MATLAB EXPO in the UK (EXPO is an action-packed one-day user conference held every year in England). This year there was an excited buzz in the exhibit hall around one particular set of monitors. This was the MATLAB EXPO Quiz game. I asked one of the instigators of that game, GianCarlo Pacitti, to write something here about how they built it. He graciously agreed.

GianCarlo works as an Application Engineer in our UK office in Cambridge, England. He has a keen interest in controls, modelling and simulation. As well as being an expert Simulink user, he also enjoys building MATLAB Apps. He helped build the quiz game, in which EXPO attendees raced against the clock in a challenge to discover who knew the most about all things MATLAB and Simulink.

I played the game, and I can vouch for the fact that it is fun, crafty, and robust. Read on to learn how they made it. Take it away GianCarlo!

Building a Quiz for MATLAB EXPO

by GianCarlo Pacitti

A few weeks ago, more than a thousand engineers and scientists gathered at Silverstone for the UK MATLAB EXPO. For some extra fun on the day, we created a “MATLAB EXPO Quiz” that people could play on one of four 55 inch touch-screen monitors in the exhibition hall.

Some numbers: throughout the day 278 unique players completed 986 individual games, with 4999 attempts at 255 questions spanning 11 categories. The questions were all multiple-choice, picking from 4 possible answers, and ranged in difficulty from simple math (“What is 3 times 4?”) to some fiendish questions on control systems and code generation. Things were easier if you attended the “What’s New” presentations as many questions were based on new features.

Designing the Quiz App

We used App Designer to quickly prototype the graphical layout of the quiz and get feedback on the game play. It was super easy to put together the structure of the quiz and hook up the graphical controls to the logic of the quiz.

To add an extra element of tension to the quiz we set a 20 second time limit to answer a question. Not only that, we played a loud ticking sound each second, and a klaxon when you were down to the last 5 seconds. It’s safe to say we caused a few people to jump the first time the klaxon went off!

Timer objects in MATLAB provided a convenient way for us to set up the question timer and trigger the game-over function when the player was out of time.

But how would the quiz hold up when we let a thousand MATLAB users loose on it? We needed it to be bullet-proof.

Testing the App

There were a few of us working together on this project, so to enable concurrent development we decided to use object-oriented programming techniques in MATLAB. It’s now easy to export the underlying MATLAB code from App Designer and break it into several MATLAB Classes that we could each work on at the same time. This saved us a lot of time when it came to merging our changes.

Locking down the desired behavior with the MATLAB Unit Testing framework meant we could tweak the design safe in the knowledge that we would know if we broke anything. To discover any edge cases we hadn’t thought of, we put the quiz in the hands of our MathWorks colleagues to try out one evening after work. We got some great user feedback, and lots of extra questions for the quiz.

Keeping Score

Before starting the game, we prompted the player to put in a name for the scoreboard. Each correct question earned the player 25 points, with an increasing bonus for completing a round of 4 questions. Completing all 6 rounds would earn you a maximum score of 1000 points.

When a player completed a game, the quiz needed to send the player name and score somewhere so we could have a leaderboard. We needed a mechanism that would allow multiple quiz machines to all send scores to the same central leaderboard. Our thoughts quickly turned to ThingSpeak, and we set up a MATLAB quiz channel.

Using the ThingSpeak API to send the data to the channel was even easier than we thought it was going to be! Here’s the code:

A separate leaderboard app used the ThingSpeak API to get the complete list of scores (using webread, rather than webwrite) and display the top 30 players.

How difficult was the quiz to play?

Any question is easy if you know the answer. We were worried that we had pitched the level of difficulty of the questions too high. We logged each question that was attempted, what answer was given, and how long it took to answer the question. From this we could plot the difficulty of each category of question using the average rate of answering correctly:

You might expect that harder questions take longer to answer, and our data shows that generally this is the case.

So, what was the hardest question of the day? Six people attempted this question, but nobody got it correct. Can you? You have 20 seconds, your time starts…. NOW!

Which of these is NOT a data type in MATLAB?
A. duration
B. clockDuration
C. datetime
D. calendarDuration
  • print


To leave a comment, please click here to sign in to your MathWorks Account or create a new one.