I think this is more of a question about how the variables update and communicate than it is about a specific piece of code, but what I’m trying to do is have students type an expression that matches a graph and then have that expression be graphed in the graph window. That part works fine.
The concern is that it graphs in real time, so every new character updates the graph. I’d like it to wait until the students are ready to check before actually graphing their expression. Here is what I tried:
I tried using the timeSincePress function with some conditionals to only update the function when timeSincePressed resets to zero:
fn1 =
when try1.timeSincePress = simpleFunction(eqn1.latex)
otherwise = simpleFunction("")
But this doesn’t work because, although I think it probably is updating when timeSincePress = 0, it instantly re-updates back to the default.
I’ve tried some other variations (adding more conditionals, changing the syntax or where the function assignment goes, etc) but haven’t found anything that works.
Basically, I want to store the contents of a student generated expression when they click try it and have that value persist until they click try it again. Is there a way to store a value like that? Everything seems to update so dynamically. Thanks for any help.
That’s cool and it’s a good start, but it only works once. I’d like the students to be able to do several “tries” on the same screen before clicking the submit to teacher button.
I modified to use timeSincePress for the Action Button to define “t”, which hides the function until the initial press, but after the initial press, the function definition is dynamic so any change the student makes to the expression is reflected immediately. I want the old function to remain until they hit the Action Button again.
It might look like this:
Student types x+3 [nothing happens]
Student hits “Try It!” button [y=x+3 appears]
Student edits the expression to x + 4 [y= x+3 remains]
Student edits the expression to x + 5 [y = x+3 remains]
Student clicks “Try It!” button again [y=x+3 is replaced with y=x+5; y=x+4 is never graphed]
Thanks so much for the quick responses. This is almost exactly what I want, but still not quite. Is there a more generic capture function than the “lastValue” function? Or maybe a better question is, how exactly does the lastValue funciton work? What is the string parameter that it requires? Is there a way to just capture the entire expression string at a specific time and then store it until a later time? Thanks again!
I was able to get the behavior I wanted directly through the Expression Input component by using the “submitted” boolean source. I just changed the name of the “Submit to Teacher” button to “Try It!”
By connecting the function definition to the submitted status it won’t show up until they click the button, and then once they begin editing the expression, the status revert back to not submitted so the function disappears. This isn’t exactly what I had envisioned, but it’s actually better!
Here’s the code I used:
function(“f”): when eqn1.submitted simpleFunction(eqn1.latex) otherwise simpleFunction(“1000”)
So easy.
The “capture” functionality didn’t work for me because there were multiple ways they can enter the equation. It might be nice to have a similar “capture” for LaTeX expressions, not just numerical values.
Looks great! It still looks like it won’t graph lines in other forms like standard ax+by=c. Although not ideal you may want to think of using rawExpression if you want to graph implicit functions.