Printing a counter as participant feedback in next routine

Hello - i’m trying to give participants some simple automated feedback as a text component in the routine following a test routine.

I created a simple counter for correct scores in the test routine:

begin routine:
score=0

end routine:

if mouse.isPressedIn(polygon):
    score = score+1

I then add a new routine and am trying to display the final value of the counter as text using a text component:

the result is that it just prints “0” (i.e., the value I set for $score in begin routine).
Anyone know what i’m doing wrong?

Cheers,
Tom

Hi There,

A few things to check:

  • Try adding a second routine within your “trials” loop called “feedback” and set a text component in that loop to be $score as you have (it could be that the response is needed first to calculate the score to then set the text parameter, but the score cannot be known until the mouse has been pressed and then the text parameter can be set if that makes sense)
  • Perhaps set your text parameter to “set every repeat”

Becca

1 Like

thanks a lot - putting score within my trials loop AND setting to “set every repeat” did update the counter.

I still need to figure out how to only present one bit of feedback at the end (instead of after every trial) but thanks for pointing me in the right direction!

Tom

adding a code component to the feedback routine (now inside the trials loop as you suggested with the text set to every repeat) in the every frame section sorted it:

if trials.nRemaining == 0:
    continueRoutine=True
else:
    continueRoutine=False 
    

not exactly hardcore coding but a victory for a novice coder :joy:

1 Like