I hope everyone is doing great. I built one of the executive functions with PsychoPy (2-back) and I would like to put an option for repeating the instruction and the practice part. So I am planning to have an option for something like, ‘Would you like to repeat the instruction/practice?’, ‘press Y for yes and N for no’. So, if they press N it will take them directly to the trails and if Y it will take the, back again to the practice/instructions part.
Please, it is urgent and I have been trying to figure it out for a while now… Maybe I am doing something wrong … I will waiting for HELP…
It would be helpful if you posted a minimal sample of your code to see what you’ve been doing so far and why it hasn’t been working.
One way to accomplish this would be to do a while loop:
practiceDone = False
while not practiceDone:
# Do your instructions here
# Do your practice trials here
doneQuestion = visual.TextStim(win, text='Would you like to repeat the instruction/practice? Y / N')
doneQuestion.draw()
win.flip()
response = event.waitKeys(keyList=['y', 'n'])
if 'n' in respnse:
practiceDone = True
Thank you so much for this great help. However, I am not sure where to input this code. in which tab of the code component do I enter this? and how do I the refer to this in the routine/loop? Sorry for I am a beginner
No problem. Where you add this depends on whether you are doing this in the “Coder” interface or the “Builder” interface, and then on how you are currently doing your practice trials. It would help if you could upload your script or experiment file (usually something like name.psyexp).
I am sorry for the delay replay but I am so packed up these days preparing for my data collection . I am using the builder interface and I was trying to know where I can possibly upload my file here so you can have a look at it but still could not figure out where to do that:disappointed_relieved:. and is there a way where I can have a direct contact with you because I really need help with this matter … Thank you so much
Hi - you would have a loop around the instructions, practice and option blocks with a repetitions value of $nReps - in the options block you would have a code component as well as your rating scale with yes and no as options. In the start of experiment tab have a line saying nReps=1 and in the end of routine tab have the following:
if ratingScale.getRating() == 'Yes'
nReps = 1
Not at a computer so can’t test it - this is the general idea though so have a play.
Thank you so much for your patience and great help I think the loop and the code is alright but I guess there is something wrong with my scale rating. Because I keep having this error :
rating = visual.RatingScale(win=win, name=‘rating’, marker=u’triangle’, size=1.0, pos=[0.0, -0.4], low=no, high=yes, labels=[u’‘], scale=u’')
NameError: name ‘no’ is not defined
and I forgot to mention, I put my code and scale rating at the end block [Inst_End] in which they will see the question which give them an option … So did I do it right?
Yes, I put the code in the code component and put it at the Inst_End block . Plus, I put $nReps in my repeatinst properties and the allowed keys for the Instr_End are ‘y’,‘n’. …