Javascript - script to update text not working

May 14, 2021

Hi - I'm trying to set a feedback layer to a multiple choice question to display different text depending on which answers are given (the user can select more than one answer)
So if they select wrong answer 1 - it adds feedback 1
If they select wrong answer 2 - it adds feedback 2

If they select wrong answer 3 - it adds feedback 3 

so, for example, selecting wrong answers 1 & 3 gets feedback 1 & 3, skipping out 2.
____

I'm using Javascript to add the feedback, executing if they've selected a given response. The variable to check which response they've given is being used elsewhere on screen and working well, so I think the problem must be in my Javascript.

var player = GetPlayer();
var newfeedback = player.GetVar("feedback1pt7") + "Feedback Text 1<br/><br/>";
player.SetVar("feedback1pt7", newfeedback);

I used this project as the basis: https://community.articulate.com/discussions/articulate-storyline/append-text-to-an-existing-text-variable

Thanks!

5 Replies
Keiran Anderson

Hi Phil, thanks for following up.  The variables are all defined (we're using them elsewhere without issue), but i wouldn't put it past me to have some incorrect JS somewhere else in the project. 

Would having other JS in the project that doesn't work break the JS everywhere? A bit new to this side of articulate.