Feedback Message Not Displaying in Pavlovia After Response

URL of experiment: [Updated_SDS [PsychoPy]

Description of the problem:

Hi,

I’m working on an Implicit Association Test (IAT) project where participants respond by pressing ‘A’ or ‘L’ on the keyboard. After each response/trial, a feedback message should appear:

  • A “+” for correct responses
  • A “oops” message for incorrect responses

This works perfectly in PsychoPy using the following code:
if corr==0:
msg=“oops”
else:
msg=“+”

However, when I sync the experiment to Pavlovia, the feedback messages do not appear. I double-checked the JavaScript (JS) script, and the function is embedded, but for some reason, it still does not display during the experiment

Any guidance or troubleshooting tips would be greatly appreciated!

Thank you

Dear @liv

You have posted a link to an experiment in pilot mode. Such links will expire after 60 minutes. It is better to post a toy version of your experiment here that also shows the bug, or give access to your git repository.

By the way, did the feedback work from the beginning? If not, try running the experiment in an incognito tab.

Best wishes Jens

Have you put msg = '' in Begin Experiment?

1 Like

Hello, I went back and changed it to msg = '', but it still isn’t working. It worked for one run, but in some trials, the message appeared while in others it didn’t. The function runs perfectly in PsychoPy, but when synced to Pavlovia, it doesn’t behave the same way. Sorry for the late reply btw

How is corr defined?

Hello,

Thank you for the heads-up! I’m still new to Pavlovia and didn’t realize that pilot mode links expire so quickly. The feedback issue has been inconsistent from the start—it works fine in PsychoPy but behaves unpredictably on Pavlovia. Occasionally, the message appears, but most of the time, it doesn’t show anything at all.

I’ve already tried setting msg = '' at the beginning of each trial, but the issue persists. I also tested it in an incognito tab, but that didn’t resolve the problem.

I created a simplified version of the issue, and my Git repository for the experiment is available here: IAT_1 Repository.

Please let me know if you need any additional details or if there’s another approach I should try.

Thank you!

I have corr defined in two places in my experiment.

  1. At the End of the Block Routine (under trial_iat) - This is where all the stimuli are presented.
  • Once a selection is made, the script evaluates the response
  • If a key response is recorded (key_resp.keys is not undefined), corr is set to key_resp.corr.
  • If a touch response is used:
    • Clicking the left side (clicked_name[0].includes('left')) is correct if CorrAns === 'a'.
    • Clicking the right side (clicked_name[0].includes('right')) is correct if CorrAns === 'l'.
    • If the response matches the correct answer, corr = 1; otherwise, corr = 0.
console.log("Key Response:", key_resp.keys);  // Debugging

if (key_resp.keys !== undefined) {  // Ensure keys exist before checking
    corr = key_resp.corr;
    rt = key_resp.rt;
} else {
    rt = touch_resp.time[0]; // Ensure it's defined
    if ((touch_resp.clicked_name[0].includes('left') && CorrAns === 'a') ||
        (touch_resp.clicked_name[0].includes('right') && CorrAns === 'l')) {
        corr = 1;
    } else {
        corr = 0;
    }
}

// Ensure PsychoPy logs the correct values
psychoJS.experiment.addData('rt', rt);
psychoJS.experiment.addData('corr', corr);
psychoJS.experiment.addData('conds_file', conds_file);
console.log("Correctness (corr):", corr);  // Debugging
  1. Feedback Routine (Immediately After Selection) - After a response is made in trial_iat, the experiment transitions to the feedback routine.
  • The feedback message is determined based on corr:
    • If corr === 1, a +` is displayed.
    • If corr === 0, oops appears.
  • Before setting the feedback message, the script ensures that corr is defined.
console.log("Feedback routine started.");
continueRoutine = true;
console.log("Checking corr value before setting message:", corr);  // Debugging

if (typeof corr === 'undefined' || corr === null) {
    console.log("Warning: corr is undefined or null, setting to 0");
    corr = 0;  // Default value
}

if (corr === 0) {
    msg = 'oops';
} else {
    msg = '+';
}

console.log("Feedback Message Set:", msg);  // Debugging

You’ve shown JS rather than Python code, but it looks like you’re experiencing a very common variable scope issue.

corr needs to be defined as well as msg

Hello

You define ms in a Begin Experiment tab of the feedback_IAT routine. However, you never set it to depend on the value of corr.

So define msg in a Begin Experiment tab of a code-component

msg = " "

Then in the Begin Routine tab of feedback_IAT or the End Routine tab of trial_IAT add

if corr == 0:
    msg = 'oops
else:
    msg = '+'.

It is also better to move the code-componet of trial_IAT to the bottom of the routine.

Best wishes Jens

1 Like