Replay trial based on key response (Conditional logic)

Hello.

I am developing a 3AFC post-test for my experiment. In this test, participants hear three words. One of the words is a target word and the other two words are foils. Participants must identify the target word by pressing the button corresponding to its presentation order (i.e., if the target was presented second in the trial, a participant must press “2”). Given the constraints on participant working memory with three words per trial, I want participants to have the option to replay each trial by pressing a button. However, I want to cap the amount of replays (e.g., a participant can replay the trial no more than three times before it forces them to make a decision).

I am new to Psychopy and decently familiar with Python. I have developed the experiment in the builder without the ability to repeat trials. Is there somewhere I could be directed for more information on how to create such conditional logic in my experiment? Any help is appreciated.

You could add an inner loop around the trial with no spreadsheet and nReps = 3 which is broken (inner_loop.finished=True) in a code component unless the repeat button is pressed.

Thanks. I was able to solve the issue by doing the following:

Create a “trials” loop with a “main” routine. The main routine is the primary stimuli presentation. Within the trials loop create two additional loops, “repeat 1” and “repeat 2”. Within repeat 1 and repeat 2 add a copy of the main routine. Using custom code components I turned on or off the repeat 1 and repeat 2 loops based on participant button press and aligned the stimuli of each routine within the trials loop and repeat loop together.

This particular set up ensured a few things: repeats were in sync with the main trial. This way a participant could repeat trial 1 and choose not to repeat trials 2-5 but then repeat trial 6 without the inner loops.