Tutorial : Making self-correcting exercise with GeoGebra

  • Create a GeoGebra account.
  • Using a display condition dependent on a variable.
  • Use a display condition with a logical operator. (coming soon)
  • Use a display condition depending on a geometric relationship. (coming soon)
  • Compare two geometric objects. (coming soon)
  • Use an auto-validation script. (coming soon)

Using a display condition dependent on a variable

It is quite simple to set a condition under which an object is displayed. This object can be a text, an image, a geometric object or any other object built with GeoGebra.


For example, in the applet shown here, as long as the calculation is false, the message “This is not the result” is displayed. It will be replaced by the message “Very good” when the result is correct.




Here are the steps for its creation:

Start by creating all the objects without worrying about which ones you want to display or not. Here, there are

  •  The instruction text.
  • The input box which allows you to enter the answer. 
  • The number which serves as a variable and which takes the value entered in the text field. It must therefore be created before the text field.
  • The two texts which are displayed according to the correctness of the answer.

You then have to enter the conditions to show the two texts that validate or not the answer.


  • The text "This is not the result!" is displayed if the number "Answer" is not 21.
  • The text "Very good!" is displayed if the number "Answer" is equal to 21.

For that, it is necessary to go to the properties of these objects and in the tab "Advanced," to enter the condition  in the field "Condition to Show Object":

You have to type "Answer == 21"

You have to type "Answer != 21"

The file is now ready. Before saving, the algebra window must be closed: this prevents the students from easily finding/modifying the display conditions and it is more aesthetic...

Change the colour of an object according to the answer


It is also possible to change text color (or the color of any other object with a changeable color) according to the results given.


For example, in this applet, as long as the answer remains 0, the calculation is written in blue. If you enter a (different) wrong answer, it is written in red and it becomes green if the answer is right (and the message "Very good" appears).

To do this, you must use the "Dynamic colors", always in the "Advanced" tab of the properties: 


  • The object will be green if the calculation number is equal to 21.
  • The object will be blue if the calculation number is equal to 0.
  • The object will be red if the calculation number is different from 21 and 0.

Note that the logical AND is written as "" in GeoGebra (note that it is not a circumflex). To get it, you can type "&&" on the keyboard.

In GeoGebra version 5 you can use the symbol table of the software. The symbol table can be found at the end of the input line by clicking on "α"). 

In GeoGebra version 6 you can use the virtual keyboard.

Note on colors


The conditions used for the use of colors are logical tests: they take the value 0 or 1.


The colors are defined by a number between 0 and 1.


It is therefore possible to obtain shades of color by multiplying the tests by a number between 0 and 1, as shown here.

It is also possible to mix these 3 colors to obtain any color: to do this, you just need to assign them the same test. It is also possible to play on the opacity of an object.