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
[table][tr][td]1[/td][td][/td][td]Type the command [b]a = RandomBetween(1, 10)[/b] in the input bar and create the number [i]a[/i].[/td][/tr][tr][td]2[/td][td][/td][td]Type the command [b]b = RandomBetween(1, 10)[/b] in the input bar and create the number [i]b[/i].[/td][/tr][tr][td]3[/td][td][/td][td]Type the command [b]sol = a + b[/b] in the input bar and create the number [i]sol[/i].[/td][/tr][tr][td]4[/td][td][/td][td]Type the command [b]ans = 0[/b] in the input bar and create the number [i]ans[/i].[/td][/tr][tr][td]5[/td][td][icon]/images/ggb/toolbar/mode_text.png[/icon][/td][td]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.[/td][/tr][tr][td]6[/td][td][icon]/images/ggb/toolbar/mode_textfieldaction.png[/icon][/td][td]Select the Input Box Tool and click in the Graphic to create an Input Box with Caption [b]=[/b] and Linked Object [b]ans = 0[/b]. Confirm with OK.[br][u]Note[/u]: In the properties you can modify the length (in tab Style) and the Textstyle.[/td][/tr][tr][td]7[/td][td][icon]/images/ggb/toolbar/mode_buttonaction.png[/icon][/td][td]Select the Button Tool and click in the Graphic to create a button with label [b]new exercise[/b] and GeoGebra Script [b]UpdateConstruction()[/b].[/td][/tr][/table]
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. [br][list][*]Rightclick on the Input Box.[/*][*]Select Objects Properties to open the dialog.[br][/*][*]Select the tab Avanced[/*][/list]
[list][*]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.[br][u]Note[/u]: By using 0.7 instead of 1 the green is slightly darker.[/*][/list]To prevent the Input Box from turning red when clicking on the button [i]new exercise[/i] we have to add a supplementary command in the script of the button. Rightclick on the button and add in row 2 following command: [b]SetValue(ans,0)[/b], which turns the number ans back to 0.

Information: Input Box for answering