URL of experiment: https://pavlovia.org/run/kerblooee/cui_stroop/html/
Description of the problem:
Hi all, long time psychopy user here, just starting with Pavlovia. I programmed a Stroop task that works fine online on its own, but then I added an Ishihara color test before the task and now I get an “Unspecified Javascript error” after entering participant number at experiment start. Here are the details:
I present PNGs of 12 Ishihara plates, one after the other. Along with the image, I present a Slider (with “radio” type checked in the Appearance settings) on which participants can select the number that appears in the image (ticks = 1-11, labels=11 labels for different numbers, as the number 5 is repeated twice). Unbeknownst to subjects, a hidden text number appears along with the image, so I can keep track of which number is actually shown in each image. After the participant clicks the rating on the Slider, they are provided feedback about whether the label of the Slider rating they clicked matched the hidden number in the Ishihara plate.
I wrote a code component to deliver feedback like this. In Psychopy, it looks like this:
Begin experiment:
msg2=""
Begin routine:
rat2lab = int(rating.getRating()) - 1
rating_label = str(rating.labels[rat2lab])
if rating_label == ishi_text.text:#stored on last run routine
msg2="Correct!"
dur=1
else:
msg2="Oops! That was wrong. Contact the experimenter if you could not see the number. If you just made a mistake, press ESC and start over again."
dur=100
I then did Auto–>JS. In JS, it looks like this:
Begin experiment:
msg2 = “”;
Begin routine:
rat2lab = (Number.parseInt(rating.getRating()) - 1);
rating_label = rating.labels[rat2lab].toString();
if ((rating_label === ishi_text.text)) {
msg2 = “Correct!”;
dur = 1;
} else {
msg2 = “Oops! That was wrong. Contact the experimenter if you could not see the number. If you just made a mistake, press ESC and start over again.”;
dur = 100;
}
Then, in the feedback message (just a textbox), duration is $dur and text is $msg2. That way, if participants make a mistake, they are stuck on that image and are told to press ESC to exit the experiment.
I’m pretty sure there is something in this code that is messing up in the translation from python to JS, because it works fine in psychopy on my desktop. As a note, in my code it says “rating” - I called my Slider “rating”, I did not use the old “rating” component, which I read does not work in Pavlovia.
If anyone can offer a solution, it would be so wonderful, I’ve been stuck on this for hours and haven’t found a solution yet. I feel like I’m so close to getting this running!
Thanks for reading!