Feedback for incorrect responses, but not if correct


I need to give participants feedback during an experiment.
During the training trials routine, I would like to have it where if the participant selects the wrong key that it will go to a different image saying “oops”, then they press space to go to the next training trial.
For the main experiment, there will be timed feedback, which I think I can do in the same routine as the main stimuli (as in, timed image, and response availability, then new image comes up where you can only press spacebar to continue). However, if I can’t get that to work, then whatever I do here for feedback could be replicated for the target trials.

But for the “you got it wrong” feedback, I tried following the code advice given to someone else for something that was similar, but it’s not working (“correct/incorrect feedback using images” Correct/incorrect feedback using images - #2 by B.D.5).

No matter what key I press on the training, it always sends me to the “you got it wrong” image. I checked my key presses on my spreadsheet, and they are recording correctly. The correct images are pulling, everything else about it works fine.

Is there a way to get it so that the feedback only shows if it’s wrong, otherwise it just continues to the next trial?

I know I’m doing something wrong (obviously since it isn’t working), so any help would be appreciated.
I would prefer to do this in builder, as my python coding is super rusty.

Hello linguisticky

do you mind showing us how you try to achieve this, e.g. screenshots of the relevant routine and the code-component. Did you by any change forget to add a $-sign in the correct answer parameter?

Best wishes Jens

Hopefully the images show up.

continueRoutine = False

I had it without the caps initially, and it still played the routine regardless of the answer.

So I looked at the link and opened the experiment downloads that were provided in the link I included, and their code had it with the caps.

So either way it’s not working


when there is a spelling error, it might be ignored by Psychopy. The proper syntax is the one provide by @wakecarter Ok, do you mind showing us how you specify KeyCorrect in your Excel-file or submit/upload a toy-version of your experiment (delete all routines irrelevant to the problem here, discard components that need images, upload a shortened version of the Excel-file) here.

Do you want feedback for the incorrect trials only?

Best wishes Jens

I’m going to try rebuilding from scratch with just a text component (so that I can get some sort of feedback that it worked). The drive that the original experiment was created on has become corrupted so I’m just going to start from scratch in the hopes that it works and maybe something else happened to the file and that’s why it’s being strange. (I had the original lower case code and everything initially and it wasn’t working).

So, I’ll make two routines and a loop with a basic excel that just has correct key presses. Then for the second routine I’ll use the following code as a ‘begin routine’ set up:
if (whatever key response it is.corr == 1):
continueRoutine = False

I’ll see what happens and then if that doesn’t work I’ll upload that here so that you all can look at it.

Apologies if I’ve been less than helpful, dealing with the corruption has thrown my timeline off so I haven’t been able to really trouble shoot this as actively as I wanted to, as I’ve had to remake all my stimuli.

I will update once I try just a basic set up.

Hello lingusticky

sorry to hear about your file corruption problem. Did you use a cloud drive? PsychoPy (Pavlovia) and cloud drives don’t go along well. In any case,


is a boolean variable, so it is True when the correct key has been pressed, False when the incorrect key has been pressed and None (undefined) when no key has been pressed. Therefore, there is no need to test for a specific value

if not key_resp.keys: 
    msg="You failed to respond"
elif key_resp.corr: 
    msg = "correct"

should do the trick. The first if checks whether the participant has responded or not. If this is true the expression evaluates as false and proceeds to the following elif. If a participant has responded with the correct key, this evaluates as True and the message is set, if not the message defined in the last else is set.

Success Jens.

It was a USB. I think it has more to do with the security settings on the university computers. But, we’re just going to put it on the computer itself and then if I can get it to work I’ll at least have a master backup.

I tried with the exact same setup as my routine would be in the experiment, just without images. That way I don’t have to do any additional booleans and can adapt what I did to the images.
The mini test worked.
So step by step now and test at each interval, then when this routine is done and functioning, I can move on to the next one.

I’m going to take a staggered approach and test it piece meal. Then hopefully if anything comes up I can isolate where it went sideways and then bring that back so that it is easier to get help and feedback.
I know better than to do a big chunk of changes and then test. Hubris got me again.
If this works after adding in the other components, I’ll come back and mark it as resolved.

If there is a version synced with Pavlovia then you can retrieve that version instead of starting from scratch (and select any commit)

Hey everyone,

Thanks for all your help.
I’m going to chalk up the errors happening to the corruption that occurred, as the rebuild from scratch is working how it is expected based on everyone’s feedback.

1 Like