N-Back script run without problem on local computer but completely went off on Pavlovia

URL of experiment: nbackexp [PsychoPy]
Script: Yang-Ming Huang / nback demo · GitLab
Description of the problem:

The script ran without error on my local end. However, when it’s uploaded to Pavlovia, several things went wrong:

  1. thisExp.addData (‘newans’, ans) doesn’t save anything…
  2. the condition completely went off…

Begin routine Settings

numlist = ['1','2','3','4','5','6','7','8','9']
shuffle(numlist)
number = numlist.pop()
count = count + 1 
if count > 2: 
    if ans == 's':
        number = tempnumber[0]
        tempnumber.pop(0) 
    if ans == 'd':
        if number == tempnumber[0]:
            ans ='s'
        tempnumber.pop(0)

end Routine

tempnumber.append(number)
thisExp.addData ('newans', ans)
thisExp.addData ('newnumber', number)

Originally, I used tempnumber.insert(0,number). It ran smoothly on my local computer but Pavlovia complained that insert is not a proper function… So I made the changes… but again things doesn’t seem to be right on Pavlovia’s end thought it was running.

How is ans set?

ans is more like a type setting.

s is for “yes” type trials
d is for “no” type trials

Depending on type, the script will determine what the participants gets to see. And since the numbers were randomly selected, the following script was added to change the ans in case the random number selected turn this trial into a “yes” trial. Hope that makes sense to you

You still haven’t shown exactly how ans is set, only what it means.

pop(0) doesn’t behave online as it does locally. Can you use number = tempnumber.pop() and take from the other end?

FYI, ans was set in the condition file

That’s exactly what I needed to know. That is confusing to me… Anyway, I ended up doing it the other way around similar to what you suggested. The mismatch between online & offline coding can be frustrating to users.

The code is here for those interested

Because append is a specific python method, to add elements to lists for online tasks we instead use presentedLetters.push(thisLetter) where push() is the Javascript equivilent of append()