URL of experiment: https://gitlab.pavlovia.org/obemar/masterthesis-automatic-sound-symbol-matching
Description of the problem:
Hi,
I’m trying to run a language experiment online but have some issues with JS. I used Builder but needed code components. It works fine offline on my acer with windows 10.
I get past the initalizing stage and am able to enter a participant code but afterwards the “random is not defined” error pops up.
I used code to assign participants to either version 1 or 2 (via a dummy loop) and within 1 or 2 I counterbalanced the starting block (Group A or B).
To create the JS code I relied on the forum-posts on this topic and used the Math.random function which seems to be the common solution for randomization. I also deleted “var” because from what I read, it seemed to cause problems sometimes.
I have no clue about my error and would be happy if someone may have a look on my JS code. I put the experiment to public, anyway here’s some of the JS code I used to randomize and counterbalance:
assign participant to V1 or V2:
in Begin Experiment (I also had it in End Routine but it didn’t work online either)
function random_character() {
chars = "CD";
return chars.substr(Math.floor(Math.random()* 2), 1);
}
nReps = random.character();
if ((nReps === "C")) {
nReps_v1 = 1;
nReps_v2 = 0;
} else {
nReps_v1 = 0;
nReps_v2 = 1;
}
counterbalance Group A or B within a version
in Begin Routine
function random_character() {
chars = "AB";
return chars.substr(Math.floor(Math.random()*2),1);
}
condition = random.character();
and in the loop I entered $‘Group’ + condition + ‘.xlsx’
I also have code for a few typed responses but since I took (and modified it a little) the code from the Pavlovia Demo Experiment “textinput” and there’s no random in it, I guess this is not causing the issue.
Thanks for any help,
Maria