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");
}
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";
}
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.
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?
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).
Hello, everyone,
since I was looking in this thread for an answer to problems I was having with the feedback screen, I am sharing with you the solution to my problem, hoping that this will help others in the future.
Also in my case, I couldn’t understand why I was getting the error message telling me that the text was not identified. Yet, I wrote the code correctly and followed the same steps I learned during the webinar.
What I realized is that the order in which the components are added to the feedback routine is of great importance. If, as I used to do, the text component is inserted BEFORE the feedback, this will affect the order in which the code will be executed: in my case text_4.setColor and text_4.setText were executed BEFORE the IF and ELSE and I was getting an error on line 578. This was obviously because the variable was not defined before being inserted into the function.
After many attempts, I realized that in the construction of the routine, the code component should be added before the text component. At the code level, things will be written in the correct order, the variables will be defined correctly and this, at least in my case, solved the problem.
I realize that I am very late, as this is a thread from 2 years ago, but I hope, in any case, that someone will find it useful if they run into the same problem as me.
Greetings to all