Creating an Array to sort variables

Aug 30, 2023

I am working on a project that includes a user survey. The following example demonstrates a simple version version of what I want to achieve:

The user toggles T/F button to indicate if they like four flavours of ice-cream (chocolate, strawberry, mint, vanilla). T if they do, F if they dont. 

When they submit their answer, I want a sentence to appear based on their opinions. 

So if someone likes the first three flavours listed above, the sentence will say, "The user likes chocolate, strawberry and mint."

But if someone else opts for the last three flavours, it would say, "The user likes  strawberry, mint and vanilla."

Because the user can opt in and out of each flavour, the sentence text is challenging as very quickly the commas, the word 'and' and the full stop don't make sense. 

I want to create an array that orders all the True choices, then populates a sentence:
"The user likes Choice1, Choice2, Choice3 and Choice4."

I can then have different states on this sentence to vary depending on how many choices they agreed with, ensuring it always makes grammatical sense.


Any help appreciated!

2 Replies
Judy Nollet

If the results sentence appears on the same slide as the choice buttons, you can track the responses based on whether a given button is Selected or not. 

If the results sentence appears on a different slide, you'll need to track the responses with variables. For example, use T/F variables that are adjusted based on the user's selections.

To display the appropriate results sentence with just Storyline, the "User likes..." text box would need a separate state for each possible combination. For each state, you'd need a trigger with conditions to indicate the selections required to show that state. (For example, change to the "Chocolate" state when "Chocolate" is selected, and "Vanilla" is not selected, and "Mint" is not selected, and "Strawberry" is not selected.)

Otherwise, you could use JavaScript to create the correct phrasing. I can't help you with that, but perhaps a JS expert will step in with a sample script. 

By the way, this post has info and a demo about using variables to track custom surveys: TIP: Track Responses to Custom Questions or Surveys - Articulate Storyline Discussions - E-Learning Heroes