Feedback error caused by code component when running in Pavlovia.org

Hi,
I would like to calculate the average success rate and return it as a msg feedback. So I wrote a routine to get feedback with the code component after a block. Everything goes well in local. But when I put it online, It has some errors. I know the reason is that the code converting from Py to JS.

This is what I wrote in Py within Code component:

# Begin experiment
msg='doh'
colortext7 = 'white'

# Begin Routine
ntrial = len(lettreblocks.data['key_resp.keys'])  #numpy array with size=[ntrials,ntypes]
nCorr = lettreblocks.data['key_resp.corr'].sum() #.std(), .mean() also available
meanRt = lettreblocks.data['key_resp.rt'].mean()
corrRate = nCorr/ntrial*100

msg = "U succeed %i percent of trials with the response time at %.2f sec. Bravo!" %(corrRate,meanRt)
colortext7 = 'green'

I guess in Py, it used dataframe but i don’t know how Js defined the data structure. So i couldn’t read these variable lettreblocks.data['key_resp.corr'] in JS script. Do you know convert these py code to js code? I found the following line in the Js script :
psychoJS.experiment.addData('key_resp.keys', key_resp.keys);

Jianghao

Problem solved :slight_smile: ref to the following post: