oTree Forum >

Can we set default value for participants/session fields?

#1 by szhangjake

Hi all,

  I plan to have an app_sequence like [APP1, APP2, APP1,...], and I want a different display when a participant comes to APP1 the second time. Hence, I need to detect how many times APP1 has been presented to him.
  
  I am thinking of using some participant fields, which could be passed between APPs. For example, we can set PARTICIPANT_FIELDS = ['times_arrival'] and update it every time. 
  And one issue is that this variable may be null the first time we come to update it. I understand that we might use 'is NUll' for such a check, but am still curious to know whether we can assign an initial/default value for participant fields.
  
  Thanks for your time in advance.
  
  Best,
  Jake

#2 by Chris_oTree

Apps cannot be repeated in the app_sequence.

Anyway, you can set the field's initial value in creating_session.

#3 by szhangjake

Got it. I was previously thinking that the initialization would also be contingent on the times of arrival. But now this is no longer a concern as we could create a third APP to avoid repetition.

Thanks for the response, Chris.

#4 by BonnEconLab

Chris_oTree wrote, “Apps cannot be repeated in the app_sequence.”

They can, with a bit of trickery: https://groups.google.com/g/otree/c/2Z3d_SStb5o/m/kEjHjBL_BAAJ.

Write a reply

Set forum username