Forum Discussion

JeanMarrapodi-c's avatar
JeanMarrapodi-c
Community Member
3 months ago

Variable change when user upates an answer?

I'm trying to build a course to help our users count money. I've done all the coding and all the math so everything works EXCEPT if they make a mistake and change a number to correct it. Then it adds the number a second time. What do I need to add so they can correct an answer but not clear everything out?

I haven't added the wrong answer part yet, but figured out how to do that. I found they had to reset the whole thing to clear it and start over, otherwise it kept adding the new numbers in. 

 

 

  • As you've discovered, you have to be very careful about when you perform math operations on a number variable. 

    There's a simple solution to your problem: reset the Total, and then add all of the variables every time the user edits one of the "How many..." fields. 

    And a simple way to do that: Every time one of those variables changes, show a "counting" layer. Don't put any objects on that layer. Just do the math, and close it. 

    This is shown in an edited version of your slide in the attached file.

    FYI: Here's more info about using invisible layers: TIP: the Incredible Power of Invisible Layers | Articulate - Community 

  • As you've discovered, you have to be very careful about when you perform math operations on a number variable. 

    There's a simple solution to your problem: reset the Total, and then add all of the variables every time the user edits one of the "How many..." fields. 

    And a simple way to do that: Every time one of those variables changes, show a "counting" layer. Don't put any objects on that layer. Just do the math, and close it. 

    This is shown in an edited version of your slide in the attached file.

    FYI: Here's more info about using invisible layers: TIP: the Incredible Power of Invisible Layers | Articulate - Community 

    • JudyNollet's avatar
      JudyNollet
      Super Hero

      And, yes, the counting could have used the Count1s value instead of bothering to put it into the 1stotal value. I just like using similar variable names for a given task. 😁