Issues with append and sum in Pavlovia

I wrote some code in python so that my program will create an array of the participants points and will look at the last 20 points (+1/-1) in the array, sum them, and divide by 20 to see if they’ve reached 80% correct in their last 20 trials so they can move to the next task.
However, I am having a lot of issues getting this to work when uploaded to pavlovia.
At first it was giving me trouble with the .append command for my array, so I have changed this to .push (the JS equivalent). This helped.
Now it is not recognizing the .sum command in python. I am having a hard time with this part. I’m seeing how I could sum in JS with the lodash function, but I’m not sure how to do this so it only adds the last 20 points and not the entire array? Any help would be greatly appreciated! Code below.


Ended up figuring it out! Below is the JS code I’m using and is working.

What version of PsychoPy are you using? Both of these are now translated automatically in version 2021.2, so I deleted the workarounds from my 2021 crib sheet.

Oh good to know! I’ll have our IT dept update our lab computers so we don’t have any issues in the future.
The version I was using is 2020.2

If you have a lot of experiments with html folders, then it might be a good idea to hold off. I have one experiment that I’m still running in 2020.2.10 because I don’t want to delete and recreate. My 2020 crib sheet has most of the information you need for that version.

1 Like