| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

View
 

Creating a random drill file

Page history last edited by Mike May, S.J. 12 years, 4 months ago

Creating a random drill file

By Mike May, S.J.

 

Method 1 – Answer acknowledged automatically

We can either set the applet up so that it automatically acknowledges when the correct answer has been reached, or we can set the problem up where it needs to be submitted. The automated approach is easier, so we will look at that first.

 

Example 1: We start with a simple example. We would like to have a random point designated, with the student given instructions to move a visible point to that location. When the point is moved to the correct point, a message should appear telling the student that they have found the correct point. There should also be some kind of button that picks a new random point.

 

We start with background stuff. We turn on the grid. In the options for the grid we select a distance of 1 for both directions. We create a point A, that will remain visible, and that will be dragged by the user.

 

For the target point, P, we need to be a bit more creative. We want it to be on a random lattice point. We recall that the Corner command returns the coordinates of the corners of the graphics window, with corners 1 and 3 being lower left and upper right, respectively. The x and y functions give the x and y coordinates of a point. The floor and ceil functions respectively round down and up to an integer. Thus RandomBetween[ceil(x(Corner[1])), floor(x(Corner[3]))] gives a random integer that can be an x coordinate of a lattice point in the graphics window. The y coordinate is defined analogously.

 

 

We now want to add three texts. The first text should give instructions that include the coordinates we want A dragged to. The second text is the congratulatory message if the student gets the problem correct. The third text lets the student choose a new problem.

 

For the first text we include the object P. Note that the coordinates show up in the preview.

 

 

For the second text, we want to go to the advanced tab and give a condition for the text to be visible. A word of caution is to be given about testing for equality. With points that we drag, we do not want to check for actual equality, since a difference in location smaller than one pixel is still inequality. For this exercise we will count two points as being equal if they are within .1 of each other.

 

 

The third issue is to let the user pick a new random point. We want to make it so that clicking on the third text picks a new point. To prepare, we create a variable test and give it the value 1. We then make it so that changing the value of test will cause the coordinates of P to be recomputed. We add test*0 to the upper bound for the coordinates. I also used the styling bar to change the background of the third text so that it looks like a button.

Now we add a script to text3, to make test=1-test. This means the value of test alternates between 0 and 1.

 

 

Finally, we remove the algebra window and customize the toolbar so give a minimal set of tools.

 

 

If this is put in a dynamic web page, the input bar can be suppressed.

 

Other example drills using the techniques of the first method:

 

This completes our first example. From a GeoGebra point of view, this gives us the skills needed for quite a number of drill sets. The issues for other drills are more mathematical. The user needs to think through what it means to have a randomly generated problem that will have a “nice description” so students can identify it. The user also needs to identify how we decide if a response is correct.

 

Example 2 – The applet should give the general equation of a line. The user should drag two points, so that the line they define matches the equation.

 

Assume that the graph is set up with the grid and lattice established. The user can see the lattice [-a,a] x [-b,b]. I wanted the line to intersect an axis at a lattice point, and I wanted the line defined by 2 easy to find lattice points. The equation has the format A x+B y+C=0. Our first effort would have A and B chosen randomly with –b≤A<b and –a≤B≤a. That would mean from one lattice point on the line, we can find another by going over A and up B. The one special case to be careful of is when both A and B are chosen to be 0, in which case we no longer have a line. In that case we will choose to make B=1. In terms of commands, this is done by choosing A and B1 randomly as before. The B is 1 if both A and B1 are 0, and B1 otherwise. To find a nice C, we need to decide if we are setting an x or a y intercept. We will look for a y intercept unless B is zero. For a y-intercept we want C to b B times a random integer in [-b,b]. For an x-intercept we want C to be A times a random integer in [-a,a].

 

To test the correctness of the student response, we look at the distances from the two points to our line. We count the solution as correct if both are less than 0.1.

 

Example 3 – The applet should give enough information about a sinusoidal curve to uniquely define the curve. The user should drag two points, so that the defined curve matches the equation.

 

There are two easy sets of data that define a sinusoidal curve. The first set is amplitude, period, x-shift and y-shift. The second set is the collection of constants A, B, C, D connected with an equation y=A sinB(x-C)+D. In setting the background of the applet, it is useful if the x-axis and grid are marked in units of π, or a fraction of π.

 

For the users curve we start with two points, P and Q, that correspond to a peak and the next midpoint of the curve. The coordinates of Q give the translations of the curve. The amplitude is the difference in y values, and the period is 4 times the difference in x values.

 

To check that the curve is correct we want to verify that P and Q satisfy the equation. We also want to verify that the points, satisfying the equation, corresponding to x values C, and C plus π/2 and π divided by B are on the curve.

 

Example 4 - The applet give the plot of a sinusoidal curve. The user then has 4 sliders to give a set of information that matches the curve.

 

This is simply the reverse of the previous example.

 

One can easily modify these examples to produce a number of other drills.

 

Method 2 – Answer must be submitted

 

For a second method of drill problem, we would like the student to have to submit the problem before GeoGebra evaluates it. (This reduces the ease for randomly dragging until the correct answer is found.) For this method we need to use buttons and scripts.

 

Example 1-B: We look at a second version of the applet for graphing a point.

 

 

As you can see form the layout, we have added three buttons to submit an answer, to show the solution, and to try a new problem. We also have a number of Boolean variables that keep track of where we are.

 

Obviously, we do not want the student to be able to submit an answer after checking the solution. We also want a change in the proposed solution to disable the message on correctness until the problem has submitted again.

 

With each button there is a collection of actions. The correct and incorrect messages should only be visible if MessageVisible is true. The submit button should make MessageVisible true. This button should only be visible if SolutionVisible is false. The show solution button should make SolutionVisible true. the new problem button should change MessageVisible, SolutionVisible, and ProblemSolved to false. It should also change the value of test so a new problem is computed.

 

These scripts are a collection of GeoGebra commands created with each button. They can be edited in the script tab when editing object properties.

 

 

The one other script we would like to add is to the point A. If the solution is shown, we would like a change in A to hide the solution again.

 

 

Method 3 – Using JavaScript to track performance

The final addition we will consider uses JavaScript in the webpage to keep track of how many problems the student has don and to look at how many tries they have made at the answers.

 

Consider the first example with this method.

 

 

Our buttons have been moved from the applet to the html page.

 

The JavaScript code I used to do this can be a bit intimidating.

 

<script type="text/javascript">

// the JavaScript has a function for each button

function showSolution(objName) {

var applet = document.ggbApplet;

applet.setValue("SolutionVisible",1);

applet.setValue("ProblemSolved",1);

var ProblemsShown = applet.getValue("ProblemsShown");

var ProblemsSolved = applet.getValue("ProblemsSolved");

var TriesThisProblem = applet.getValue("TriesThisProblem");

var TriesTotal = applet.getValue("TriesTotal");

document.outputForm.TextAreaOutput.value =

"Problems shown = " + ProblemsShown +

" Problems Solved = " + ProblemsSolved +

"\nTries this problem = " + TriesThisProblem +

" Total tries = " + TriesTotal;

};

</script>

 

<script type="text/javascript">

function submitSolution(objName) {

var applet = document.ggbApplet;

var TriesThisProblem = applet.getValue("TriesThisProblem");

var TriesTotal = applet.getValue("TriesTotal");

var ProblemSolved = applet.getValue("ProblemSolved");

var ProblemsSolved = applet.getValue("ProblemsSolved");

var SolutionVisible = applet.getValue("SolutionVisible");

var ProblemsShown = applet.getValue("ProblemsShown");

var DisAP = applet.getValue("DisAP");

applet.setValue("MessageVisible",1);

document.outputForm.TextAreaOutput.value =

"barney.";

if (ProblemSolved>0) //Check if the problem is already done

{ document.outputForm.TextAreaOutput.value =

"You may not submit a problem after solving it"+

"\nor after moking the solution visible."+ProblemSolved;

}

else

{

applet.setValue("TriesThisProblem",TriesThisProblem+1);

applet.setValue("TriesTotal",TriesTotal+1);

if (DisAP<.1) //This line is the test if the problem is correct.

{applet.setValue("ProblemSolved",1);

applet.setValue("ProblemsSolved",ProblemsSolved+1);

}

document.outputForm.TextAreaOutput.value =

"Problems shown = " + ProblemsShown +

" Problems Solved = " + applet.getValue("ProblemsSolved") +

"\nTries this problem = " + applet.getValue("TriesThisProblem") +

" Total tries = " + applet.getValue("TriesTotal");

applet.setValue("MessageVisible",1);

};

 

}

</script>

 

<script type="text/javascript">

function newProblem(objName) {

var applet = document.ggbApplet;

var test = applet.getValue("test");

var ProblemsShown = applet.getValue("ProblemsShown")+1;

applet.setValue("test",1-test);

applet.setValue("ProblemsShown",ProblemsShown);

applet.setValue("SolutionVisible",0);

applet.setValue("MessageVisible",0);

applet.setValue("ProblemSolved",0);

applet.setValue("ProblemSubmitted",0);

applet.setValue("TriesThisProblem",0);

var ProblemsSolved = applet.getValue("ProblemsSolved");

var TriesThisProblem = applet.getValue("TriesThisProblem");

var TriesTotal = applet.getValue("TriesTotal");

document.outputForm.TextAreaOutput.value =

"Problems shown = " + ProblemsShown +

" Problems Solved = " + ProblemsSolved +

"\nTries this problem = " + TriesThisProblem +

" Total tries = " + TriesTotal;

}

</script>

 

<script type="text/javascript">

function setOutput(objName) {

var applet = document.ggbApplet;

var ProblemsShown = applet.getValue("ProblemsShown");

var ProblemsSolved = applet.getValue("ProblemsSolved");

var TriesThisProblem = applet.getValue("TriesThisProblem");

var TriesTotal = applet.getValue("TriesTotal");

document.outputForm.TextAreaOutput.value =

"Problems shown = " + ProblemsShown +

" Problems Solved = " + ProblemsSolved +

"\nTries this problem = " + TriesThisProblem +

" Total tries = " + TriesTotal+

"\n ProblemSolved, SolutionVisible, MessageVisible, "

+ProblemSolved+""+SolutionVisible+" "+MessageVisible;

}

</script>

<form name="functionForm"

onsubmit="setOutput('T'); return false;">

<input value="Submit Problem"

onclick="submitSolution('T');" type="button">&nbsp;

<input value="Show Solution"

onclick="showSolution('T');" type="button">&nbsp;

<input value="New Problem"

onclick="newProblem('T');" type="button">&nbsp; <br>

</form>

<form name="outputForm" onsubmit="setOutput('T'); return false;">

<textarea name="TextAreaOutput" rows="2" cols="70"

value="Problems Shown = 1, Problems Solved = 0, Tries this problem = 0, Total tries = 0."

onchange="setOutput('T');"></textarea>

</form>

 

 

You should note that, there is only one line that changes with a new drill. It is the line that tests if the submitted solution is correct.

 

Comments (0)

You don't have permission to comment on this page.