Forum Discussion

DiannaBeards049's avatar
DiannaBeards049
Community Member
2 years ago

User selection toggle with variable score toggle

Hello - Learning storyline, but cannot figure out a solution to this problem for my scenario. I want user to select multiple action items from a text list, and once it is selected it is visible to user. Each item for selection  has a corresponding value that will be added to the variable (I know how to do the add/subtract to variable part) but then the user also needs the option of de-selecting the items, and in that case the point value must be subtracted from the variable. And that resets the selection option to original state.  I think of it as a toggle button, click > show it is selected and plus 1 gets added to var > click to deselect, and -1 gets subtracked from variable. I hope that makes sense and thank you for any ideas/solutions for creating this part. 

  • Give the item a Selected state, and when it is clicked it will automatically change to that state. When clicked if it is in Selected state, it will change to Normal. The Selected state is truly a toggle state. It is the only toggle in SL that functions without a trigger.

    Create a trigger to add to variable when item is clicked IF state of item is equal to Selected (the state is changed before the triggers are evaluated).

    Create another trigger to subtract from the variable when the item is clicked IF the state of the object is not equal to Selected.

  • MichaelHinze's avatar
    MichaelHinze
    Community Member

    Rather than adding/subtracting, you could reset the variable and recalculate each time a selection changes, based on the selected options. See attached a quick example.

  • Michael is correct, in that adding on the fly is more vulnerable to inaccuracy.  Unless you need to keep or display a running total, the best option is to wait until the learner finished selecting, then when they click to move on, calculate the total.