Participant in all rounds

Skip to first unread message

FRANCESCA FEDERICO

unread,
Apr 8, 2021, 5:02:02 PM4/8/21
to oTree help & discussion
Hi everybody,

Is it possible that player.in_all_rounds() does not return the objects of the current participant if I shuffle players between groups each round? 

In my experiment I reshuffle players each round (subsession.group_randomly(fixed_id_in_group = False)).  At the end of the game, I have a table where I show all participant's previous round data using player.in_all_rounds() and group.in_all_rounds(), but these lists do not match with participant data (the only correct data are the ones of the last round). 
I've tried to use participant.vars,  but then I just see the sum of all variables stored, not the list of all items. I've also tried using participants.in_all_rounds but it doesn't work. 

Is there any way to show all participant past decisions in a list, as when I use "for p in player.in_all_rounds" or  "for g in group.in_all_rounds"?

Thank you!

Francesca

Chris @ oTree

unread,
Apr 8, 2021, 7:14:26 PM4/8/21
to FRANCESCA FEDERICO, oTree help & discussion
Can you show your code and some output like a screenshot or print statements that demonstrates this incorrect behavior?

Sent from my phone

On Apr 9, 2021, at 5:02 AM, 'FRANCESCA FEDERICO' via oTree help & discussion <ot...@googlegroups.com> wrote:

Hi everybody,
--
You received this message because you are subscribed to the Google Groups "oTree help & discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/c09e35df-49cc-48ac-bdc7-45fbb979e4e5n%40googlegroups.com.

FRANCESCA FEDERICO

unread,
Apr 9, 2021, 12:59:31 PM4/9/21
to oTree help & discussion
Hi Chris,
the code from the first screenshot works (it's a page template), but only variables referring to round 5 are "right" (=match with participant data): I think that for the other rounds data are taken from players in previous rounds that have the same player.id_in.group that the participant had in his last round (I reshuffle players each round, so player.id and group.id change each round).
I've tried using {% for p in  participant.in_all_rounds %} but it doesn't work. Is there a way to access participant data in all round and showing them as a list?
Thank you!
Francesca

Schermata 2021-04-09 alle 18.36.55.png
Schermata 2021-04-09 alle 09.19.36.png
Schermata 2021-04-09 alle 18.32.12.png

Chris @ oTree

unread,
Apr 9, 2021, 7:17:09 PM4/9/21
to oTree help & discussion
Hi, thanks for the info. Can you add a column to the table showing the participant code?

<td>{{ p.participant.code }}</td>

That way we can confirm whether it's the same participant. Otherwise i can't directly see from the screenshot that it's behaving incorrectly; I would need to see some kind of screenshot or print statement showing that oTree is contradicting itself, like showing that this table is inconsistent with what you see in the data export,etc.

If it is behaving inconsistently, can you send me your project and tell me where to find the code that does the group shuffling?

Chris @ oTree

unread,
Apr 9, 2021, 7:17:51 PM4/9/21
to oTree help & discussion
By the way there is no participant.in_all_rounds() because participants do not change from round to round.

FRANCESCA FEDERICO

unread,
Apr 10, 2021, 5:57:09 AM4/10/21
to oTree help & discussion
Sorry it was my mistake! Player.in_all_rounds works correctly, but only in some rounds (in this case round 1 and 4)  it seems that when I use group.in_all_rounds data are mixed up 
Schermata 2021-04-10 alle 11.12.18.png
Schermata 2021-04-10 alle 10.37.17.png
Schermata 2021-04-10 alle 10.36.51.png
Schermata 2021-04-10 alle 10.37.24.png
Schermata 2021-04-10 alle 10.41.39.png

Chris @ oTree

unread,
Apr 10, 2021, 6:07:35 AM4/10/21
to FRANCESCA FEDERICO, oTree help & discussion
See the note in the documentation about group.in_all_rounds etc. you should not use it if you are shuffling groups between rounds. 

Sent from my phone

On Apr 10, 2021, at 5:57 PM, 'FRANCESCA FEDERICO' via oTree help & discussion <ot...@googlegroups.com> wrote:

Sorry it was my mistake! Player.in_all_rounds works correctly, but only in some rounds (in this case round 1 and 4)  it seems that when I use group.in_all_rounds data are mixed up 
You received this message because you are subscribed to a topic in the Google Groups "oTree help & discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/otree/F9zeTI4P3go/unsubscribe.
To unsubscribe from this group and all its topics, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/6eb90e43-bb4c-43a0-b2df-c9e984f29239n%40googlegroups.com.
<Schermata 2021-04-10 alle 11.12.18.png>
<Schermata 2021-04-10 alle 10.37.17.png>
<Schermata 2021-04-10 alle 10.36.51.png>
<Schermata 2021-04-10 alle 10.37.24.png>
<Schermata 2021-04-10 alle 10.41.39.png>

FRANCESCA FEDERICO

unread,
Apr 10, 2021, 6:13:58 AM4/10/21
to oTree help & discussion

Ok. Thank you!

Chris @ oTree

unread,
Apr 10, 2021, 6:16:31 AM4/10/21
to FRANCESCA FEDERICO, oTree help & discussion
If you want the groups the current player was in previously, you can do:

for p in player.in_all_rounds(): p.group.total_contribution 



Sent from my phone

On Apr 10, 2021, at 6:14 PM, 'FRANCESCA FEDERICO' via oTree help & discussion <ot...@googlegroups.com> wrote:



FRANCESCA FEDERICO

unread,
Apr 10, 2021, 6:23:17 AM4/10/21
to oTree help & discussion
You're right! Thank you again!
Reply all
Reply to author
Forward
0 new messages