Force Minimum Waiting Time

248 views
Skip to first unread message

Zhang Sr

unread,
Sep 23, 2021, 12:22:43 PM9/23/21
to oTree help & discussion
Hi all,

I have a question regarding the minimum time for a page, I have wrote the same question when answering Chris's Email, but I think it would be good to write a separate email. 

I saw there are sample codes on Otree-snippets, However the page before that is waiting-page, so I have to wrote the code on the page itself I want to stay for 15s:

def error_message(player: Player, values):
import time
player.page_pass_time = time.time() + 15
if time.time()< player.page_pass_time:
    return " stay here"

However , whenever I click "next button" it shows the error message " stay here".

I want to know in case the previous page is waiting room , how can we set the minimum time?

Thank you!
Shaorong

Chris @ oTree

unread,
Sep 23, 2021, 12:46:09 PM9/23/21
to oTree help & discussion
if the previous page is a wait page, then you can set it for each player in after_all_players_arrive. 

Zhang Sr

unread,
Sep 23, 2021, 12:55:46 PM9/23/21
to oTree help & discussion
Thank you so much for the reply @Chris !

Sorry but to my understanding it can only set the group methods in after_all_players_arrive, how can I set it for individual player?

Sorry for so many questions. I have tried many ways but none worked.

Shaorong

Shutong HE

unread,
Sep 29, 2021, 5:51:16 AM9/29/21
to oTree help & discussion
Is that possible to use a "customised" waiting page instead of the standard oTree waiting page? In that case, you can create a page and let the NEXT button show up after 15 seconds. So participants will have to stay at the page for this long. 

Best,
Shutong

Zhang Sr

unread,
Sep 29, 2021, 6:26:30 AM9/29/21
to oTree help & discussion
Hi Shutong,

Thank you for your suggestion. Actually previously  the documentation introduced the way as you described, to hide the "next button" for 15s. My concerns is it might mislead the players think something went wrong and they make a 'reload'. 

Also Chris has published a sample code on this, but it requires a page in prior to the page that I want to keep the players for 15s. It cause some problem on my code, therefore I decided to make a soft reminder on the page.

Thank you again for this.
Shaorong

Shutong HE

unread,
Sep 29, 2021, 8:24:59 AM9/29/21
to oTree help & discussion
Hi Zhang,

I'm not sure whether this is feasible for your experiment. Maybe you can explicitly indicate on the waiting page that "Please wait for blah blah", just as a standard waiting page does. Below is the code that I used for hiding the button:

In HTML file:

<button class="btn btn-primary" style="display: none" id="next-button">Next</button>

<script>
setTimeout(function() {
document.getElementById('next-button').style.display = 'block';
}, 5 * 1000);
</script>


--> In my case, I hide the button for 5 seconds - 5*1000

Best,
Shutong

Zhang Sr

unread,
Sep 30, 2021, 12:08:22 AM9/30/21
to oTree help & discussion
Thank you Shutong, yes, I tried your code, it works! I will discuss with my colleague if we want to use this way.

Shaorong

Reply all
Reply to author
Forward
0 new messages