Online Experiment Stuck on "Initializing the experiment"

URL of experiment: https://pavlovia.org/Jesusjlopez619/multitasksoundbehavioral

Description of the problem: Hello, I’m trying to get my task running online on Pavlovia, but I’m stuck on. “initializing the experiment…” like many others here. I went through the Psychopy to js crib sheet and I believe I have converted everything that should be. I also checked the error message I receive when trying to run my task online. It is as follows: ERROR Line 1360: Unexpected end of input in MultitaskSound2-legacy-browsers.js.

I believe this may be due to a missing bracket somewhere in the js code, but i don’t receive any syntax errors when looking through the code with Auto -> JS active. Would anyone be able to help me with this problem?

Thank you in advance!

missing } at line 82

Thank you! That seemed to fix that issue.

I’m now getting the following message after entering the Participant ID when piloting the experiment:
“ReferenceError: PsychoJS is not defined.” Do you know what might be causing this error?

no problem.

could you bring up the console (“f12” if you are using windows) and paste complete error message? a line number is really helpful in this case.

Yes, absolutely. Attached should be an image of it. Please let me know if there’s anything else that might help you figure this out. I really appreciate of. your help!

“psychoJs” should be “psychoJS” at:
line 135 of MultitaskSound2.js
line 127 of MultitaskSound2-legacy-browsers.js

I can’t believe I missed that, thank you so much. I went through and found (and fixed) a few more typos I spotted, but now it seems I have an issue with my conditions file.

It seems to be an issue with the “Selected rows” section in my loop since I defined the “random” function at the beginning of my experiment.

I also tried adding the $ in front of random, but that returned the following error:

Do you have any advice for how to fix this issue? Again, I really do appreciate all the help you’ve been able to give me.

I don’t think that you can have random in the loop definition. You’ll need to create a variable that contains a random selection of rows…or you could just stop the loop early.

Glad to help. But I got to say I don’t have much experience with the builder, especially the condition files. Hopefully my speculation would help.

I guess “var random” and the function is generated by the builder? But I can’t find it being used anywhere in the js file. If it is not, I suggest getting rid of “var random” and the function to start with.

Also there is a problem with the function. I assume the parameter “a” is the number of random numbers. But it is not passed into the function. As a result, random(20) will only return one random number in [0,1). It should be in a for/while loop and “a” is the maximum loop value. If you want “a” to be the maximum value, it should be something like “return Math.random()*a;”

Anyway, if you just want to select 20 out of 195 conditions, I think what you put in “Selected” should be fine and TrialHandler already takes care of it. Again, please take these with a grain of salt.

I tried creating a variable according to the “dynamic” solution here Selecting different rows per iteration in a loop, but entering the argument they suggest into the “selected rows” results in the “ok” box being greyed out.

I then tried ending the loop early by setting a variable named this_loop_number and increasing that by 1 each time it’s executed. I then end the loop when it hits a certain number (3 for testing purposes), but this only seems to work for the first run through of the loop. Is there a piece of code I’m missing somewhere?

I’ll explain the task in case it helps to understand what I’m trying to do. My experiment consists of two tasks. The primary task just asks the subject to respond to whether a math operation is correct. On random trials (I have this set to be every trial right now for testing purposes), a popup will appear on screen (I have to fix the positions for psychoJS but I haven’t done that yet as i’ve been trying to get it to run properly at first) as well as play a tone to indicate a possible switch. If they choose to switch by pressing ‘Y’, they then complete a word completion task where they see a word with missing letters and they must complete the word by typing in the missing letters. Once they complete this word completion trial (or they run out of. time), it then returns to next trial of the primary task.

I see what you mean about the random function, but I can apparently not use that argument in the loop definition, so I have to fix it another way.

Nevertheless, I really do appreciate your help!

What are you doing to reset this_loop_number?