Re: [oTree] Setting session.vars outside of creating_session

205 views
Skip to first unread message

Chris Crabbe

unread,
May 3, 2022, 12:17:36 PM5/3/22
to Niklas Witzig, oTree help & discussion
Hi Niklas -

Yes, you can read from session.vars and write to session.vars from anywhere in your oTree app.  It is the primary way to communicate between different apps in a session (along with participant.vars if you want to store data particular to one subject instead of across the whole experiment).

Thanks,
--Chris

On Tue, May 3, 2022 at 5:18 AM 'Niklas Witzig' via oTree help & discussion <ot...@googlegroups.com> wrote:
Dear all,

I have one question:

- Is it possible to manipulation session.vars outside of the usual creating_session call?

My intended use case is to only allow players, who solved X tasks correctly in app 1 to be able to proceed to app2. While this specific problem probably could be solved with app after this page, dynamically setting session.vars could be handy in other instances, as well, so I'd like to give it a shot.

My original idea was to have a round 1 with my task, and in round 2 to call creating sessions (with an if subssion.session.round_number == 2) to set a session.var after participant.vars realized based on task performance in round 1 and then check the session vars in the beginning of the next app (to see who is a legal participant). However, it seems that creating_session tries to execute code within the if submission.session.round_number == 2: already in the beginning and gives an error as some of the participant.vars are not-yet-filled).

Any other ideas?

Thank you!
Best
Niklas

--
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/96f87e0d-6c32-4154-b220-6c9891ddab37n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages