psychopy.org | Reference | Downloads | Github

Feedback Message $msg Error on Pavlovia Python to JS

Hi everyone,

I have an experiment on Pavlovia it used to run properly until I added a Feedback message, in my computer works perfectly so I guess it could be related with the code written in Python instead of JS.

I’m really naive in Python and I have no idea about JS code:

This is my code (it’s very simple and the “message” written in spanish):

#Begin Experiment
msg=""

#Begin Routine
nCorr = trials.data[‘key_resp_t.corr’].sum() ;
nCorrp = (nCorr*100)/60;
msg = “Tuviste %i %%\n de respuestas correctas” %(nCorrp);

I wish somebody can help me

Hi @TaliaRoman, click and see the link below to see if that helps:

@dvbridges

Hi David,

I am coming across a similar issue with the msg variable. Thanks to your feedback I now inserted the JS code alongside the Python code and the experiment on Pavlovia works fine without the $msg error, however the message (Correto, Incorreto, in Portuguese) is not displayed on Pavlovia, whereas it is on the PC version of Psychopy. On Pavlovia, I instead get a blank space during the time in which the feedback message would appear. Any idea what I do wrong?

My codes in the code component are as follows (I am assuming the left window is for the Python Code and the rigth side for the JS code?);

#Begin Experiment (Left Side Window)
msg=""
#Begin Experiment (Right Side Window)
#I left this blank

#Begin Routine (Left Side Window)
if key_resp_practice.corr:#stored on last run routine
msg=“Correto! RT=%.3f” %(key_resp_practice.rt)
else:
msg=“Incorreto”
#Begin Routine (Right Side Window)
msg = ‘’;

#End Routine (Left Side Window)
#I left this blank
#End Routine (Right Side Window)
if (key_resp_practice.corr === 1) {
msg = “Correto! RT=%.3f” %(key_resp_practice.rt);
} else {
msg = “Incorreto”
}

Hi @tjl, it may be that your string formatting is wrong for JavaScript. To format your strings, it is better if you just add things together: e.g.,

msg = 'Correto! RT = ' + key_resp_practice.rt.toFixed(2);

the toFixed method allows you to round your rt value to 2 decimal places (or however many you want).

1 Like

@dvbridges thanks so much for your feedback and the push in the right direction! I managed to make it work by changing the code component into JS only with the following codes:

//Begin experiment
msg= ‘’;
//Begin Routine
if (key_resp_practice.corr = 1)
{msg = "Correto! RT = " + key_resp_practice.rt.toFixed(2);}
else
{msg = “Incorreto”}

Thank you so much again, really appreciate it.