End a routine when mouse is not clicked but time is over

I am trying to build the Winscosin Card Sorting Test, and I need to pass for the next stimulus when the time limit to respond is over. However, my code just allow to pass for the next stimuli with a mouse click.

I appreciate if someone could help me.

if mouse.clicked_name == AnsCorr:
feedback_text = ‘Correto!’
msgcolor = ‘green’
corr = 1
if mouse.clicked_name != AnsCorr:
feedback_text = ‘Errado!’
msgcolor = ‘red’
corr = 0
if mouse.time[-1] > 10.0:
feedback_text = ‘Tempo Esgotado!’
msgcolor = ‘yellow’
corr = 0

I believe there is a build in variable called t that refers to the time passed since the beginning of the routine. Perhaps you can do something like:

if t > 10: # here I typed 10(secs) but change accordingly
    continueRoutine = false

I would put the above to every frame tab

I tried this, but when I use continueRoutine = False the program end all the test.

I just need the software to show the next stimuli
.

continueRoutine = False should just end that routine, not the whole experiment.
How about setting the duration of the Routine to 10s and using continueRoutine=False within your if mouse.clicked_name==AnsCorr loop? I.e. If the mouse is pressed, end routine early.

Hi everyone,

thanks for the help.

I solved the problem using the following code on the trials code:

Begin Routine
clicked_things =
t = 0

Each Frame
clickables = [option1, option2, option3, option4]

#check if the mouse is pressed in any of the boxes
for clickable in clickables:
if mouse.isPressedIn(clickable):
clicked_things.append(clickable.name)

if t > 10: # here I typed 10(secs) but change accordingly
continueRoutine = False

Then, I added this on feedback component:

Begin Experiment:
feedback_text = ‘’
msgcolor = 0
mouse.clicked_name =

Begin Routine:
if mouse.clicked_name == AnsCorr:
feedback_text = ‘Correto!’
msgcolor = ‘green’
corr = 1
if mouse.clicked_name != AnsCorr:
feedback_text = ‘Errado!’
msgcolor = ‘red’
corr = 0
if t > 10.0:
feedback_text = ‘Tempo Esgotado!’
msgcolor = ‘yellow’
corr = 0

End Routine:
thisExp.addData(“resp.corr”, corr)

Hi Larissa,
Would this not again wait 10s before presenting the ‘Tempo Esgotado!’ feedback? It is hard to be sure how this sequence is structured (it would help to use the </> function when writing your code), but as far as I understand you have one Trial Routine where you check for clicks and end the routine if there is no response within 10s, and one Feedback Routine where you give feedback (correct, incorrect, too slow). I would suggest allocating corr within the Trial Routine (Each Frame), so:

if mouse.isPressedIn(clickable):
   clicked_things.append(clickable.name)
   if mouse.clicked_name == AnsCorr:
        corr=1 # correct
   else:
        corr=0 # incorrect

if t > 10: # here I typed 10(secs) but change accordingly
   corr=9 # too slow
   continueRoutine = False

Then in the Feedback Routine just allocate the message and colour based on the value of corr (in Begin Routine):

if corr == 1:
   feedback_text = ‘Correto!’
   msgcolor = ‘green’
elif corr == 0:
   feedback_text = ‘Errado!’
   msgcolor = ‘red’
elif corr ==9:
   feedback_text = ‘Tempo Esgotado!’
   msgcolor = ‘yellow’

wow, it is true! Thank you very much!