Timeout set by participants

77 views
Skip to first unread message

D Dark

unread,
Oct 27, 2021, 9:40:07 AM10/27/21
to oTree help & discussion
Hi everyone! I was wondering whether it is possible to let participants decide the timeout seconds for their rounds. For example, a participant can choose from 0 seconds to 180 seconds for a round, instead of me setting a fixed length for a round for the participant.

I tried the following methods But they did not work.
 1. class Player(BasePlayer):
               timeout = models.IntegerField()
                
                
     class Task(Page):
               timeout_seconds = float(Player.timeout)

 Error message says float() function cannot be used with otree atribution (or similar meaning).

2. class Player(BasePlayer):
                time = models.IntegerField()
                 timeout = float(time)


    class Task(Page):
                @staticmethod
                 def get_timeout_seconds:
                        timeout_seconds = Player.timeout
                         return timeout_seconds

this does not work neither.


Thank you very much for your help in advance!!!

  

D Dark

unread,
Nov 2, 2021, 10:23:42 AM11/2/21
to oTree help & discussion
Problem Solved.
I used the following code.

class Player(BasePlayer):
           my_page_timeout_seconds = models.IntegerField()


class Timer(Page):
          form_model = "player"
          form_fields = ["my_page_timeout_seconds"]


class Task(Page):
           @staticmethod
           def get_timeout_seconds(player):
           return player.my_page_timeout_seconds


Reply all
Reply to author
Forward
0 new messages