Multiple Correct Answers in Textbox based quiz (Quiz has multiple questions)


Problem: I should be able to enter multiple correct answers in this quiz.
Example: For the first question, I should be able to enter
Sweden (Sweden, with a space)


You can use these Blocks to 'normalize' your answers


Removes any spaces leading or trailing the input string and returns the result.


Returns a copy of its text string argument converted to all upper case.


Returns a copy of its text string argument converted to all lower case.


also, you can remove spaces using this Block

Where should I find these blocks and how should I use them?

The Blocks are in Block window MIT App Inventor Text Blocks .

How you use them depends on how your app uses a TextBox to type in an answer to a question and how you determine what is a correct answer.

There are several ways the Blocks can be used. A simple way is to use If then statements.

To make things easier to code, all your correct answers in your routine that indicates a correct answer could be all UPPER case or lower case.



How do I implement the "replace all text" block on clicking a button for 5 such questions?

Sorry, I have no idea because I do not know what the Blocks you have coded so far do. Post an image of your Blocks?

Fill in the missing AnswerList and CurrrentQuestionIndex in this example and you might have what you want.

The segment is filled with a space; replacement is filled in with an empty Text Block.

There are other ways to do the normalizing.

Now your turn to experiment and see what works for you. :slight_smile:

Here are some resources to help you learn to use the AI2 tools. A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook App Inventor 2 Book: Create Your Own Android Apps ... 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 Course In A Box and the aia files for the projects in the book are here: App Inventor 2 Book: Create Your Own Android Apps

How to do a lot of basic things with App Inventor are described here: How do you...? .

Also look here App inventor español. Offline. Tutorial. Ejemplos. Instalación. Códigos. Juegos. Curso gratis de App inventor. and here Tutorial Index | Imagnity for more tutorials

Learn about components Component Reference
and visit the Library The MIT App Inventor Library: Documentation & Support Help>Library on the MENU


I have to add it to the "Submit_button" block, right?

That is what I would do. Why not try doing exactly that, fill in the missing orange Blocks of yours and try it?

What should I fill in the "then" section of that if statement?

perhaps make it 'look' like your existing answer logic. :astonished:

Change TextBox2 to Answer_input_box too.

The solution isn't working. The app's aia is given below.

FlagQuiz (1).aia (169.9 KB)


add a trim to the right side too.

1 Like

Where can I get that "or" block that you used in those examples?


Tests whether any of a set of logical conditions are true. The result is true if one or more of the tested conditions are true. The number of tests can be expanded using the mutator. The conditions are tested left to right, and the testing stops as soon as one of the conditions is true. If there are no conditions to test, then the result is false.

You should read the Inventor's Guide in the above link and particularly


Actually, I can find these types of blocks: can I use that instead?

Certainly or convert the Block using external inputs. Why didn't you read the link showing how to do this that is provided in Post number 16 ?

Even after implementing all this, if I enter my answer with a whitespace, it returns my answer as incorrect. What should I do?

Here is one way that might work:

There are other ways but all the other possibilities involve checking to find out if you Answer_input_box contains any text too.

See Programming Your App to Make Decisions