Stuck on experiment initialising

URL of experiment:

https://run.pavlovia.org/TUPS/thpn-img-21-v2/?__pilotToken=6512bd43d9caa6e02c990b0a82652dca&__oauthToken=b0365263db1d83f3e9fb80ae0c03d13aca7b7ddc2039518225cfbaa4961d7762

Description of the problem:

Everything is working offline i.e. on the computer but my study is stuck on initialising when I try to pilot it in a web browser. I only have a couple of user entered coding parts; one which randomises the conditions at the start of the expt (works offline) and the other prints a message at the end of the expt based on participant input.

I also got my friend to have a look at my auto-generated java script and he changed it slightly, but it still has the same issue (stuck on initialising).

I went back to the previous version of Python code (found from a post on this forum somewhere) with the auto-generated java script.

I’ve searched the posts with the same problem (seems to be common) but haven’t found a solution yet. I tried in both Firefox and Google Chrome.

I haven’t tried a version without the code.

My experiment has a rating scale component. I seem to remember that being an issue for online studies? Not sure if it could be that?

I’m not sure how to share my code here?

Hope someone can help.

Thanks

Ben

Hi There,

You have an import * as random from 'random' statement on the javascript side of your code. This is valid python (so it works locally) but invalid Javascript (so it break online) please see the crib sheet for guidence

Becca

Hi Becca,

Thanks for your reply. Initially I thought that that was the issue so managed to get some help from a friend and used the following code in place of it (I also changed the psychopy code element to JS and then recompiled the JS):

function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
switch (getRandomInt(3)) {
case 0:
condition = “A”;
break;
case 1:
condition = “B”;
break;
case 2:
condition = “C”;
break;
}
msg = expInfo[“participant”];

It works as intended offline but it still didn’t initiate in the browser. I wondered if it might be an additional problem or something else I have overlooked or am missing.

Ben

Actually, I just tried it again with the code above - it now initialises, but I got the following error:

Unfortunately we encountered the following error:

  • ReferenceError: assignment to undeclared variable condition

Try to run the experiment again. If the error persists, contact the experiment designer.

https://run.pavlovia.org/TUPS/thpn-img-21-v2/?__pilotToken=c81e728d9d4c2f636f067f89cc14862c&__oauthToken=b0365263db1d83f3e9fb80ae0c03d13aca7b7ddc2039518225cfbaa4961d7762