Conditional branching in experiment with test criterion

Hi all,

I have an experiment that is set up like this:

  1. There are a total of 24 stimuli (loop has 24 iterations) presented to the participants.

I have a current code in the “end routine” tab that is set up like this in which if the participants scores at least 8 correct in the first 12 stimuli, they move on to the test routine, otherwise the remaining 12 will run.

if practices.thisN == 11 and score >= 8:
practices.finished = True

However I would like to make to the following changes:

  1. Addition of an instruction slide before the start of the remaining 12 stimuli (i.e., the second round of practice)
  2. if the child failed 5 or more trials out of 12 in the first round of practice trials, it shows the instruction slide again and moves to the second round of practice trials (the remaining 12 stimuli).
    3… If they fail 4 or fewer trials in the remaining 12 stimuli (second round of practice trials), they enter the testing trials. However, if they fail 5 or more trials in the second round of practice, the particular routine (e.g., tone task) ends, and they move to the next routine.

Do I have to amend the code that I have in my “begin routine” and “end routine” tab or do I have to create another routine in the loop for this to work?

I think you can add these routines inside the loop with 24 stimuli after the routine with the stimulus. Then, you place singular loops outside of these, but inside the stimuli loop. You set the number of repetition to a variable (e.g. $myVal1). Finally, you set these variable as = 0 at the beggining of the experiment with a code component, and then as = 1 using some conditional statement when you want these routine to appear. After they appeared be sure to set the variables to 0 once again.

Hmm so how do i go about with that? sorry im really not that well versed with python language and coding as well as using psychopy