Experiment practice feedback: reach the correct rate but can not break the practice loop in the code component

URL of experiment: https://pavlovia.org/run/BW/alcohol-dot-prob-task_zjr/html/

Description of the problem:
In this experiment, I put a code component in the begining of experiment. The purpose is that when the participant reach the practice correct rate than go on with followed session, otherwise go back to the begining to try again the practice session.
But the setting of code component doesn’t working when I sync to online, while it work well in PC psychopy. Is the programming language conversion problem?

The following is my code:


I’m guessing it would have generated an error message - you should always provide that detail.

I’m not a Javascript person, but in this case, it looks like the JS in code_2 is missing an opening curly bracket.

Also note that code should really be in the “end routine” tab. If you set the loop to be finished, that will only take effect after all routines have ben completed, so at this point, you are probably getting one more trial than you want, as the current trial will still run even if the criterion is met.

Hi Michael

Thank you for your reply.

There are no errors when I run the program. It just cannot jump out of the loop at the position of the code_2 component. Because I need to accord the correct rate to decide whether starting another practice for participants, thus I put the code in the begin routine tab.

I think the problem is very likely that you said “missing an opening curly bracket”. But I don’t konw Javascript neither :sob: . I will try debug by google. Thanks.

You might be running into the same issue as I was with the updated PsychoPy. They updated how you break out of loops. See this thread:

Hi Bobby_Thomas,

Thank you for your answer. I tried the new code for breaking out of loops, but it still not works. I’m still looking for a solution.