Feedback message either shows "default text" or "too slow"

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): macOS Big Sur 11.6
PsychoPy version (e.g. 1.84.x): v2020.2.10
Standard Standalone? (y/n) If not then what?: y

What are you trying to achieve?:

I have two types of stimuli shown (long or short). Participants must respond “z” for long and “m” for short. I would like to provide feedback after some responses, but not all.
If they correctly respond for long, then I want there to be a 60% chance that a “correct +50 points” message appears afterwards.
If they correctly respond for short, then I want there to be a 20% chance that a “correct +50 points” message appears afterwards.
If they are incorrect, no message should appear and it continues to the next trial.
If they miss a response, I want there to be a “Too slow” message.

What did you try to make it work?:

In my feedback routine, I created a code component with the following code at each part of the experiment:

Begin experiment tab:

import random
rewarded = [ ]
msg = '.'

Begin Routine tab:

randomNumReward= random.randint(0,100) 

if not userAnswer.keys:
    msg="Too Slow"
elif userAnswer.corr and smile_stimulus=="long" and randomNumReward <=60:
    msg="Correct! + 50 points"
elif userAnswer.corr and smile_stimulus=="short" and randomNumReward <= 20:
    msg="Correct! + 50 points"
    rewarded = True
    rewarded = False

thisExp.addData('rewarded', rewarded) 

Next, I added a text component (below the code component) in the same routine, where in the “Text” box I put “$msg” and set it to “set every repeat”.

Note: userAnswer and smile_stimulus are from the previous routine. “short” and “long” are in my conditions file under a column titled “stimulus”, which I entered in the smile_stimulus image box as $stimulus (set every repeat).

What specifically went wrong when you tried that?:

The experiment runs, but there are two problems:

  1. The message shown is always “default text” unless,
  2. When I purposefully omit a response, the text “Too Slow” appears, but on every subsequent trial, no matter what I respond, the “Too Slow” message appears

I’ve used a similar set up in previous experiments using the same version of psychopy/OS and did not run into this issue, so I’m a bit at a loss at what’s happening here. I’ve also read a few other similar posts, but didn’t find a solution that worked for me.

Side note: I already have a functioning version of this task written in python using the coder, but I need to run it on Pavlovia and ran into major problems with generating PsychoJS. I tried to sync a version to Pavlovia by copy-pasting the python code from the coder into a code component in the builder, but kept receiving syntax errors in the JS columns (even though it runs). So in the end, I decided to recreate it using the builder.

Any insight would be wonderful, thank you in advance :slight_smile:

I fixed the first problem by changing “smile_stimulus” to the actual column name in the conditions file, but the second problem still persists.

I managed to get rid of the second problem by changing msg=None to msg=" "