Error compiling

I use sliders online

Have a look at my crib sheet (see pinned post in the online category) for details of how to code for online

I’ll look at it and try the alternatives.
But should I be worried with the feedback? because it’s importante…

I had to add a code component in builder, for feedback answers, it works well when I run it in builder.
When I run in builder it works fine, but as pilot in pavlovia I get this message, just before this routine starts (the ones before run ok):

image

and I don’t know where to find this loop in js file.
In builder it lokks like this:

image

image

And this is what I have in the code component in builder:
Begin Experiment:
msg=’’
Begin Routine:
if practice1_task1_mouse.isPressedIn(practice1_task1_box1) and correctAns==‘practice1_task1_box1’:
msg=“Helyes!”
answer_loop.finished = True
elif practice1_task1_mouse.isPressedIn(practice1_task1_box2) and correctAns==‘practice1_task1_box2’:
msg=“Helyes!”
answer_loop.finished = True
elif practice1_task1_mouse.isPressedIn(practice1_task1_box3) and correctAns==‘practice1_task1_box3’:
msg=“Helyes!”
answer_loop.finished = True
elif practice1_task1_mouse.isPressedIn(practice1_task1_box4) and correctAns==‘practice1_task1_box4’:
msg=“Helyes!”
answer_loop.finished = True
elif practice1_task1_mouse.isPressedIn(practice1_task1_box5) and correctAns==‘practice1_task1_box5’:
msg=“Helyes!”
answer_loop.finished = True
elif practice1_task1_mouse.isPressedIn(practice1_task1_box6) and correctAns==‘practice1_task1_box6’:
msg=“Helyes!”
answer_loop.finished = True
elif practice1_task1_mouse.isPressedIn(practice1_task1_box7) and correctAns==‘practice1_task1_box7’:
msg=“Helyes!”
answer_loop.finished = True
elif practice1_task1_mouse.isPressedIn(practice1_task1_box8) and correctAns==‘practice1_task1_box8’:
msg=“Helyes!”
answer_loop.finished = True
elif practice1_task1_mouse.isPressedIn(practice1_task1_box9) and correctAns==‘practice1_task1_box9’:
msg=“Helyes!”
answer_loop.finished = True
else:
msg=“Helytelen…”

Can you help me with this?
Gabriela

I saw in this forum the following possibility:

Do you recomend it (I have no experience with coding!)?
G.

Start by putting msg=“ “ in a Begin Experiment code tab

Feedback should be fine but you will need some simple code (as you do offline)

I have that code component in my feedback routine (see below my previous answer) bu in Begin Experiment, I have msg=’ ’ (with single quotation mark, not double) is this important?

I usually put single quotes in the Python which auto translate to double quotes in the JavaScript.

If you already have msg=’ ’ in a Begin Experiment tab then maybe you need it outside the loop.

I’m a little bit lost…

In js file in gitlab, for the text I want to appear after every answer, I have:
// Initialize components for Routine “feedback”
feedbackClock = new util.Clock();
feedback_text = new visual.TextStim({
win: psychoJS.window,
name: ‘feedback_text’,
text: ‘default text’,
font: ‘calibri’,
units: ‘norm’,
pos: [0, (- 0.4)], height: 0.1, wrapWidth: undefined, ori: 0,
color: new util.Color([(- 1.0), (- 1.0), (- 1.0)]), opacity: 1,
depth: -1.0
});

In the code view in builder, I have:
feedbackClock = core.Clock()
msg=’’ (HERE IT’S 2 SINGLE MARKS)
feedback_text = visual.TextStim(win=win, name=‘feedback_text’,
text=‘default text’,
font=‘calibri’,
units=‘norm’, pos=(0, -0.4), height=0.1, wrapWidth=None, ori=0,
color=[-1.000,-1.000,-1.000], colorSpace=‘rgb’, opacity=1,
languageStyle=‘LTR’,
depth=-1.0);

In the code component in builder I have:
Begin Experiment:
msg=’’
Begin Routine:
if practice1_task1_mouse.isPressedIn(practice1_task1_box1) and correctAns==‘practice1_task1_box1’:
msg=“Helyes!”
answer_loop.finished = True
elif …

Can you explain me better what’s the problem? I’m sure it’s a simple logical problem, but I’m really new at this.

Thank you, sincerely,
Gabriela

I would recommend that you try to only look at the components in Builder unless you need to look at the JS file online in order to work out which bit of the Builder is causing the issue.

Is the code I’ve quoted in the same routine that has the text component showing $msg? If so, then that should be okay if $msg is set to update every repeat and the code component is above the text component and the previous routine finishes on the mouse click.

If the code is in the same routine as the response then you are checking the response before you’ve given the participant a chance to respond. It would be better to put it into End Routine so that it is processed after the participant has responded.

I was careful to put the code above the text component, as I read it in the forum:

image

It works fine in builder (here’s a short video of the feedback working), with the parameters in Begin Experiment, that’s why I though the problem was in the js file.
I tried now to the quoted code in End Routine, but then I only get “not correct” answers…

Hi, again :slight_smile:
I adpated the rating scale to a different kind of components, and, without the feddback the experiment is working fine, I tried as pilot in 2 different computers.
But I still need to make the feedback work.
In builder I try a change: I moved the msg=’ ’ from Begin Experiment to Before Experiment, it worked as well in builder, but online I still get the error message: “msg is not defined”…
Do you have any more ideas on how can I solve this problem? To put the feedback working online is the only thing I need to start running the experiment with participants…
Thank you for your time,
Gabriela

You definitely shouldn’t need to put msg=‘’ Before Experiment

Here are two thoughts.

  1. Have you got the text component that displays $msg set to Constant instead of Each Repeat?

  2. Do you have a column called msg in one of your Excel files?

Hi!

it’s set to Each Repeat (once I tried to Constant and it doens’t work)

Actually no.
My condition excel file is very simple:
image

If I create a column msg, what should I put there? correct or incorrect?

In the code component in builder, in Begin Routine, I have:
if practice1_task1_mouse.isPressedIn(practice1_task1_box1) and correctAns==‘practice1_task1_box1’:
msg=“Correct!”
answer_loop.finished = True
elif practice1_task1_mouse.isPressedIn(practice1_task1_box2) and correctAns==‘practice1_task1_box2’:
msg=“Correct!”
answer_loop.finished = True
elif practice1_task1_mouse.isPressedIn(practice1_task1_box3) and correctAns==‘practice1_task1_box3’:
msg=“Correct!”
answer_loop.finished = True

else:
msg="else:
msg=“Incorrect…”

Again: it works perfectly in builder…

Thank you,
Gabriela

Just as a try, I created a column named message,
image
and now something is working online, but off course, the only feedback message I have is “message”…

Sorry for the confusion. I was giving suggestions of what might be causing the error. The text component should be set to each repeat and msg should not appear in the Excel file.

Please could you show screenshots of any code components containing msg clarifying whether the associated routine is inside or outside your loop

In builder, this is what I have:

image

image

image

image

As I told you, I can run this in builder without a problem, but when I go online I get this error message:

image

And when I tried to add a column named msg in excel, like this:

image

then the experiment is not craching but I always get “message” as feedback text:

image

Maybe the problem is than in my feedback_text component I wrote $msg as text?

I don’t know if it helps, but in the js file I find this:

feedback_text = new visual.TextStim({
win: psychoJS.window,
name: ‘feedback_text’,
text: ‘default text’,

and later:

var feedbackComponents;
function feedbackRoutineBegin(snapshot) {
return function () {
//------Prepare to start Routine ‘feedback’-------
t = 0;
feedbackClock.reset(); // clock
frameN = -1;
routineTimer.add(1.000000);
// update component parameters for each repeat
feedback_text.setText(msg);
practice1_feedback_word6.setImage(‘images/tojas.JPG’);
practice1_feedback_word8.setImage(‘images/tudas.JPG’);
// keep track of which components have finished
feedbackComponents = ;
feedbackComponents.push(feedback_text);

Your code components are set to Python only. You need to set them to Auto to create JavaScript code.

It works!!!
sorry for making such a confusion for such a simple error…
Thank you so much!
Gabriela