Guide For Making A Simple Quiz App
Guide For Making A Simple Quiz App
Contents
http://ai2.appinventor.mit.edu/
Components
This is where
you will see
ALL the
components
Palette Viewer Properties
your app has,
This is how the app will This is where you customise a
All the components and the
look. You can rearrange component.
you can add are here. structure of
items in the viewer by Click on the component in the
Buttons, Images, etc your app.
clicking and dragging Components screen to see its
them . properties here.
1.6) Drag a “Vertical Arrangement” into your Viewer
You should now have three in total and your screen should look like the below.
We will put a picture in the top box, a question in the middle box and some buttons for choosing
answers in the bottom box.
1.8) MAKE SURE YOUR COMPONENTS SHOW 3 VerticalArrangements. Do not confuse it with
HorizontalArrangements!
1.9) Let’s make the arrangement boxes the right size. Change the properties of the
VerticalArrangements as follows:
In the Palette, find “image” (part of “User Interface”) and drag it into the top box.
1.12) In the Properties panel change the Height and Width to “Fill parent”
1.13) Change the picture.
ReadOnly = tick
To make the buttons sit next to each other you must use a HORIZONTAL ARRANGEMENT. (Horizontal
means “sideways”).
1.18) Change the properties of the HorizontalArrangement for the width and height so it Fills parent:
1.19) Add two buttons from the Palette (in the “User Interface” section).
x2
1.20) Change their properties so the width is Fill parent, and change the text so one answer is
correct and the other answer is wrong.
---------------------------------------------------------
2.2) It is best practice to give things sensible names. You are NOT allowed any spaces in the name
Click “OK”.
2.3) Let’s put a message in the middle of the screen.
2.4) Make the Height of the top and bottom boxes “Fill parent”. Do NOT change the Height of the
middle box.
2.6) Add a label to the middle box. Change the properties of the label so it says “You win!”, the width
is “Fill parent” and the text is nice and big.
Remember, the “Arrangement” boxes are invisible. So when you run the app all you will see is “You
win!” in the middle of the screen. This is exactly what we want.
---------------------------------------------------------
Section 3: Creating the screen for losers
3.1) We need to make a screen for when you lose.
3.2) It is best practice to give things sensible names. You are NOT allowed any spaces in the name
Click “OK”.
3.3) We want to add a message and a button to the middle of the screen.
Make the Height of the top and bottom VerticalArrangements “Fill parent”.
Change the properties of the button so it reads “Try again” and the text is bigger and centred.
Remember, the “Arrangement” boxes are invisible. So when you run the app all you will see is
“Wrong answer!” and the button with “Try again” in the middle of the screen. This is exactly what
we want.
Now we need to add a little code to our quiz, so it will change screens when the buttons are
pressed…
---------------------------------------------------------
Section 4: Adding code
4.1) To add and edit code, you need to go to the coding window.
General code is
here.
Most of the time
you will access a
component first
(see below), then
link it to some This is where your blocks of code will appear.
general code
afterwards. There are lots of useful options when you
RIGHT-click in this space, such as tidying up
your blocks or saving a picture of them.
4.4) Choose the block “when Button1.click do”
4.6) Clip this block into the previous block.
4.7) When someone playing the quiz presses “Button1” a new screen should be opened.
Depending on whether Button1 is the correct or wrong answer, you need to change “Screen1” to the
appropriate option. (Click on “Designer” at the top right of the screen if you cannot remember).
4.8) Add another block of code for “Button2” that takes you to the other screen.
Screen1 (the screen with the question on) is finished now. But there is on more button that needs to
be coded. Do you remember where it is?
4.10) Click on “Button1” in the panel on the left, and add the “when Button1.click do” block.
4.11) Now open the “Control” section and choose the block called “Close screen”.
---------------------------------------------------------
Section 5: Testing your app
Let’s test the app!
You can connect from the Designer or Blocks screen – either will work.
5.1) Make sure you have “Screen1” open (otherwise you will not start the app in the correct place).
5.3) On your phone, open the MIT App Inventor app and scan the QR code.