Displaying accumaltion of points as performance feedback

I am trying to display point accumulations based on performance.
Two stimuli are present, one of which is highlighted with a border. P’s are asked to indicate whether it is associated with a reward or punishment by pressing r and p.

Irrespective of performance, participants will be awarded + 10 if they receive the correct answer for reward conditions or -10 for the right answer for stimuli in the punishment condition.

If answers are incorrect, they will gain a 0

I am trying to display feedback on performance and points accumulated.

Any help will be greatly appreciated.

Thanks

Hello Zelal

so, the other tread can be closed? Try this

in the Begin experiment tab of the code-component in the feedback-routine:

points = 0

the in the Begin routine tab of the code-component in the feedback routine.

if not key_resp.keys:
    msg="You failed to respond"
elif key_resp.corr: 
    msg = "Correct. You earned " + str(Correctpoints) + " points."
    points += Correctpoints
else:   
    msg="Incorrect. Your earned " + str(Incorrectpoints) + " points."
    points += Incorrectpoints

then

and

grafik

Best wishes Jens

Thank you so so much. I could not reply yesterday as I had reached the response threshold.

Correct or Incorrect would not appear. Therefore I simply added $msg into the text component, at it all worked. Thank you very much.

Best wishes

Zelal

Hi again

I followed the steps and it works. However. It does not show the accumulation of points nor display whether it was a correct or incorrect answer.

Please may you help

Can you please define what’s working and what isn’t. What is it showing you instead?

Hello Jonathan

Thank you for your message. Using the code above, after each trial response, participants simply view ‘You earned 10 points’ or You earned 0 points. However, what I am trying to achieve is
E.g.,
’ Correct, you earned + 10 points’ Total points 30.

So the message should include correct or incorrect and the points added or deducted and the running total of points gained.

Thank you.

I ran the tasks a few years ago and this was working however I am unsure why it isn’t.

I see. Here’s what I would recommend: In the code component for your feedback trial, put the following in your “begin routine” tab.

if not key_resp.keys:
    msg="You failed to respond"
elif key_resp.corr: 
    points += Correctpoints
    msg = "Correct. You earned " + str(Correctpoints) + " points. You have " + str(points) + " points total."
    
else:   
    points += Incorrectpoints
    msg="Incorrect. Your earned " + str(Incorrectpoints) + " points. You have " + str(points) + " points total."

The text in msg will now contain the full text you want to display.

EDIT: @wakecarter 's solution is probably better because it will add the message about total points to the “you failed to respond” message as well.

1 Like

How about

if not key_resp.keys:
    msg="You failed to respond"
elif key_resp.corr: 
    msg = "Correct. You earned " + str(Correctpoints) + " points."
    points += Correctpoints
else:   
    msg="Incorrect. Your earned " + str(Incorrectpoints) + " points."
    points += Incorrectpoints
msg += " Total points: " + str(points) + "."

Hi again

Thank you for your help. I followed the steps you suggested wakecarter and for some reason, it does not show correct or incorrect in the message nor does it show an accumulation of points. I added this to the text component

"Total points: " + str(points) + “.”

This allowed to show the points accumulated however, I am still not seeing the correct or incorrect in the feedback message.

I have included this in a text component with a different routine directly after the routine containing the code

$‘You earned’ + str (points) + 'points. ’ "Total points: " + str(points) + “.”

which shows points earned and accumulated.

In the code component in the begin experiment tab I have included

points = 0

In begin routine tab I have included

if not key_resp.keys:
msg= " You failed to respond"
elif key_resp.corr:
msg = " Correct. You earned " + str(Correctpoints) + " points."
points += Correctpoints
else:
msg= " Incorrect. Your earned " + str(Incorrectpoints) + " points."
points += Incorrectpoints
msg += " Total points: " + str(points) + “.”

Thankyou

In the text component, just put $msg, don’t put anything else.

Hello

Thank you. I had already tried $msg in the text component which resulted in “msg” appearing as the feedback text and nothing else.

Best wishes

I always mess up the builder syntax because I hardly ever use it. Let’s try something more direct. Delete everything in the “text” field of TextPoint and put this in Begin Routine:

if not key_resp.keys:
    msg= " You failed to respond"
elif key_resp.corr:
    msg = " Correct. You earned " + str(Correctpoints) + " points."
    points += Correctpoints
else:
    msg= " Incorrect. Your earned " + str(Incorrectpoints) + " points."
    points += Incorrectpoints
msg += " Total points: " + str(points) + “.”

TextPoint.text = msg

The code should now set the content of the text object.

Thank you for your help. Including the code above results in a syntax error.

Hello

what is the error message? In the code above there are some smart " in the penultimate line. These won’t work.

Best wishes Jens

Hello

Thank you for your response. Simply it provides the message
“syntax error”.

I was presented with this error message.
TextPoint.text = msg
NameError: name ‘TextPoint’ is not defined

Hello,

you need to use the name of the text-component that displays the feedback, not TextPoint. What is it called?

Best wishes Jens