Input Box for answering
adding two integers
Next applet shows an exercise in which the sum of two integers is asked. Conditional coloring of the Input Box gives feedback. Then try it yourself, following the given Construction Steps.
Try it yourself...
Construction Steps
1 | | Type the command a = RandomBetween(1, 10) in the input bar and create the number a. |
2 | | Type the command b = RandomBetween(1, 10) in the input bar and create the number b. |
3 | | Type the command sol = a + b in the input bar and create the number sol. |
4 | | Type the command ans = 0 in the input bar and create the number ans. |
5 | | Select the Text Tool and create the dynamic text a + b. Select a and b in the list of available objects to make the text dynamic. |
6 | | Select the Input Box Tool and click in the Graphic to create an Input Box with Caption = and Linked Object ans = 0. Confirm with OK. Note: In the properties you can modify the length (in tab Style) and the Textstyle. |
7 | | Select the Button Tool and click in the Graphic to create a button with label new exercise and GeoGebra Script UpdateConstruction(). |
Feedback with conditional colors
You can color the Input Box red when the answer is wrong and green when it's correct by using dynamic colors.
- Rightclick on the Input Box.
- Select Objects Properties to open the dialog.
- Select the tab Avanced
- The syntax for Red: if ans is not equal to 0 neither to sol, the Input Box turns red. If not it doesn't.
- The syntax for Green: if ans is equal to the solution it turns green. If not it doesn't. Note: By using 0.7 instead of 1 the green is slightly darker.