# Button updates random variables though the code doesn't say so

M.E shared this question 4 years ago

I have created the attached exercise generator which also evaluates the answers.

Here the students are going to move a parabola so it fits to specific criteria regarding the constants; a, b, c and d.

The problem is that when I press the evaluation button "Evaluer graf" (meaning "Evaluate graph"), the criteria is being updated. And I can't find a way to solve this problem.

I hope someone can help me.

You must change "=" to SetValue[] in your scripts as Chris says.

1

I downloaded the added file, but the problem you describe doesn't occur to me, the criteria don't change.

But a general advise is to change the many net attributions in both buttons from e.g. <object> = into "SetValue(<object>,<value>)

And of course this is no answer to your specific question but I have used another way to make dragging exercises with parabolas, using two given points: top, a random point (and a third hidden point that's the reflection of the free point). With these two draggable points one can make exercises like yours using the identification method you use to (a, b,... out of the list of coefficients) and drawing parabolas with the top up or down.

Perhaps it's easier to distinguish the different exercises and solutions to start with a variable e.g. k that defines the type of exercise, like a=If(k<3,1,-1) where a is positive for k<3 and negative else. If you work with signs you don't have to work with randoms. The only random is k that controls the type of graph.

Secondly I'd define the evaluating signs for a true of false solution by dragging the graph itself and use the evaluate button just as a boolean show= true or false to show them.

Since a, b... change by dragging you don't need any assignment in the evaluate button any more. Maybe getting these assignments out of the evaluate button is just the solution of the updating problem you mentioned,

It's just a suggestion to simplify.

chris

1

I prefer that the students have to place the graph first and then have

the opportunity to get it evaluated by the pc. Because if it is possible

for the students to move the graph and on the same time see when the

graph match the criterias, then the exercise won't encourage students to

make as many considerations as if the graph is only evaluated each time

they click on a button. Here they are encouraged to consider where the

graph should be placed (next) as it would take more time to just move

the graph more or less randomly and get the pc to evaluate it.

1

You must change "=" to SetValue[] in your scripts as Chris says.

1

Ok.

I have found the function in danish;

TildelVærdi( <Boolesk>, <0|1> )

TildelVærdi( <Object>, <Objekt> )

TildelVærdi( <Liste>, <tal>, <Objekt> )

Which one of them can I use and how ?

ccambre mentioned "SetValue(<object>,<value>)". I can't find that one.

1

The name of the parameter in the command doesn't matter, so for Setvalue() with two parameters use TildelVærdi( <Object>, <Objekt> ) and type your command. For the second parameter, fill in the expression you used earlier in your command e.g. for a = .... , including all nested conditions

chris

1

Thank you very much, that solved the problem. :)

1

Here's an alternative solution, using a minimum on scripting, but working with tests.

A random k defines the conditions for a, b, c and d (from 1 to 20) as teka=If( k...)

So I start with the solution and not with random a, b and c's.

You can draw all kinds of parabolas dragging the two points

The values of a, b, c and d of the drawn parabola are defined as para= If(a...)

Now it's easy to compare teka with para etc and to give feedback using dynamic colors on the texts with the conditions

chris

1

Moved

1

Hi

When you click"evaluer" button, you should stop move curve

2) in "evaluer" button script :

Show your duplicate curve gladd or surr (those curves are fixed) with same command

Hide "evaluer" button

3) create an other button "try again"

1

Why... ?

1

Your problem was that when you click on "evaluer" button, a, b, c and d are updated, ok

But you also write

Because if it is possible for the students to move the graph and on the same time see when the

graph match the criterias, then the exercise won't encourage students to

make as many considerations as if the graph is only evaluated each time

they click on a button. Here they are encouraged to consider where the

graph should be placed (next) as it would take more time to just move

the graph more

So, with my other button, students can't move the curve and see in real time if it is good or not (and find solution in few seconds)

(It was just an idea, no problem if you don.t like it...)

2

Sorry, I only asked of curiosity since I couldn't see the purpose of it.

I have made the applet so that the students has to click on the evaluate button every time they want to check if their graph fits the criterias. So I don't need to do more about that.

But thank you for your surgestion.

1

Another challenge have come up...

In the click script for the button "Nye kriterier" (meaning "new criterias") I have written this:

"TildelVærdi[d, Hvis[a < 0 ∧ c > 0, 1, Hvis[a > 0 ∧ c < 0, 1, Hvis[b < 0 ∧ c ≟ 0, 1, Hvis[a > 0 ∧ b ≟ 0 ∧ c > 0, -1, Hvis[a < 0 ∧ b ≟ 0 ∧ c < 0, -1, Hvis[b ≟ 0 ∧ c ≟ 0, 0, Hvis[b > 0 ∧ c ≟ 0, 1, TilfældigMellem[-1, 1]]]]]]]]]"

Where:

TildelVærdi = SetValue

Hvis = If

The problem is that though these part is in the script, d gets a wrong value:

IF[a < 0 ∧ c > 0, 1 Here I often get d < 0 when a > 0, b < 0 og c > 0, though it should return d > 0,

I can't find the reason for this.

1

You don.t test all possibilities.. so you often go in d=TilfaeldigMellem[-1,1]

Why don.t you test if b^2 < or == or > 4 a c..?

(Your last file is better than the first because you need tap "evaluer"" to see evaluation...

That was why i proposed you my button "try again"... my idea was good if you want to count number of tries...)

1

Your right, it would be easier to just test for b^2 < or = or > 4 a c.

1

Sorry, but it does it again...

For example I get:

a < 0

b < 0

c > 0

d < 0

And I have tried to change the d variable as it is defined as TilfældigMellem[-1, 1] (meaning random between) in the Algebra window. But as soon as I'm out of that particular field, it is changed back to TilfældigMellem[-1, 1].

1

Hmm my b^2 - 4ac is not good because your d is not b^2 - 4 ac !

Tell me if it works if you put "d" instead of "TilfældigMellem[-1, 1]" in your script

"TildelVærdi[d, Hvis[a < 0 ∧ c > 0, 1, Hvis[a > 0 ∧ c < 0, 1, Hvis[b < 0 ∧ c ≟ 0, 1, Hvis[a > 0 ∧ b ≟ 0 ∧ c > 0, -1, Hvis[a < 0 ∧ b ≟ 0 ∧ c < 0, -1, Hvis[b ≟ 0 ∧ c ≟ 0, 0, Hvis[b > 0 ∧ c ≟ 0, 1, TilfældigMellem[-1, 1]]]]]]]]]"

1

No it is fine, I changed the code you have cited to:

TildelVærdi[d, Hvis[b^2 < 4*a*c, -1, Hvis[b^2 ≟ 4*a*c, 0, 1]]]

So that should solve the problem.

And I have just managed to change the status of variable d. Somehow I couldn't do it yesterday where it seemed locked. But maybe a new startup solved that problem.

Once again thank you very much for your suggestion. :)

1

I finally understand your bug lol

"TildelVærdi[d, Hvis[a < 0 ∧ c > 0, 1, Hvis[a > 0 ∧ c < 0, 1, Hvis[b < 0 ∧ c ≟ 0, 1, Hvis[a > 0 ∧ b ≟ 0 ∧ c > 0, -1, Hvis[a < 0 ∧ b ≟ 0 ∧ c < 0, -1, Hvis[b ≟ 0 ∧ c ≟ 0, 0, Hvis[b > 0 ∧ c ≟ 0, 1, TilfældigMellem[-1, 1]]]]]]]]]"
It is not a>0 but a==2

It is not a<0 but a==1