How do you calculate correct answers and wrong answers in a quiz app?

I created the app as you told. But I Want to tell user given answer is right with background color of selected button is green color, else background color is red when user click the option.
How to do it ?
Please help I am going to create educational quiz app ?

1 Like

Show us what you created, .aia and Blocks.


I tried this but it doesn't work.

original aia file of Taufinquiz.aia (10.5 KB)

1 Like

I see what you did wrong.

The original app did not bother to help the quiz taker know what he got right or wrong. It waited until the end of the quiz before checking the newly completed list of student answers against the official list, just to calculate a total score.

You tried to squeeze question by question feedback into that end-of-test summation pass, without pausing to show the questions and answers along with the colors.

You need to decide when you want to show your feedback:

  • after each question is answered and before the user clicks a (new) Next Question button, or
  • after the test is finished and a second pass of the questions and answers is started, also with Next and/or PREV buttons to walk the questions and answers, one by one.

Which approach would you try?


I wanted to show my feedback when student answer that question and after that student will click next button to go ahead

I made quiz app there I did this. But by that method it increases number of blocks. I want to reduce it.

1 Like

Please download and post each of those event block(s)/procedures here ...
(sample video)

1 Like

1 Like

Export your .aia file and upload it here.

(we can't read collapsed blocks and we can't edit screenshots).

Don't you find it contradictory to set answer background colors to all different pastel colors then switch their color scheme when answered?

Also, you are at the point where you should consider loading your lists from Media .csv files, rather than from hardcoded block lists.

1 Like

FirstMarathiEnglishQuizApp.aia (115.0 KB)

If I can create it with csv then I can create more questions for students. Now due to more blocks I have limitation of question.
So please solve my problem.

1 Like

The first step in reducing blocks is to get all the questions, answer candidates, and correct answers out of text blocks and into a spreadsheet, so it can be exported as a csv text file and loaded into the Media folder.

Columns for a quiz:

  • question
  • correct answer
  • answer for button 1
  • answer for button 2
  • answer for button 3
  • answer for button 4

Thanks for reply but how to implement it and with the use of spreadsheet can I make offline app ?
Is it possible to show with blocks ?

in this case you can use files in csv format, probably easiest is to have a file with the questions like this

This is question 1
This is question 2
This is question 3

and another file with the answers

This is the correct answer for Q1, another answer 1,another answer 2, another answer 3
This is the correct answer for Q2, another answer 1,another answer 2, another answer 3
This is the correct answer for Q3, another answer 1,another answer 2, another answer 3

store the files in the assets, read them on first run of the app, convert them into lists and assign them to the question and answers list
do a search in the community for these steps in case you need help...

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here and the aia files for the projects in the book are here:
How to do a lot of basic things with App Inventor are described here: .

Also do the tutorials to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.


Thank You. I will study these.

Sorry sir but I I didn't find any tutorial for this in community. I am eagerly want to make app for my students. please can you help me?

Have you read

1 Like

Yes. I understand how to store questions and answer in list. I got how to create the quiz and display result after user solve all questions. But I want to set background color green of button which user clicks if it is correct answer else red.And the background color of button should set green which has correct answer.
That is the point which I am not understanding. Sorry to bother you.

Devise a way for the user to spend time to see the colors you set in response to their answer.

Didn't understand, how to do it ?

I tried to apply a generic click event to your 4 answer buttons in screen3, then discovered you had several sets of 4 buttons each in that screen, and i did not have the language skills to tell which was right.

Here is the generic button click event I wrote, to replace the Samanya1-4 click events.
FirstMarathiEnglishQuizAppABG.aia (111.1 KB)

Your Screen3 is too complex for me to work with, with so many extra buttons in a language I don't understand.

P.S. Please read through the logic of this generic answer button handler and tell me if it makes sense to you.

P.P.S. It might be necessary for you to turn off button feedback for your 4 answer buttons in the Designer, in case the click animation interferes with background color replacement.

P.P.P.S. What is the difference between the two global variables CurrentflagSamanya and QuestionNumberSamanya? Why do you need two variables?

1 Like

Thank You So much It Works. You are genius.
It reduces some blocks.
In my project I made 4 List for options, 1 list for questions and 1 for answers so If I take 25 question then there might be 150 blocks only for quiz answer and options. That is why I want to develop quiz app as Taifun made. to make list for option in one csv
Can this logic work with this type of list as shows in Image blocks.

As shown in image, Can be implemented nextQuestion procedure in my app ?

I am sharing aia which you create for me with some modifications . Now I made it in English.FirstMarathiEnglishQuizAppABG.aia (106.5 KB)