# Feedback Message Not Displaying in Pavlovia After Response

**URL:** <https://discourse.psychopy.org/t/feedback-message-not-displaying-in-pavlovia-after-response/43853>\
**Category:** Online experiments\
**Tags:** online, pavlovia\
**Created:** [February 11, 2025, 7:52pm UTC](https://discourse.psychopy.org/t/feedback-message-not-displaying-in-pavlovia-after-response/43853 "2025-02-11T19:52:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![liv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/liv/32/43971_2.png) [@liv](https://discourse.psychopy.org/u/liv)\
**Post date:** [February 11, 2025, 7:52pm UTC](https://discourse.psychopy.org/t/feedback-message-not-displaying-in-pavlovia-after-response/43853/1 "2025-02-11T19:52:45Z")

</div>

URL of experiment: [[Updated\_SDS [PsychoPy]](https://run.pavlovia.org/lvillarreal22/updated_sds/? __pilotToken=98f13708210194c475687be6106a3b84&__ oauthToken=81949ee1f139c16f386d18b6bd63206bfa119ed8b33a910aadc4c868e85cbd1d)

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

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [February 12, 2025, 9:32am UTC](https://discourse.psychopy.org/t/feedback-message-not-displaying-in-pavlovia-after-response/43853/2 "2025-02-12T09:32:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 12, 2025, 10:14am UTC](https://discourse.psychopy.org/t/feedback-message-not-displaying-in-pavlovia-after-response/43853/3 "2025-02-12T10:14:39Z")

</div>

Have you put `msg = ''` in Begin Experiment?

> [@Wakefield's Daily Tips](https://discourse.psychopy.org/t/wakefields-daily-tips/43371/41):
>
> ReferenceError: varName is not defined This is one of the most common errors in online experiments It is also one of the easiest to solve. The issue is one of “scope”. To define a variable so it has scope across your whole experiment, all you have to do is assign it a value. Don’t edit your JavaScript to add “var” or “let” commands. To give your variable scope assign the value in a Begin Experiment code component tab outside any clauses (i.e. no Python indents). I usually s…

---

<div class="post-metadata">

**Author:** ![liv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/liv/32/43971_2.png) [@liv](https://discourse.psychopy.org/u/liv)\
**Post date:** [February 18, 2025, 7:39am UTC](https://discourse.psychopy.org/t/feedback-message-not-displaying-in-pavlovia-after-response/43853/4 "2025-02-18T07:39:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 18, 2025, 7:49am UTC](https://discourse.psychopy.org/t/feedback-message-not-displaying-in-pavlovia-after-response/43853/5 "2025-02-18T07:49:12Z")

</div>

How is corr defined?

---

<div class="post-metadata">

**Author:** ![liv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/liv/32/43971_2.png) [@liv](https://discourse.psychopy.org/u/liv)\
**Post date:** [February 18, 2025, 7:50am UTC](https://discourse.psychopy.org/t/feedback-message-not-displaying-in-pavlovia-after-response/43853/6 "2025-02-18T07:50:21Z")

</div>

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](https://gitlab.pavlovia.org/lvillarreal22/iat_1).

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

Thank you!

---

<div class="post-metadata">

**Author:** ![liv](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/liv/32/43971_2.png) [@liv](https://discourse.psychopy.org/u/liv)\
**Post date:** [February 18, 2025, 8:15am UTC](https://discourse.psychopy.org/t/feedback-message-not-displaying-in-pavlovia-after-response/43853/7 "2025-02-18T08:15:50Z")

</div>

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`.

```javascript
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.

```javascript
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

```

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [February 18, 2025, 8:25am UTC](https://discourse.psychopy.org/t/feedback-message-not-displaying-in-pavlovia-after-response/43853/8 "2025-02-18T08:25:15Z")

</div>

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

> [@Wakefield's Daily Tips](https://discourse.psychopy.org/t/wakefields-daily-tips/43371/41):
>
> ReferenceError: varName is not defined This is one of the most common errors in online experiments It is also one of the easiest to solve. The issue is one of “scope”. To define a variable so it has scope across your whole experiment, all you have to do is assign it a value. Don’t edit your JavaScript to add “var” or “let” commands. To give your variable scope assign the value in a Begin Experiment code component tab outside any clauses (i.e. no Python indents). I usually s…

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [February 18, 2025, 8:31am UTC](https://discourse.psychopy.org/t/feedback-message-not-displaying-in-pavlovia-after-response/43853/9 "2025-02-18T08:31:56Z")

</div>

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

```auto
msg = " "

```

Then in the Begin Routine tab of feedback\_IAT or the End Routine tab of trial\_IAT add

```auto
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
