when I use the pavlovia online experiment, the experiment always stucks in this line : reference error : sum isn’t defined. what I wonder is sum is a built in function, so why do I need to define it ? And how can I define it ? Pls help me ,thank you .
Hi there @banana,
Could you please confirm:
- Which version of PsychoPy you’re running
- The line/block of code where you’re using
sum(), please copy and paste in a code block here if you can
- Are you using the Auto>JS code type or typing directly into JS yourself?
thank you for your reply
2.if key_resp_practice.corr == 1:
total = total + 1
feedback = ‘correct’
total = total
feedback = ‘false’
b = sum(a[0:])/total
if total >= 6 and b > 0.9:
trials.finished = True
feedback = ‘Practice is over,\nNow the experiment is starting.\nPlease pay attention.’
3.Referred to someone’s code, I want to calculate the accuracy rate so did some changes.
Thanks so much for this! So, firstly I would recommend updating to the latest version of PsychoPy here. Next, if you set your code type to Auto>JS (in the drop down at the top of the code component), sum should auto transpile to util.sum on the right hand side of the code component (see screenshot).
This should stop the error.
thank you so much for this answer!
I found the latest version of psychopy didn’t support the online experiment, so I chose the available 2020version.And these codes with changes can be run in local but not on the online platforms (pavolvia, naodao).
No problem at all. The reason for these not running online is actually the same issue as you faced previously. If you now change the code type to ‘Both’ so that you can edit the right hand JS side, you can change:
b = (sum... to
b = (util.sum...
then it should work. Unless you’re now getting a new error online?
thank you so much, this really help me a lot.
Online experiment shows problems and I did some detour to avoid using sum, I really appreciate your help and patience.