Progress bar on waiting screen

230 views
Skip to first unread message

kmo

unread,
Mar 14, 2022, 10:14:06 AM3/14/22
to oTree help & discussion
Hi all,

I am trying to implement a progress bar on a wait page that updates automatically, giving the participant an idea how much longer it will take for the experiment to proceed. It seems to me that I need the live pages method to feed my python information on the number of waiting participants into the html template in continuous time, but in the docs (I am on Python 3.3.1) it says that the live_method is not yet supported on WaitPages.

Maybe I am missing on an easier way of achieving the above and would appreciate any suggestions.

Many thanks!

Chris Crabbe

unread,
Mar 14, 2022, 12:38:57 PM3/14/22
to kmo, oTree help & discussion
Hi kmo -

You could use a regular Page with a live_method to simulate a wait page.  Since you're sending updates with the number of players who have connected, you could also make it so that when your liveRcv function receives a message with all of the players arrived it updates the progress bar but also submits the Page's form, and then everybody would move on.

Thanks,
--Chris

--
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/712bffba-7a59-48d0-afed-8f55e9575eaan%40googlegroups.com.

kmo

unread,
Mar 15, 2022, 2:35:06 AM3/15/22
to oTree help & discussion
This is a very helpful suggestion, thank you! Is there an easy way to access the number of participants who are currently waiting? Thus far, I have generated my own variable indicating whether a participant has moved to the waiting page.

Thanks!

Chris @ oTree

unread,
Mar 15, 2022, 2:42:23 AM3/15/22
to oTree help & discussion
yes you should use live pages to make your own wait page with the exact design you want. check out wait_page_from_scratch in otree-more-demos. anyway yes you should define your own field to track who has arrived. oTree does not provide that automatically.
Message has been deleted

kmo

unread,
Mar 15, 2022, 11:17:26 AM3/15/22
to oTree help & discussion
Hi Chris, thanks again for your help. I have one follow up question: I managed to get it running within groups as exemplified by the otree-more-demos example. The thing is, I need this functionality on a wait-for-all-groups page but it seems that when I specify in my live method that data should be send to all players using "0", this only targets players within a group. So, what effectively happens is that the last player joining the wait page triggers all own-group members to move forward while the other groups are stuck. Is there a way to send data to all players beyond the group level? Or any other workaround? I appreciate your help!
kmo schrieb am Dienstag, 15. März 2022 um 08:59:26 UTC+1:
Perfect, it's all clear to me now. Thank you very much!

Chris Crabbe

unread,
Mar 15, 2022, 12:00:54 PM3/15/22
to kmo, oTree help & discussion
Hi kmo -

Since you're already implementing a live page, you should be able to have each client send a message to the server when they load the page (telling the server that they've connected) and from those you can keep count of how many people have connected (in a group field or in session.vars), and then reply to the whole group with the new count.

Thanks,
--Chris

kmo

unread,
Mar 16, 2022, 2:30:31 AM3/16/22
to oTree help & discussion
Hi - this is exactly what I have already implemented and that works fine. As you described, whenever a person loads the page a counter in session.vars keeps track of the number of people who arrived at the wait page. When that counter reaches the total number of participants in the experiment, some calculations happen and the form is submitted. The problem is that the last person joining the wait page triggers these functions for their own group only, but I need all groups to proceed together at the same time. It seems the return statement in the live method takes id_in_group as a statement and by specifying "0" I can only send data to own-group members but I want all participants beyond the group level receive these updates. Is there a way of achieving this? Maybe I am missing something obvious.

Thanks!

Chris @ oTree

unread,
Mar 16, 2022, 2:37:50 AM3/16/22
to kmo, oTree help & discussion
Yes live pages are just within the group. One possibility is to put everyone in the same group for that app (set PLAYER_PER_GROUP to None). 

Or instead of live pages you could use a custom wait page template that refreshes every 30 seconds using JavaScript window.location.reload(). On each page load, output how many ppl currently waiting. 

Sent from my phone

On Mar 16, 2022, at 2:30 PM, kmo <ult...@gmail.com> wrote:

Hi - this is exactly what I have already implemented and that works fine. As you described, whenever a person loads the page a counter in session.vars keeps track of the number of people who arrived at the wait page. When that counter reaches the total number of participants in the experiment, some calculations happen and the form is submitted. The problem is that the last person joining the wait page triggers these functions for their own group only, but I need all groups to proceed together at the same time. It seems the return statement in the live method takes id_in_group as a statement and by specifying "0" I can only send data to own-group members but I want all participants beyond the group level receive these updates. Is there a way of achieving this? Maybe I am missing something obvious.

kmo

unread,
Mar 16, 2022, 9:46:39 AM3/16/22
to oTree help & discussion
Thanks for the clarifications, it's working now!
Reply all
Reply to author
Forward
0 new messages