Create and Sort "Subject" number as in zTree

127 views
Skip to first unread message

X. Zhou

unread,
May 30, 2022, 9:50:29 AM5/30/22
to oTree help & discussion
Dear all,

I am finding a way to create a subject_number variable similar to the Subjects variable in zTree.

The main reason is to match computer station number with oTree participant number and also create variables based on their subject number flexibly.

Please note that the snippet :

def creating_session(self):
    labels = [1, 2, 3 , ...]
    for player, label in zip(self.get_players(), labels):
        player.participant.label = label

does not work because if work station 2 is empty, then label 2 wil be assigned to station 3.

It would also be nice to access the "subject number" variable, curretly, in the data, there is only P1, P2, etc. I am wondering how to create the subject variable based on that.

Thanks!

Best,
Zhou

BonnEconLab

unread,
May 30, 2022, 10:06:39 AM5/30/22
to oTree help & discussion
Just add ?participant_label=PC_number (e.g., ?participant_label=01, ?participant_label=02, etc.) to the URLs when opening the oTree URL in the browser on the participants’ PCs.

X. Zhou

unread,
May 31, 2022, 10:23:44 AM5/31/22
to oTree help & discussion
Thank you very much! I will try!

basti...@gmail.com

unread,
Jun 2, 2022, 2:15:23 PM6/2/22
to oTree help & discussion
This is helpful.. Thanks.
Reply all
Reply to author
Forward
0 new messages