Summer is an odd time. With no ice hockey matches to attend our thoughts turn to other subjects, such as why does RefSignals sometimes repeat questions? I've been asked a few times about how to stop it doing this, so here is a solution. RefSignals is an Android app built with Google App Inventor for Android that quizzes you on the signals made by referees during ice hockey matches. In February I wrote about this app and published the source code so that people could take it and use it as the basis for their own quiz apps. The response was great and the app has been remixed for all sorts of subjects so I hope this will come in useful.
The RefSignals app picks an entry at random from a bank of twenty-five ice hockey penalties as the basis for a question where the user is asked to correctly identify the penalty that the referee is signalling in the picture. The quiz is multiple choice, so three options are presented where one is the correct answer and two the wrong answer. In the original app there was nothing to prevent the same penalty being picked more than one to be the basis of a question, so we need to get it to remember the penalties it has picked and not ask about them again. These instructions show you how to update the original app, but up to date source code is attached.
In the Blocks editor define a new variable called penalties_taken. Go to the Lists drawer and select Make a list and drag it into your new variable. This just means the variable will contain an empty list when it is created. This variable will eventually contain the index number of the penalties used so far in the quiz for questions. You new variable block should look like the one below.
Now find the NextButton.Click block. The first if block is run when we are on the first question of the quiz, we need to add some logic to reset our list of penalties that have been used for questions, otherwise if the user runs the quiz more that once we will run out of penalties to ask them about. Add a block to set the value for the variable this_penalty to zero, then add a block to set the value of the penalties_taken by dragging a make a list block into it and then making that item in the list a zero. The top of your NextButton.Click block should now look like this:
Our pickPenalty block can now be amended to prevent repeated questions about the same item. The logic here is to pick a penalty and then check if it is in the penalties_taken list. If it is pick another penalty, check again and so on. We can implement this logic with a While block. While the current penalty is in the list generate another penalty. The variable this_penalty will always be set to the last penalty asked about, so the while loop will run at least once. Of course the first question is a bit different as there are no entries in the list or current penalty, so we force the logic inside the loop to run in this instance by deliberately setting this_penalty to zero and making the first item in the penalties_taken block a zero too. Your pickPenalty block should look like the one below.
If this doesn't make sense at first have a look at the blocks in the Editor and consider the order that they are run in. See if you can follow the instructions yourself. It might also help to watch the penalties_taken list being populated. You can do this by going to first Is in List? Block and right clicking over the penalties_list block next to it. Select Add Watch and you should see a balloon that will show the list filling up as the quiz runs.
multiple choice quiz
thanks for the source code!!!
i'l like to ask how to set this app so it will ask question and select choices intended for that question alone. just like on a multiple choice quiz
thanks again!
Hi,
Hi,
I'm doing a quiz on your app.
I've got pictures of famous people and 4 buttons with names. everything works great, BUT
when the buttons appear they are random. meaning that if you see a picture of a guy you can get female name
in ex.
picture: Marlon Brandon
who is it?
a) Marlon Brando
b) Angelina Jolie
c) Katy Perry
d) Kate Winslet
my question is (since I'm NOT so advanced as I thought) - how to assign sex to the pictures (I could do a list as I did connecting good answers and pictures like: male = 0, female = 1), but more important question: how to make my question generator to choose options only from one sex.
I'd be very grateful for help
ps the app will be non-commercial in case you wonder
Re: HI
HI Monica,
Good question! One way to do this would be to have another list containing the genders of the people in your questions, in the same way as we have an array of the pictures of the people in the questions. You will also need another variable to contain the gender of the person who is the right answer. Now if you dig into the generateButtonText block you will see a red-orange "or" block, this is attached to the bit of the block that generates the text for the wrong answers on the buttons. The bits inserted into this "or" block are the conditions that will cause the block to have another go at generating some text for this button (e.g. because that bit of text might already have been used). It should work here to add in an extra test in the "or" block to say that if the gender of the proposed wrong answer for the button (which you can get using the "select list item" block is "not =" to the gender of the right answer then it should try again.
Hope this helps!
How to run App Inventor
Hi Liam, thanks for such an awesome application... i have download in on my gingerbread android phone... It works very well... I want to use your app for creating quiz related to my subject... However, i am unable to install or probably run app inventor... i tried to follow the instructions provided by website, yet unable to start or even find app inventor.exe... could you please help... thanks in advance
thanks for the tutorial, i'm
thanks for the tutorial, i'm newbie in app inventor an android..this tutorial really help me
adding other picctures to the app (lists)
Thank you very much for this great tutorial, i've been working on your app to start with appinventor, and now, i'm looking for a way to show more than 1 image for each question. Let's say my quiz is a geography quiz, I not only want the quiz to show a map of the country, but also its corresponding flag, as well as some extra text-data (population, area, etc).
I've prepared my screen elements+ extra lists in the blocks editor, on the model of the penaltyimglist, but i don't know what to do next. I've read all the stuff i could find about lists, but i cant find any solution that works
thank you for your help