oTree Forum >

Extra url parameters

#1 by None

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 None

Thanks Chris, I did add those participant fields. Here is what I did:

In settings.py:

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: 


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 None

Thanks! When I use the corrected URL 


The code only works if I directly pass the parameters into the REST API. Excerpted from extra-url-params main.py:
        # vars=params,
    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.

Write a reply

Set forum username