Button not reactivating when I navigate away and come back

I have a button that is disabled when clicked. It is to check answers on a previous slide. I want the button to stay inactive until a user navigates away and then comes back to the slide to check a second time. I copied the code exactly from another cardsort that works perfectly. Mine however, will not reactivate the button. I can’t tell a single bit of difference.
Thanks for any help…

Here’s the set up
Slide 1 has the card sort called ‘sort’
Slide 2 has an untitled note and a button called ‘button’.
The only code is under the note and button.

HERE IS THE CODE FOR THE BUTTON:
s=sort
b=button

content: when b.timeSincePress()>0 “{start}{waveLine}” otherwise “${start}\n\n\n\n\n”
start= “Press the button to see how you did on the Card Sort.”
check=
when s.matchesKey “Great work! You got them all correct.\n\n\n”
otherwise “Not Yet. Go back and keep trying.\n\nYou can come back later to check again.”

time = b.timeSincePress()
animLength = 0.25
waveLine =
when time>0 and time <= animLength “\n\n\n\n…”
when time>0 and time <= animLength “\n\n\n\n…”
when time>numericValue(“1*{animLength}") and time <= numericValue( "2*{animLength}”) “\n\n\n\n·…”
when time>numericValue(“2*{animLength}") and time <= numericValue( "3*{animLength}”) “\n\n\n\n˙·…”
when time>numericValue(“3*{animLength}") and time <= numericValue( "4*{animLength}”) “\n\n\n\n·˙·…”
when time>numericValue(“4*{animLength}") and time <= numericValue( "5*{animLength}”) “\n\n\n\n.·˙·…”
when time>numericValue(“5*{animLength}") and time <= numericValue( "6*{animLength}”) “\n\n\n\n…·˙·.”
when time>numericValue(“6*{animLength}") and time <= numericValue( "7*{animLength}”) “\n\n\n\n…·˙·”
when time>numericValue(“7*{animLength}") and time <= numericValue( "8*{animLength}”) “\n\n\n\n…·˙”
when time>numericValue(“8*{animLength}") and time <= numericValue( "9*{animLength}”) “\n\n\n\n…·”
when time>numericValue(“9*{animLength}") and time <= numericValue("10*{animLength}”) “\n\n\n\n…”
when time > 0 “\n\n${check}”
otherwise “”

HERE IS THE CODE FOR THE BUTTON:
disabled: this.timeSincePress>0

You can share your activity link (the three dots menu as long as the activity is not private). That way people can just copy and edit, instead of trying to recreate your post.
Also, you can also use triple backticks as you would quotes to more accurately share your code:

multiple lines of code
will work with triple backticks
in the lines above and below your code like this

Yes…much easier to just share the activity. Here is the one I’m having trouble with…


The only places I added code were on the components on the second slide.

For reference, if needed, here is the activity that I took the code from that works the way I want.

Thanks for any help

I don’t have a ton of CL experience myself, but I’ve been pretty good at figuring some things out so far. For the life of me, I can’t seem to sort this one out. For some reason, navigating away from Screen 2 isn’t resetting the timeSincePress value for the button to 0; instead it is getting reset to 10. I don’t know why. I’m curious if anybody else is able to figure it out.

For what its worth, you can copy an entire screen from one activity to another, instead of copy/pasting code. Just click the screen at the top, hit Ctrl+C or Cmd+C (the screen tile should flicker) and then you can Ctrl+V/Cmd+V to paste the screen into another Activity. When I copied the screen wholesale from your reference activity to your own activity, the button reset as expected. The best I can guess is something went wrong when you copied the code, but I can’t tell what it was.

1 Like

Copying the slide worked great. This is resolved. I know when I was reading the code to figure out what it did I inserted a line or two and then took it out. I must have triggered something.
Thanks for the help!