Problem reading in files for online experiments

URL of experiment:

Description of the problem: Using Builder with extensive use of code snippets, I am trying to read in files during the experiment for sound files and also the loop conditions file. I generate the order to be read in at the start of the experiment (begin routine tab, first trial)

myChoice = Math.floor(Math.random() * 64) + 1; 
if (myChoice < 10) {  
    myOrderString = "0".concat(myChoice.toString()) 
   myOrderString = myChoice.toString() }
block1Order = ("order_bl1_" + myOrderString + ".csv")
block2Order = ("order_bl2_" + myOrderString +".csv")


Even though this looked fine in the console (the resulting string looked as planned),
this gave rise to “unknown reference errors”, like the following:

Unfortunately we encountered the following error:
when importing condition: orders/order_bl1_14.csv
when getting the value of resource: orders/order_bl1_14.csv
unknown resource

Try to run the experiment again. If the error persists, contact the experiment designer.

I checked on github that the file is there in the subfolder “orders”.
Strangely enough, if I copy the “orders/order_bl1_14.csv” from the error message,
put that into the conditions tab for the loop everything works.

( I also tried losing the subfolder, by putting all my csv files (many…) in the same folder as the index.html, with no success.)

I had the same problem with reading in sound files, which were given as somthing.mp3 in the csv input,
and then supplied with the path in a code snippet:

soundFileL = "sounds/".concat(soundFile);

This again give rise to an “unknown resource error”. I could solve that problem by adding the “sounds/” part to the soundfile specification in the csv file, but I really would like to understand why the file is found when specified as “sounds/something.mp3” in the conditions csv file, but not found if specificed as “something.mp3” in the conditions file, with the path added during execution (and yes, I did change the variable in the sound itself to soundFileL).

Can anybody explain what’s going on? Is there some string interpretation going on when putting these variables into the tabs of the experiment objects?

Kind regards,

Hello Holger,

did you check whether your filenames match? Offline, psychopy makes a guess if it can’t find a file, so
test.png might be used even if there is only a test.bmp. Also, offline Test.png will work even if you ask for test.png. This does not work online. So, perhaps it is only a spelling error?

Best Jens

I think I ruled that out by taking the output from the console (put there by the console.log command) and coping its contents into the field for conditions of the loop. Then it works. But when it is a variable, it is not found.

Hello Holger,

ok, your project is not yet accessible. So, you might want wot set it to public so that somebody else could check it out.

Best Jens
Still on Malta?

Hello Jens (and others),

I now went back to an earlier project where I did something similar.
That was run under Version v1.3. So I downgraded my local psychopy version,
recreated the experiment and tried the same code. Now it works. I made both projects public.

So we have
“computerstimmen01” running on platform 2020.2: not working
“computerstimmen1” running on platform 2020.1: working

Obviously for the 2020.1 version, I had to copy all files into the local resources folder (under the
psychopy created html/ folder) and update to upload them, but at least the final product works.

Greetings from Malta,