Displaying correct feedback does not work

Description of the problem:

I am setting up an online experiment in which I want to give feedback that evaluates if the response given by the participant was correct.

Importantly, when no response was given, I want a message to be displayed that states: “too slow”.
I have 2 problems:

  1. the “too slow” feedback is never being initiated, my feedback always displays “correct” or “incorrect”.
  2. my response from the previous trial seems to be carried over, even when I don’t press anything, it gives me the feedback from the previous trial again.

I have set up two routines. In the first routine my key response (set to every repeat) is recorded and I have ticked the boxes in the keyboard component that discards previous, which is why I don’t understand the carrying over of responses.
In a following feedback routine I have included this in a code components “Begin routine” tab:

if (resp_test_inst_t1.corr) {
    thisFeedback = "Correct!";
} else {
    if ((! resp_test_inst_t1.keys)) {
        thisFeedback = "Too Slow";
    } else {
        thisFeedback = "Incorrect";
    }
}

And of course a text component that displays the feedback with $thisFeedback

I would appreciate any help, as I have already consulted these topics:

…I would appreciate any ideas on what I am missing here.
Thank you in advance!

Hello,

ok, this part of the if-else construction evaluates apparently never as true. You could add some print-command to check the values of the relevant variables.

You might want to try

if ((resp_test_inst_t1.keys === null)) {

Best wishes Jens

@JensBoelte Thanks for your help!
Unfortunately,

if ((resp_test_inst_t1.keys === null)) {

did not work. I checked what resp_test_inst_t1.keys is logging and it seems not empty, but it is logging: [ ] . I tried this and also tried to just negate the statement, and did

if (((!resp_test_inst_t1.keys === "right") || (!resp_test_inst_t1.keys === "left"))) {
    thisFeedback = "Too Slow!";
}

However, I am remaining without success until now.
Best wishes, Frieda

Hello Frieda

what do you mean with

I admit that I did not test the above mentioned code online. The code I posted is auto-translated-code.

Perhaps, the following toy-experiment is more helpful. It accepts y and n as answer to y and n as stimuli. The stimulus and the correct key are set in an Excel-file. The feedback-routine presents correct, wrong and no answer as feedback-message.

feedback4.psyexp (15.3 KB)
feedback4.xlsx (8.5 KB)

I tested the experiment in a local browser. I hope that this helps

Best wishes Jens

Hi @JensBoelte,

many thanks for sending the example experiment with the working feedback routine. That definitely helped to identify the mistake I made.
It now works for me.
I figured out that, in a different code component, I still had these lines of code as a leftover code from something else:

if ((resp_test_inst_t1.keys === undefined)) {
    resp_test_inst_t1.keys = [];
    resp_test_inst_t1.rt = [];
}

I suspect that this was the reason for the feedback not working in case of no button presses.

Have a good day and thanks for you help!