psychopy.org | Reference | Downloads | Github

A routine that is designed to be executed after 10 times running the loop, in online version plays after each loop!

URL of experiment: offline [PsychoPy]

Description of the problem: Hi everyone. I’ve created an experiment including audio samples to be read from the spreadsheet and in my experiment there is a routine called attention_check. in the routine I’ve put a custom code to make the routine be played after 10 times running the loop. And what happens after 10 times running the loop is that it play a sound for 2 seconds and then won’t go to the next routine until I press the space bar. This is the code:

if count != 10:
    continueRoutine = False

this is the js translation:

 if ((count !== 10)) {
        continueRoutine = false;
    }

The weird thing is that when I run it locally it works perfect but online it play the sound after each running the loop and doesn’t wait for the space bar too. So as my experiment includes audio samples already this sound which belong to the attention_check routine play at the same time with audio samples!!
Does anybody has an idea what’s the problem and what should I do to fix it?
I’ve also put my experiment here if you wanna see the routines and codes.
offline.psyexp (37.4 KB)

Where does count come from?

In the routine “code”, in the tab “begin experiment” I’ve defined count=0, and then after each playing the loop I increase the count by 1. You can see it in the routine “code” in the tab “begin routine”.

@thomas_pronk
Hi, I just thought you would be able to help with this! What do you think the problem is?

Not sure; there is quite some logic in your experiment, so I can’t solve it just by looking at the code. I’d recommend to add debugging code: log all kinds of info to the browser console: for instance the values of variables, some labels to identify at which routine you are, then check if it’s all as you expect it to be. See Thomas Pronk / tutorial_js_console_log · GitLab

The relevant code seems to be

if (_pj.in_es6(getRow(standard), playedReg)) {
    continuePlaying = false;
} else {
    playedReg.push(getRow(standard)); //we changed append to push here
    count += 1; 
}

As Thomas says, you should add some console.log statements to see what is happening to the value of count, and which bits of code are being executed.