URL of experiment: Pavlovia
Natalie Alessi / ccD_chB_exp1 · GitLab
Description of the problem:
So my experiment is just about done but I keep getting this weird problem that happens about half the time. I tried recreating the error but it seems random. So essentially, participants click on one of the image objects and then the images on the next screen are based on the selection. Here’s the JS code, which is in “every frame”:
// Practice show results
stateAp = ;
stateBp = ;
stateCp = ;if (Ap_high.contains(mouseprac)) {
stateAp = ‘high.png’;
} else if (Ap_low.contains(mouseprac)) {
stateAp = ‘low.png’;
} else if (Bp_high.contains(mouseprac)) {
stateBp = ‘high.png’;
} else if (Bp_low.contains(mouseprac)) {
stateBp = ‘low.png’;
} else if (Cp_high.contains(mouseprac)) {
stateCp = ‘high.png’;
} else if (Cp_low.contains(mouseprac)) {
stateCp = ‘low.png’;
} else {
console.log(‘error in setting practice variable’);
}k = Math.random();
v = Math.random();
console.log('random number k is ’ + k);
console.log('random number v is ’ + v);if (Ap_high.contains(mouseprac)) {
if (k < 0.5) {
stateBp = ‘high.png’;
} else {
stateBp = ‘low.png’;
}
if (v < 0.5) {
stateCp = ‘high.png’;
} else {
stateCp = ‘low.png’;
}
} else if (Ap_low.contains(mouseprac)) {
if (k < 0.5) {
stateBp = ‘high.png’;
} else {
stateBp = ‘low.png’;
}
if (v < 0.5) {
stateCp = ‘high.png’;
} else {
stateCp = ‘low.png’;
}
} else if (Bp_high.contains(mouseprac)) {
if (k < 0.5) {
stateAp = ‘high.png’;
} else {
stateAp = ‘low.png’;
}
if (v < 0.5) {
stateCp = ‘high.png’;
} else {
stateCp = ‘low.png’;
}
} else if (Bp_low.contains(mouseprac)) {
if (k < 0.5) {
stateAp = ‘high.png’;
} else {
stateAp = ‘low.png’;
}
if (v < 0.5) {
stateCp = ‘high.png’;
} else {
stateCp = ‘low.png’;
}
} else if (Cp_high.contains(mouseprac)) {
if (k < 0.5) {
stateAp = ‘high.png’;
} else {
stateAp = ‘low.png’;
}
if (v < 0.5) {
stateBp = ‘high.png’;
} else {
stateBp = ‘low.png’;
}
} else if (Cp_low.contains(mouseprac)) {
if (k < 0.5) {
stateAp = ‘high.png’;
} else {
stateAp = ‘low.png’;
}
if (v < 0.5) {
stateBp = ‘high.png’;
} else {
stateBp = ‘low.png’;
}
}psychoJS.experiment.addData(“stateAp”, stateAp);
psychoJS.experiment.addData(“stateBp”, stateBp);
psychoJS.experiment.addData(“stateCp”, stateCp);
So I know the error is occurring in the first set of if-then statements because in the console I get ‘error in setting practice variable’. Here’s a pic of the console and error:
The weird thing is that this only happens some of the time but other times it works. Also, it’s not based on any of the image objects because it occurs no matter the image object. I have similar code in my two later blocks but I am not sure if they have the problem too because I only get to the later blocks half the time. I am going to do some testing closing the first loop to see if its happening in the other blocks but I thought I would post here in the meantime to see if anyone could help. Thank you so much!