from otree.api import * doc = """ Your app description """ # Note: As an app, using "app_after_this_page" gives an error if the entered value is more than 5 dollars # This app runs properly when combined with another app class Constants(BaseConstants): name_in_url = 'new_snakeActivityMulitplayer' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): pass # PAGES class snakeInstructions(Page): @staticmethod def live_method(player: Player, data): return super().live_method(player, data) # When this page "ends", a session timer will start @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant import time participant.expiry = time.time() + 1*60 # 1*60sec class snakeActivity(Page): # literrly change the timer text timer_text = 'Time left to until this section is over:' # everytime another round is generated, carry over the remaining time from the previous page def get_timeout_seconds(player): participant = player.participant import time return participant.expiry - time.time() # remember to add 'expiry' to PARTICIPANT_FIELDS in settings.py # when the time is less that two seconds, quit the current round and skip to the "Results" page @staticmethod def is_displayed(player): participant = player.participant import time time_remaining = participant.expiry - time.time() return time_remaining > 2 page_sequence = [snakeInstructions, snakeActivity]