#1 by djb187,
Hello, After implementing https://github.com/oTree-org/extra-url-params using the directions provided in the README, the code is not working as expected. I don't get an error, but the parameters embedded in the URL do not appear as participant variables in my data export. Has someone been able to get this to work recently? Perhaps the server side has broken? I include my (slightly modified) version of the code attached. Thanks!
#2 by Chris_oTree,
Did you add those fields to PARTICIPANT_FIELDS? That is required for them to show up in the data export.
#3 by djb187,
Thanks Chris, I did add those participant fields. Here is what I did: In settings.py: PARTICIPANT_FIELDS = [ 'workerId', 'hitId', 'assignmentId', ] But they only appear in the data export if I initialize them in init.py, for example: def creating_session(subsession): participant = player.participant participant.workerId = _____ This value that I give it is just a temporary placeholder that is meant to be overwritten by 'aaa' when I open the heroku server and then type into my browser's url: https://[server-name].herokuapp.com/room/test?participant_label=djb187&workerId=aaa But, while the link opens to the experiment and the participant label is successfully populated with 'djb187', workerId is still blank (or left at the initial value that I gave it when creating the session) in the Data export under participant_vars, which is a LongStringField which stores all values of my participant variables. Does this make sense? Any thoughts on what might be the issue? Thanks in advance.
#4 by Chris_oTree,
That URL you posted just looks like the regular oTree room URL, not the extra-url-params URL.
#5 by djb187,
Thanks! When I use the corrected URL https://[server-name]/?participant_label=djb187&workerId=test1 The code only works if I directly pass the parameters into the REST API. Excerpted from extra-url-params main.py: call_api( POST, 'participant_vars', room_name=ROOM_NAME, participant_label=participant_label, # vars=params, vars=dict(workerId='test1',hitId='test2',assignmentId='test3'), ) Basically, params = dict(request.query_params) seems to not be working? I have included the main.py file I am using (basically the same as the original, with some print statements).
#6 by Chris_oTree,
what is the output of printing dict(request.query_params)? if it's not working, it must differ somehow from the hardcoded values you set.