psychopy.org | Reference | Downloads | Github

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


#1

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?


#2

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!


#3

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";
}


#4

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.


#5

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


#6

thanks for the additional tips @dvbridges!


#8

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?


#9

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


#10

Thank you very much! It works :blush: