Description of the problem: I created a code in my experiment so participant can see the percentage (or the sum of their correct responses in a trial). This works locally but not online.
My code is:
corrTrials = Practicetrials.data['task2prac_key_resp.corr']
msg = "You got %i trials correct out of 4" %(corrTrials.sum())
it works locally but not online. I hope to hear from you
Thank you for your response. It does not have an error message but shows a repeat of the feedback message last presented but in white colour.
Basically I have a self-association task. After each participant press the right key they receive “correct” in green colour. If wrong they receive “incorrect” in red colour. If response takes a while, it receive “too slow”. After 60 trials the participant should receive a message “You have answered 51 out of 60 correct response” from that code locally. But when online the latter code is gone and just a repeat of the last feedback either correct, incorrect or too slow in white colour ink
OK thanks for clarifying - could you please try reformatting your code to follow something like this post (which I think may be a similar issue) Problem to read a code on Pavlovia - #2 by Becca
@Becca I adapted your code but unfortunately it is still coming up with an error.
All I wanted to say in my experiment is the total correct score after each block. Unfortunately, there is still an error. It is working locally but not online
@JensBoelte I have adapted your suggestion too so I added str(myVar) but it is still not working online
Thank you for getting back to me - I am using Psychopy ver 2021.1.4. Does this mean I cannot give a total of correct trials at the end of each block online because of the version I am using?
If I need to use a different version - does this mean I need to re-program my experiment using another version?
Thank you for sending this through. I am using the v2021.1.4
I am also very new to coding but will have a look if I can translate sum online with my version.
Thank you
well, it should work in 2021.1.4 but it doesn’t seem to work. You do not have to reprogram your experiment when updating to a new version. Downgrading is more difficult because newer version introduce features that were not available in older versions. So, it might be worth a try to use the current version.
Sorry sir, I do not know much about coding so please have patience with me - so what do you mean by .keys?
I am using the .corr because I wanted the code to count the total of correct responses of the participant and provide a feedback about it at the end of the block. So like, “you scored 2 out of 4 trials”.
The codes I had seems to work only locally not Online - am I defining the wrong variables?
Your error message mentions task2prac_key_resp.keys which should be the list of keys pressed (and can give an error if you ask information about it when nothing has been pressed).
.corr is the 1 / 0 score and therefore is the one you want. I was wondering if you were referring to .keys in any other code tabs.