Google Classroom
GeoGebraGeoGebra Klaslokaal

making calculations

Introduction

Many exercises deal with making calculations. This is a model for creating random generated exercises in which the result of the calculation has to be typed in an empty textfield. Feedback is given by coloring the answer. Additionally the correct answer can be shown.

How to do this?

  • Two numbers: Define the random numbers a and b. a = RandomBetween[1, 20] and b = RandomBetween[1, 20].
  • Solution: define the solution. sol = a + b remark: By naming it sol you can easily adapt the file for another exercise.
  • Answer: define a number to use as anwer and give it a value, that's certainly not the solution. ans = pi
  • Empty inputfield: create an empty inputfield to type in the answer by using following steps - Create an empty text: empty = "" - Create an Input Box with caption "=", select "empty" as Linked Object and click on OK.
  • Assigning the typed text to ans: - Rightclick in the Input Box, open the Properties and select the tab Scripting. - Type the scripting command SetValue[ans,%0] to assign the typed text to the variable ans.
  • Feedback on the answer: We'll give feedback on the answer by dynamic coloring of the typed text in the Input Box. - Rightclick in the Input Box, open the Properties and select the tab Advanced. - Define the dynamic colors of the Input Box: Red: If((empty ≠ "") ∧ (ans ≠ sol), 1, 0) Green: If((empty ≠ "") ∧ ans ≟ sol, 0.7, 0) Blue: 0 remark: 0.7 instead of 1 for green gives a slightly darker green which is better to read.
  • Showing the solution: - Type the calculation and the right solution in a dynamic text. - Define a checkbox with the text show solution to control the visibility of the solution.
  • Button: Create an action button with caption new exercise and type following scripting commands: UpdateConstruction[] SetValue[empty,""] SetValue[ans,pi] SetValue[show,false] This script recalculates all random numbers, makes the Input Box empty and unchecks the checkbox.