Loop.finished not working

URL of experiment: not online yet - pilot

Description of the problem:

The “trials” part of my experiment is composed of five rounds. I have added a screenshot so that you can have a better description. The participants should have the possibility to leave at any time of the experiment. In order to achieve that, I have added a keyboard response in the routine “trial” so that they can quit if they press ‘p’ and should then immediately go to the routine “cigarette length” without finishing the 5 rounds.
If they click on ‘p’ in the routine “trials”, they will go to the routine “feedback_stop” (this is already done), and then they should immediately go to the routine cigarette_length even if they did not finish the 5 rounds. I have tried to code this with trials.finished=true in the tab end routine but this doesn’t work. I have also tried to add start_selected.finished=true because there are two loops but this didn’t help.

In addition to that, if the participants complete one of the rounds, they will go to the routine “feedback_continue” where they should also have the possibility to leave without finishing the five rounds, also by pressing “p” but same problem, instead of ending the trial and going to the routine cigarette_length they go to the next round. I have tried to code this with the following code in the tab each frame:

if ((key_resp_4.keys === "p")) {
    continueRoutine = false;
    trials.finished = true;
    start_selected.finished = true;
}

But this also doesn’t work.

I am working with the version 2020.1.2

This is relevant: Loop.finished=true No longer working

Basically, name_of_loop.finished doesn’t work online and is iffy locally. trials.finished is generic, it applies to the most immediate loop currently running I believe. Calling one of your loops “trials” makes this a little confusing to discuss, but in fact when you call “trials.finished” you are not referencing the loop with that name, you are referencing whatever is the most proximal loop to that trial. If this code is in the feedback_stop trial, then it will probably only end the “beenden” loop, but won’t affect anything “above” it in the loop hierarchy (trials, start_selected, or constent_form_agree).

One solution I suggested to someone else which worked for a somewhat similar problem is to add dummy trials, that is, a trial that only contains a code component which is directly under the loop you want to end. So you could add a dummy trial after feedback_stop that is not under the beenden loop that only has a code component which checks your condition to go to “cigarette_length” and calls trials.finished=true in that case. However, I’m not sure if that would end what is currently called the “trials” loop as well as the “start_selected” loop, or only one of them, so you may need a second dummy trial that is under “start_selected” but not “trials”.

Thank you for your advice. I have added these dummy trials the way you said and it works now.

2 Likes