Skipping follow up questions if participant uses the mouse key

Dear all,

I am trying to run an experiment where a participant sees a word (randomly selected from an excel file located in the ‘trials’ loop) (CUEWORDS is the routine where the participant will see the word), and then press the spacebar as soon as they have a memory related to that word. They then will press the spacebar a second time to indicate they have carried on thinking about the memory as much as possible and can now remember as many details as possible (access_elaboration_loop is added so there can be 2 separate spacebar presses that both end the routine and can be recorded).
They will then be asked several follow up questions (the ‘DvG’, ‘FIRST_VERSUS_THIRD’, ‘DESCRIBE’ and ‘WHEN’ routines) about their memory.
However, I want to add an option that if the participant does not have a memory for that word, the follow up questions will be skipped and the next cue word will be displayed (the loop restarts). Otherwise it is a waste of the participants time. I have added a polygon that can be clicked for ‘no memory’ and tried this code, however it ends the entire loop not skips to the next trial.

Any help is appreciated as I am very new to coding!

Thankyou, Jess

Can you try putting the following in each frame

if mouse.clicked_name[0] == 'polygon':
  access_elaboration_loop.finished = True
  trials.finished= True

And then put the following in the Begin Routine in each following-up question:

if trials.finished = True;
  continueRoutine = False

I am not 100% sure this will work. But I know the general idea is that if you want to skip the follow-up question, you need to use continueRoutine = False at the beginning at the Begin Routine for the question.

Thankyou for your quick response!
Can you please explain the error I have now made with the syntax?

I think it should be a colon instead of a semicolon. Sorry, that’s my bad

if trials.finished = True:
  continueRoutine = False

Also, the code I suggested is based on python, I don’t know if it will work in PsychoJS. check out this to see which component will work online. Status of online options

Bills code still has a typo.

if trials.finished == True:
    continueRoutine = False

I’m not sure if that will do what you want, though.

If I were you, I’d try the following instead:
Just wrap another loop around all the routines that will be skipped if the polygon is pressed.
In the settings of that loop enter a variable name for the nReps:

EDIT: Uncheck “Is trials” here. I forgot about that (it will work either way, but output will be messy if its still checked).

We will control this variable and set it to 1 if participants do have memories and set it to 0 if they do not. This works because 0 repetitions result in skipping the whole loop.
To do so, just add a code component to the cueword routine and put the following code inside the the tab labeld “each frame”:

skip_if_no_memory = 1
if mouse.isPressedIn(polygon):
    skip_if_no_memory = 0
    access_elaboration_loop.finished = True
    continueRoutine = False

I tested it and it seems to work just fine.

1 Like

That is brilliant, it works perfectly! Thank you so much, both of you, for your help! Have a nice day