psychopy.org | Reference | Downloads | Github

Feedback issue in online experiments

Hi,
I am having a problem with the feedback in my experiment. It runs correctly in Builder.
But online - there is no feedback. I read about this issue and it seemed to be easy to fix, but strangely it is not working. I have a coding components with the following:

Begin experiment

msg = "";

Begin routine

if not response.corr:
    msg = "No response"
    msgColor = "red"
elif response.corr == 1:
    msg = "Correct!"
    msgColor = "green"
else:
    msg = "Error!"
    msgColor = "red"

I read that I need to translate this code into JavaScript in order it to work on Pavlovia. I did it automatically using Auto JS function in Psychopy3. So now when I try to launch the experiment in Pavlovia, it works but there is no feedback. What am I doing wrong?

Can you share the experiment repository on Pavlovia? This is the Python code, but in order to figure out what’s not working online, the JavaScript is what’s relevant.

To be clear, is it not giving you any feedback at all, or is it giving you the wrong feedback? There can be issues with resposne.corr because Python and JavaScript use different key-codes, see Pavlovia storing all key_resp_stimuli.corr as wrong

Thanks Jonathan!
For some strange reason now it is giving me the feedback. But not completely correct. Instead of “Error” - always “No Response”. Correct feedback is fine. And No Response also.

Here is the experiment’s URL:
https://run.pavlovia.org/MarinaIosifian/semantic-primining-children/html

And this is how translated JavaScript looks like:

if ((! response.corr)) {
    msg = "No response";
    msgColor = "red";
} else {
    if ((response.corr === 1)) {
        msg = "Correct!";
        msgColor = "green";
    } else {
        msg = "Error!";
        msgColor = "red";
    }
}

Yep, that’s the same issue as the thread I linked. response.corr is always being coded “wrong”. You may need to specify what the “correct” keys are in a different way. Try replacing whatever “correct” is with the JavaScript key-codes for those keys, which you can get from here: https://keycode.info/

Thanks Jonathan! My correct answers are keys “e” and “i”. So in my conditions xlsx file instead of “e” and “i” I put JS codes (69 and 73). In Builder the allowed keys are still “e” and “i” (or should I also put 69 and 73 instead?). I synchronized with Pavlovia, but the response.corr is still being coded as “wrong”…

This is one where I’m actually not 100% on exactly what Pavlovia needs because I haven’t used this particular functionality myself. There are multiple ways that keycodes can be read off by JavaScript, so I’m going to recommend trying different permutations until one works. For example, try KeyE and KeyI.

The “allowed keys” should only affect whether it accepts those keys as input at all, so if it’s recognizing the key-presses than that should be fine. You could also look in your code repository in the html folder and see how the JS renders the “allowed keys” for the keyboard object (just search for the name of the keyboard component in the JS file), and see how they’re listed there.

Strangely enough I only get my “Correct” feedback when I code the keys as e and i. KeyE does not seem to work, neither 69.
Thanks a lot, Jonathan! At least it seems to be working now!

I think this isn’t to do with keycodes. PsychoJS should be translating your keycodes to the same equivalent values as PsychoPy.

I think the issue is your code logic (I think in the python version it should also be giving “no response” instead of any “error”). If no response then response.corr == None and if incorrect response then response.corr==0 but both of those fall under the heading not response.

I think you want this:

if  len(response.keys)==0:
    msg = "No response"
    msgColor = "red"
elif response.corr == 1:
    msg = "Correct!"
    msgColor = "green"
else:
    msg = "Error!"
    msgColor = "red"

and I believe that should correctly autotranslate into JS andd work there too.

But move your key definitions back to the letter names as in the python version. That should be the same