psychopy.org | Reference | Downloads | Github

Feedback message error: "ReferenceError: msg is not defined"

I have an experiment uploaded on Pavlovia online, its runs fine on my local machine but when I run the online version I get this “ReferenceError: msg is not defined”. I am using msg() to send feedback on practice trials.

I was getting the error from this python:

if prac_resp.corr:
    msg = "Correct!"
    msgColor = "lawngreen"

else:
    msg = "Oops! That was wrong"
    msgColor = "red"

So I tried converting it to Javascript, below, but I continue to get the same error message.

if (prac_resp.corr){

    msg("Correct!");
    msgColor("lawngreen");
        }
    else{
    msg("Oops! That was wrong");
    msgColor("red");
    }

What is going wrong?

1 Like

Hi everyone,

I just wanted to follow up on my previous post and say that the Python code that I used is taken directly from Chapter 6 on Providing Feedback in the book “Building Experiments in PsychoPy”. From reading various other posts, it seemed the problem might be needing to convert that Python code into JS code. I took a very rudimentary stab at java, as you can see from the above. I am new to both!

Any help or advice would be much appreciated! Thanks!

Hi @lingo, yes the error is because you are treating the msg variable in your javascript as a function, but it should be a variable that holds your text. Have a look at the Navon demo on www.pavlovia,org. In that experiment, we define the msg variable in the JS code component like this:

# Begin experiment
msg='';

# Begin routine

if (resp.corr > 0) {
     msg="Correct! RT=" + resp.rt.toFixed(3); 
} else {
     msg="Oops! That was wrong";
}

2 Likes

Hi @dvbridges, many thanks for your reply. Unfortunately I’m back to square one. After trying to follow your advice, the experiment simply wouldn’t run at all anymore, even from within the PsychoPy app. I recreated it, and am now having trouble getting it online. The html isn’t exporting for some reason. And the old experiment keeps reappearing when I upload the new one, even though I’ve removed the old one.
I will keep at it and hopefully troubleshoot my way there.

@lingo, a new release of psychopy is available. I would update just in case, but if you are starting again, 1) delete your .git file in your local experiment folder (make sure you have folder settings to view hidden files), and 2) delete your online project on pavlovia.

thanks for the additional tips @dvbridges!

Hey there,
A quick question, how to delete online project on pavlovia quickly (like in once)? I only know how to delete the single file one by one, but if one of my online project on pavlovia account has thousands of files, it’s impossible to delete single file one by one to kill the whole project. So any suggestion?

Go to Settings, then Advanced Settings, then scroll down to Remove Project

Thank you very much! It works :blush:

Hi!
I have the same problem because I wanted to give a feedback during the experiment. Finally I decided it was not a good idea so I deleted the feedback.
Well, I continue to have the same error, but I have deleted the portion that contain the feedback…So I am confused. Importantly I tried several option in order for the portion with feedback to have no effect: I used an old program that had never included a feedback and I put it on Pavlovia (I still get the message), I uninstalled Psychopy (I still get the message), I used another account of Pavlovia (I still get the message). It is as if PsychoPy kept a track of that routine that I once created but no longer exist.
Has someone have an idea?
Best,
Alessandro

@Alessandro_Guida have you made sure the cache is clear when reloading the experiment because reloading the page often does not reload the javascript (e.g. ctrl-shift-R will usually reload the page and also clear the cache).

Waw Jon that was fast!
Thank you very much it indeed worked.
Best,