URL of experiment: Memory Experiment G [PsychoPy]
Description of the problem:
MemoryMFtest1(backup copy).psyexp (173.1 KB)
Hello there,
I have made a task in PsychoPy to run a memory test online on Pavlovia. My task contains a code component which tries to do a form of counterbalancing by assigning participants randomly to one of my 4 conditions to remove the effect of order. This task works pretty well offline (except of the auditory stimuli format which I should change to wav for offline and mp3 for online testing) but when I try to run it online it just does not show or do anything. just a blank page! However, I think the problem would be with that code component because when I sync it in builder I receive this error : 1973.9460 ERROR Line 383: Unexpected token in MemoryMFtest1(backup copy)-legacy-browsers.js
Any help would be appreciated because I am extremely in hurry to report some result to university.
Hello,
which PsychoPy-version are you using?
I couldn’t find a “counterbalancing” code-component in the example you provide. I get an error message that “Alert 4210:JavaScript Syntax Error in ‘Begin JS Experiment’ tab. See ‘Line 1: Unexpected token’ in the ‘Begin JS Experiment’ tab. For further info see 4210: Probable syntax error detected in your JavaScript code — PsychoPy v2021.1” when I try to run the experiment locally. However, there is no Begin JS Experiment tab.
Your online-version did start.
BTW, you could use lists in Experiment info to restrict the choices a participant can make. So, if a participant had to choose either from a, b, or c enter [‘a’, ‘b’, ‘c’] as a default in relevant experiment info field.
Best wishes Jens
I am using PsychoPy 3 version 2021.1.4. I fixed that error. Apparently python auto translation to JS was not working properly so I used an external website “Esprima.org” for syntax checking. Now I am facing another error but about the same code component. It says “TypeError: Cannot read property ‘0’ of undefined”
Here is the content of my code component. In the psyexp file I have send and attach it here again it is called randomizer. Apparently it is not being translated into JS properly.
rand = Math.random();
var nrepsa, nrepsb, nrepsc, nrepsd, randnum;
if (((rand >= 0) && (rand < 0.25))) {
nrepsa = 1;
nrepsb = 0;
nrepsc = 0;
nrepsd = 0;
} else {
if (((rand >= 0.25) && (rand < 0.5))) {
nrepsa = 0;
nrepsb = 1;
nrepsc = 0;
nrepsd = 0;
} else {
if (((rand >= 0.5) && (rand < 0.75))) {
nrepsa = 0;
nrepsb = 0;
nrepsc = 1;
nrepsd = 0;
} else {
nrepsa = 0;
nrepsb = 0;
nrepsc = 0;
nrepsd = 1;
}
}
}
I really appreciate your kind help.MemoryMFtest1(backup copy).psyexp (171.9 KB)
The link to my experiment is:
https://run.pavlovia.org/Hamed1994/memory-test/html/
BTW, why Experiment info looks so messy since I updated my PsychoPy?
Hello
you might want to take a look at the web app by wakecarter for counterbalancing and at his crib sheet for PsychoPy to PsychoJS auto-translation problems.
Notice that you should have JS-only or Both code-components instead of autotranslate code-components otherwise PsychoPy will always overwrite your manually entered JS-edits.
I have no idea why your exp.info box is so messed up. Probably, its size is fixed and your are exceeding its size. That’s why I would go for lists instead of “explaining” what to enter.
Best wishes Jens
1 Like