Pilot experiment stuck in "initialising the experiment"

Well, the good news is that this error message isn’t related to your experiment, that error is for the repository page itself. If you launched the experiment and opened the console on that page, then you would see any javascript errors that were from the experiment code. To my surprise, Pavlovia didn’t do what it usually does in these cases and pop up an error window. However, when I checked the console from the actual experiment page, I got this:

Much more informative. It’s getting stuck because of a simple syntax error.

Looking through that bit of code, it seems to be a custom component? Custom components don’t handle library imports right now, so importing os, random, and time like they’re python libraries just won’t work.

Looking at the actual code, you don’t need the os import at all (among other things that looks like it was partly to fix something on the Python side that I addressed recently: Working directory change with 2020.1 and later?).

Every instance of “time” will need to be replaced with either Date.now() or a util.Clock object, both of which are built in to this experiment already (you will need to do this several times, I see the time library is invoked at several points throughout the experiment).

“random.shuffle” needs to be replaced. Now, by default the way PsychoPy would like you to do this involves using a TrialHandler or just setting it up in the builder. If that won’t work for you, you can simply roll your own shuffle function:

function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex;

  // While there remain elements to shuffle...
  while (0 !== currentIndex) {

    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;

    // And swap it with the current element.
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
  }

  return array;
}

This is a standard JavaScript shuffle function that you can find with some cursory googling. The Math library is built in, no extra imports required.

EDIT: And I should add, this is how to fix it by directly modifying the javascript. It’s probably the fastest way to go. There are possibly more elegant solutions you could pursue within the builder, but this is the one I’m most confident will just work.