Timer in waitpage?

471 views
Skip to first unread message

joyce...@gmail.com

unread,
Feb 25, 2021, 5:05:36 PM2/25/21
to oTree help & discussion
Hi all,

Is it possible to display a timer on the waitpage? I tried using timer_seconds but that seems incompatible. Thanks so much!

Joyce

Chris @ oTree

unread,
Mar 1, 2021, 4:46:24 PM3/1/21
to oTree help & discussion
If you just want to display a timer (e.g. one that counts up or counts down but does not submit the page or take any action), you can customize the wait page template: https://otree.readthedocs.io/en/latest/misc/advanced.html#custom-wait-page-template and put some javascript/html code for a timer. you can find lots of examples online.

if you need players to move past the wait page after a certain amount of time, see here: https://otree.readthedocs.io/en/latest/multiplayer/waitpages.html#timeouts-on-wait-pages




Vic vP

unread,
Mar 13, 2021, 8:17:13 AM3/13/21
to oTree help & discussion
I am trying to use that technique (i.e.,  group_by_arrival_time_method) to move participants who time out to the last app in the app sequence.
Can this be done too using that method? Or can it only return a one-player group?
I think one-person groups are not really feasible for most multiplayer apps that require matching among participants.

Chris @ oTree

unread,
Mar 13, 2021, 8:24:28 AM3/13/21
to oTree help & discussion
Yes you can do that. On the same wait page, you use group_by_arrival_time to return the group, then app_after_this_page to forward the user to the last page if they are in a 1-player group:

def app_after_this_page(player, upcoming_apps):
  group = player.group
  if len(group.get_players()) == 1:
    return upcoming_apps[-1]

Vic vP

unread,
Mar 13, 2021, 9:44:05 AM3/13/21
to oTree help & discussion
Ah great! Yes, so I tried this, but I get this error:

NameError: name 'waiting_too_long' is not defined.

I put the def waiting_too_long(player) method under the Player class and the def group_by_arrival_time_method(subsession, waiting_players) method under the Subsession class.
Pycharm also says it does not now where "waiting_too_long" under the last method refers too.

Chris @ oTree

unread,
Mar 13, 2021, 9:49:46 AM3/13/21
to oTree help & discussion
it depends whether you're using the new no-self format. If so, it should be a function and you refer to it as waiting_too_long(player). If not, it should be a method on the Player class and you should refer to it as player.waiting_too_long().

Vic vP

unread,
Mar 13, 2021, 9:58:57 AM3/13/21
to oTree help & discussion
Ah yes, it works now. Had to double-check how it would run.

Ah of course. Yes. So, the tutorial code would work for the joined "__init__.py" file.
I will definitely switch to that. Thanks a lot btw for making all of it simpler. It looks great.

Gergely Horváth

unread,
May 25, 2022, 5:53:08 AM5/25/22
to oTree help & discussion
Dear All,

I have a question related to the timer on the waitpage. As mentioned above, the waitpage refreshes once or twice per minute, which also restarts my timer displayed on the waitpage. Is there a way to fix it so that the timer does not restart?
Thanks for your help in advance!

Best,
Gergely

Reply all
Reply to author
Forward
0 new messages