psychopy.org | Reference | Downloads | Github

Online experiment stuck at 'Initialising the Experiment'

URL of experiment: des condition [PsychoPy]

Description of the problem:
the experiment can run at psychopy, but stuck at ‘Initialising the Experiment’ when online, I had translated the coding into JS, and add a blank at text, but it still stuck
the code is as below:
import {Design, Prospect} from ‘darc_toolbox’;
import {days_to_string} from ‘darc_toolbox/utils’;
import {data_plotter} from ‘darc_toolbox/data_plotting’;
import {event} from ‘psychopy’;
import {gui} from ‘psychopy’;
import * as random from ‘random’;
var keys, rand_num;
rand_num = random.random();
keys = event.waitKeys({“keyList”: [“1”, “2”, “3”, “4”]});
console.log(keys);
if ((keys[0] === “1”)) {
result_2.text = “100”;
} else {
if (((keys[0] === “2”) && (rand_num <= 0.5))) {
result_2.text = “200”;
} else {
if (((keys[0] === “3”) && (rand_num <= 0.2))) {
result_2.text = “500”;
} else {
if (((keys[0] === “4”) && (rand_num <= 0.1))) {
result_2.text = “1000”;
} else {
result_2.text = “0”;
}
}
}
}

As per my crib sheet you can’t import Python libraries if you want to run your experiment online.

thks, so did I need to delete the synatx in begin routine? even though I had transleted it to JS

Have you translated the libraries to JS?

Import statements in PsychoJS don’t have { brackets and should go in Before Experiment, c.f.

import PsychoPolyFill from 'https://run.pavlovia.org/tpronk/demo_polyfill/PsychoPolyfill.js';

thks, I’ll check it carefully