Feedback worked locally but not online

Everything worked properly on my computer, but when I piloted my task online on Pavlovia, I received the following reference error regarding the feedback component:

I looked up previous posts, and I think this error is about code type (Py ->JS), but I’m not so sure what to change. Here is the code component:

I’m very new to PsychoPy and programming, so any (basic) guidance will be appreciated.

I think row 4 is the problem. Try

     msg = "Correct! RT="+str(round(key_resp_2.rt,3))
1 Like

General Python tip:
I would advise you to use f-string formatting. Put an f in front of your string and place your variables in curly braces {var}.
It’s a great way to make strings more readable - and in my opinion they are by far the best way to format strings in Python.

msg = f'Correct!  RT={key_resp_2.rt:.3f}'

This gave no error when I tested it in a code component.

1 Like

Wow, yes, it worked! Thank you so much!

Thank you for the tip! I appreciate it :slight_smile:

Have you checked this works online (in Auto translate components)?

I know Python string formatting link "my var = %s" % myVar doesn’t work.

Yes, it was able to auto generate JS code when I used f-strings.