"Variable Not Defined" Problem in Pavlovia

URL of experiment:

Description of the problem:

I coded in Psychopy some conditions to end a loop. Before Experiment:

score = []
scorr = 0

And in the End Routine Part

score.append(key_resp_2.corr)
scorr+=key_resp_2.corr
thisExp.addData(‘Score’,score)
if (average(score) >= 0.95 and scorr >= 1):
training.finished = True

It seems that when I try to run the experiment in Pavlovia the code doesn’t recognice that variables. I tried to define it in the JavaScript scripts but it doesn’t work.

Any idea?

Thanks!!!

Try prefixing your score and scorr variable with window.
For example: window.score

Thanks! I’ll do it. I’ll wirkte back as soon as I test it.

Best!

1 Like

Hi!

I solved the problem by erasing “this.Exp.addData(‘Score’, score)”

The code now works fine online.

Thanks!

1 Like