Reading in conditions file online using the participant to reference a row fails

My experiment works fine when run on my PC but when I run it online it fails with the following message

FATAL GUI.dialog core-3.2.js 705 | {“origin”:“TrialHandler.importConditions”,“context”:“when importing condition: Participants12Online.xlsx”,“error”:{}}
BrowserConsoleAppender.append @ log4javascript.min.js:1

I used builder to set up a loop to read the conditions file, using the participant to access a particular row. The details are below.
I read a posting which referenced Wakefield Morys-Carter’s excellent crib sheet which provides a solution but I think that only applies if you are writing the code as to opposed to using builder.
Any help would be greatly appreciated.

image

image

when I look at the python code generated it looks like what Wakefield mentioned in his crib sheet but I do not know how to add the javascript code when I am not writing python code directly.

Wakefield’s crib.

Python

myData = data.TrialHandler(nReps=1, method='sequential', extraInfo=expInfo, originPath=-1, trialList=data.importConditions('conditions.xlsx'), seed=None, name='myData')

Access individual values using: aValue = myData.trialList[Idx]['variableName']  

JavaScript

myData = new TrialHandler({
psychoJS: psychoJS,
nReps: 1, method: TrialHandler.Method.SEQUENTIAL,
extraInfo: expInfo, originPath: undefined,
trialList: 'conditions.xlsx',
seed: undefined, name: 'myData'});```

Try rows

$participant:(participant+1)

Thanks for the quick reply Wakefield. when I make the change I get the following error on the psyschopy runner window.

ERROR: Line 1579: Unexpected token : in ToyOnline.js

Line 1579 is:

trialList: TrialHandler.importConditions(psychoJS.serverManager, 'Participants12Online.xlsx', participant: (participant + 1)),

I assume you meant $participant:(participant+1) which is what I used. You missed the 2nd sign.

oops…

$participant:($participant+1)

$participant is and has to be a string so that is why there is an error.
I will try entering 2 for the selected row temporarily to see if it resolves unexpected token error

i decided to work around the problem by creating lists of participant conditions for each participant internally rather than read it in from an excel file. I have eventually 160 participants so BIG lists. Also I have to change the program each time I make a change. Not ideal but I had to move on. I could come back to it later if a solution is found.

Once I spent a little time thinking about it the solution was very easy. :slightly_smiling_face:

I read in the whole file in a loop and have some code in the loop which sees if the participant ID in the file is the same as the one entered in the experiment. If it is then save the conditions.