ResetOnChange Sink

Hi All –

I’m interested in exploring the “ResetOnChange” Action Button sink. Does anyone have a working example they’d be willing to share?


Coincidentally, I just posted an example in another topic that uses ResetOnChange. Here you go:

1 Like

Thanks Craig! Much appreciated!

Is there a way to use resetonchange with an ordered list or numerical input or text input?

This might help for the inputs.

Yes, that’s what I’m trying to do. But all the examples I’ve seen use the command with graphs. I can’t figure out how to reset the button if an ordered list is changed.

Something like this resets the button. This is based on 3 items in the list.

resetOnChange: "${order.indexOfItem(1)}${order.indexOfItem(2)}${order.indexOfItem(3)}"
1 Like

Thanks. I’ll try that.
Where can I find instructions on how to write such code?

There isn’t much documentation on this sink, unfortunately. I did look in the documentation for something that would be considered a “change” in the ordered list. I’m sure the method I used isn’t the only way the button will reset.

Thanks again for the previous code. It worked great.
Does button reset also work to check typed answers?

So basically, whatever you want to reset you need to list out as the sink’s parameter?

I’ve never used it, but it looks like it does. This would be for a text input:

resetOnChange: "${text.content}"

This would be math input:

resetOnChange: "${input.latex}"
1 Like

Basically. I’ve only used it a few times when the timeSincePress didn’t automatically reset. Usually it’s for an interactive object in a graph.

resetOnChange will fire whenever it detects a change in any text string, so looking for anything that changes at the moment you want it reset will work. Just make sure that number or boolean values get some sort of string representation. resetOnChangeExamples • Activity Builder by Desmos

I want the student to hit the check answer button to determine if their answer is correct. I don’t mind if they do if for each cell, but the problem is that I can’t get the button count to reset to zero. I am trying to avoid the check mark showing up when they enter the last character of the correct answer. It also needs to leave the check mark from any problems they get correct, so it might be more difficult than i thought.

There are several attempts shown in my code. Can anyone tell me what the issue is? Really trying to figure this stuff out, and everyone is so incredibly helpful.


For tables, I usually use something like this for each cell (in this case answers are being placed in the second column):

check1= (your condition for first cell's correctness here)
cellSuffix(1,2): when isBlank(this.cellContent(1,2) or this.cellHasFocus(1,2) ""
when check1 "✅"
otherwise "❌"

Doesn’t even require a button. You could also instead use cellContent(1,3): if you’d rather use a separate cell instead of a suffix.

I use the suffix as well…but the issue I have is this: Let’s say the correct answer is “5”, and a student thinks the answer is “52”. The student will get the check mark the instant they hit the 5. I was looking for a work around so that would not happen.

I will second Daniel’s suggestion for checking tables as I use that method as well. It’s less code and it won’t mark the problem until an answer has been typed and the student has clicked out of the cell. Here’s an activity I had made that uses this method so you can see what it looks like.

I looked at your code and the reason it’s not working is that you need to change your check variable to check=checkWork.timeSincePress>0. The problem with this is that if you try to use resetOnChange with the button (which you are trying to do), the problem will get marked wrong as soon as the student tries another problem. Because of this, you will want to capture the previous answer using this method.

Both of these methods work, but since you have a lot of rows in this table, I think the first method might be quicker.

Just another suggestion as the checking is trying to match a string, I would suggest using patterns or maybe simpleFunction with evaluateAt paired with countNumberUsage to check for correctness. Here’s an example of how to use patterns with the first problem using your original code:

p = patterns
p1=p.sum(p.product(p.number.satisfies("x=5"), p.literal("x")), p.number.satisfies("x=8"))
cellContent(1,4): when p1.matches(t.cellContent(1,3)) and check "✔️" otherwise "❌"

I appreciate the help…for the most part, comparing the latex works with these pretty basic answers, and it is a lot simpler for me to code. I just recently started playing around with the parseEquation and evaluateAt code to check for correctness., so that code with patterns looks a little intimidating …but I look forward to figuring it out. ( for example: Not sure what “patterns” is doing. Is that code that is in the CL library? Is it similar to when I write “t=table”? Table is a component, but what is “patterns” ? )

Now that I am looking at Daniel’s code, I will start there. The hasFocus and isBlank are two new things to me that seem to be the key to my minor issue!

Thank you again. I am always amazed at how quickly you guys help out.

And I appreciate your patience, if some of my questions seem a bit rudimentary.

You are correct about patterns being in the CL library. There isn’t a lot of documentation on it, but there are several YouTube videos with examples posted on the Desmos channel. I think for the most part, you could just copy and paste that code since most of your examples are made up of a product and a sum. The only thing that would need to be changed is the coefficient and the constant. I don’t remember if you had any with a difference, but if you did, that code would be a little different.