Only getting a wrong answer message even when it's correct

Description of the problem: Offline, the experiment worked well but after trying to run it on Pavlovia the Wisconsin card sort task part I only get the “incorrect” message no matter if the answer is correct or not. I’ve tried some troubleshooting but as I’m new to coding I think I may just have a huge mess!

If anyone can take a look I’d really appreciate it :slightly_smiling_face:

Thanks,
Sarah

Please could you show your code related to the feedback?

Code for the feedback is (in python, it’s been automatically changed in the program for auto>JS):

Begin Experiment
msg = ‘’

Begin Routine
if (corrAns == 1):
msg="Correct! "
else:
msg=“Incorrect”

End Routine
if (trials.thisTrialN) == 10:
trials.finished = True

Is this in Begin Routine of the routine with the response?

How are you setting corrAns?

thisTrialN doesn’t work online.

I have a routine for “trial” and for “feedback” in the same loop.

The code for the trial part is:

Begin Experiment
key_resp.counter=0

Begin routine
if currentLoop.thisN == 0: # reset on the first trial
n_consecutive = 0

Each frame
for stimulus in [one_red_dot, two_yellow_triangles, three_green_crosses, four_blue_stars]:
if response.isPressedIn(stimulus):
print(stimulus.image, corrAns, stimulus.image==corrAns, type(stimulus.image), type(corrAns))
if stimulus.image == corrAns:
corrAns = 1
psychoJS.experiment.addData(‘correct’, corrAns)
continueRoutine = False

End routine
if key_resp.corrAns:
n_consecutive = n_consecutive + 1
if n_consecutive == 5:
currentLoop.finished = True
else:
n_consecutive = 0

Save this in the data to check things are working OK:

psychoJS.experiment.addData(‘n_consecutive’, n_consecutive)

(I’m sorry if I’m not giving you the right answers to your questions but I’m not 100% sure on coding!)

You seem to be using corrAns for three different things.

  1. Is it a column in your Excel file
  2. You are trying to set it to 1 if the correct stimulus is clicked. Use a different variable for this and set it to 0 in Begin Routine.
  3. You seem to also have a keyboard response and I think you mean if key_resp.corr (which should be 1 if the keyboard response is correct).