from asyncio import all_tasks from asyncio.base_futures import _FINISHED from otree.api import * from json import dumps as json_dumps, loads as json_loads from datetime import datetime, timedelta, timezone doc = """ One player decides how to divide a certain amount between himself and the other player. See: Kahneman, Daniel, Jack L. Knetsch, and Richard H. Thaler. "Fairness and the assumptions of economics." Journal of business (1986): S285-S300. """ class Constants(BaseConstants): name_in_url = 'Rounds' # PLAYERS_PER_GROUP = 2 players_per_group = 2 num_rounds = 1 endowment = cu(100) # 總回合數22個 # amount_rounds = 22 amount_rounds = 22 # 遇到對方drop時的等待時間 drop_waiting_seconds = 1200 # drop_waiting_seconds = 180 drop_waiting_mins = drop_waiting_seconds/60 # 剩5分鐘時跳提醒 alert_last_seconds = 300 # endowment, prices endow_1 = 75 price_s_1 = 1 price_o_1 = 2 endow_2 = 40 price_s_2 = 1 price_o_2 = 3 endow_3 = 75 price_s_3 = 2 price_o_3 = 1 endow_4 = 60 price_s_4 = 1 price_o_4 = 2 endow_5 = 40 price_s_5 = 3 price_o_5 = 1 endow_6 = 60 price_s_6 = 1 price_o_6 = 1 endow_7 = 100 price_s_7 = 1 price_o_7 = 1 endow_8 = 60 price_s_8 = 2 price_o_8 = 1 endow_9 = 80 price_s_9 = 1 price_o_9 = 1 endow_10 = 40 price_s_10 = 4 price_o_10 = 1 endow_11 = 40 price_s_11 = 1 price_o_11 = 4 endow_12 = 300 price_s_12 = 1 price_o_12 = 2 endow_13 = 160 price_s_13 = 1 price_o_13 = 3 endow_14 = 300 price_s_14 = 2 price_o_14 = 1 endow_15 = 240 price_s_15 = 1 price_o_15 = 2 endow_16 = 160 price_s_16 = 3 price_o_16 = 1 endow_17 = 240 price_s_17 = 1 price_o_17 = 1 endow_18 = 400 price_s_18 = 1 price_o_18 = 1 endow_19 = 240 price_s_19 = 2 price_o_19 = 1 endow_20 = 320 price_s_20 = 1 price_o_20 = 1 endow_21 = 160 price_s_21 = 4 price_o_21 = 1 endow_22 = 160 price_s_22 = 1 price_o_22 = 4 # 回合數 choice_dict = {} # for i in range(22): for i in range(amount_rounds): temp = [] temp_2 = locals()["endow_"+str(i+1)] temp.append(locals()["endow_"+str(i+1)]) temp.append(locals()["price_s_"+str(i+1)]) temp.append(locals()["price_o_"+str(i+1)]) choice_dict[i+1] = temp menu_list = list(choice_dict.values()) def shuffle_menu(menu_list, choice_dict): import random menu_display = list(menu_list) random.shuffle(menu_display) choice_dict_num = [] for i in menu_display: choice_dict_num.append(list(choice_dict.keys())[list(choice_dict.values()).index(i)]) return choice_dict_num, menu_display # 準備放random好的30種menu choice_dict_num = [] menu_display = [] # 預設最多20組 for i in range(amount_rounds): choice_dict_num_temp, menu_display_temp = shuffle_menu(menu_list, choice_dict) choice_dict_num.append(choice_dict_num_temp) menu_display.append(menu_display_temp) print('group1:', choice_dict_num[0]) print('group2:', choice_dict_num[1]) print('group3:', choice_dict_num[2]) # print(menu_display) # choice_dict = Constants.choice_dict # print(menu_display) # 聊天室 PAPERCUPS_TEMPLATE = __name__ + '/papercups.html' width = '850px' height = 1.7 class Subsession(BaseSubsession): pass class Player(BasePlayer): # 跳轉 to_next_app = models.BooleanField(initial=False) # 點數紀錄 hold_1 = models.IntegerField(blank=True) pass_1 = models.IntegerField(blank=True) hold_2 = models.IntegerField(blank=True) pass_2 = models.IntegerField(blank=True) hold_3 = models.IntegerField(blank=True) pass_3 = models.IntegerField(blank=True) hold_4 = models.IntegerField(blank=True) pass_4 = models.IntegerField(blank=True) hold_5 = models.IntegerField(blank=True) pass_5 = models.IntegerField(blank=True) hold_6 = models.IntegerField(blank=True) pass_6 = models.IntegerField(blank=True) hold_7 = models.IntegerField(blank=True) pass_7 = models.IntegerField(blank=True) hold_8 = models.IntegerField(blank=True) pass_8 = models.IntegerField(blank=True) hold_9 = models.IntegerField(blank=True) pass_9 = models.IntegerField(blank=True) hold_10 = models.IntegerField(blank=True) pass_10 = models.IntegerField(blank=True) hold_11 = models.IntegerField(blank=True) pass_11 = models.IntegerField(blank=True) hold_12 = models.IntegerField(blank=True) pass_12 = models.IntegerField(blank=True) hold_13 = models.IntegerField(blank=True) pass_13 = models.IntegerField(blank=True) hold_14 = models.IntegerField(blank=True) pass_14 = models.IntegerField(blank=True) hold_15 = models.IntegerField(blank=True) pass_15 = models.IntegerField(blank=True) hold_16 = models.IntegerField(blank=True) pass_16 = models.IntegerField(blank=True) hold_17 = models.IntegerField(blank=True) pass_17 = models.IntegerField(blank=True) hold_18 = models.IntegerField(blank=True) pass_18 = models.IntegerField(blank=True) hold_19 = models.IntegerField(blank=True) pass_19 = models.IntegerField(blank=True) hold_20 = models.IntegerField(blank=True) pass_20 = models.IntegerField(blank=True) hold_21 = models.IntegerField(blank=True) pass_21 = models.IntegerField(blank=True) hold_22 = models.IntegerField(blank=True) pass_22 = models.IntegerField(blank=True) # 法幣紀錄 hold_coin_1 = models.IntegerField(blank=True) pass_coin_1 = models.IntegerField(blank=True) hold_coin_2 = models.IntegerField(blank=True) pass_coin_2 = models.IntegerField(blank=True) hold_coin_3 = models.IntegerField(blank=True) pass_coin_3 = models.IntegerField(blank=True) hold_coin_4 = models.IntegerField(blank=True) pass_coin_4 = models.IntegerField(blank=True) hold_coin_5 = models.IntegerField(blank=True) pass_coin_5 = models.IntegerField(blank=True) hold_coin_6 = models.IntegerField(blank=True) pass_coin_6 = models.IntegerField(blank=True) hold_coin_7 = models.IntegerField(blank=True) pass_coin_7 = models.IntegerField(blank=True) hold_coin_8 = models.IntegerField(blank=True) pass_coin_8 = models.IntegerField(blank=True) hold_coin_9 = models.IntegerField(blank=True) pass_coin_9 = models.IntegerField(blank=True) hold_coin_10 = models.IntegerField(blank=True) pass_coin_10 = models.IntegerField(blank=True) hold_coin_11 = models.IntegerField(blank=True) pass_coin_11 = models.IntegerField(blank=True) hold_coin_12 = models.IntegerField(blank=True) pass_coin_12 = models.IntegerField(blank=True) hold_coin_13 = models.IntegerField(blank=True) pass_coin_13 = models.IntegerField(blank=True) hold_coin_14 = models.IntegerField(blank=True) pass_coin_14 = models.IntegerField(blank=True) hold_coin_15 = models.IntegerField(blank=True) pass_coin_15 = models.IntegerField(blank=True) hold_coin_16 = models.IntegerField(blank=True) pass_coin_16 = models.IntegerField(blank=True) hold_coin_17 = models.IntegerField(blank=True) pass_coin_17 = models.IntegerField(blank=True) hold_coin_18 = models.IntegerField(blank=True) pass_coin_18 = models.IntegerField(blank=True) hold_coin_19 = models.IntegerField(blank=True) pass_coin_19 = models.IntegerField(blank=True) hold_coin_20 = models.IntegerField(blank=True) pass_coin_20 = models.IntegerField(blank=True) hold_coin_21 = models.IntegerField(blank=True) pass_coin_21 = models.IntegerField(blank=True) hold_coin_22 = models.IntegerField(blank=True) pass_coin_22 = models.IntegerField(blank=True) # 時間紀錄 time_1 = models.IntegerField(blank=True) time_2 = models.IntegerField(blank=True) time_3 = models.IntegerField(blank=True) time_4 = models.IntegerField(blank=True) time_5 = models.IntegerField(blank=True) time_6 = models.IntegerField(blank=True) time_7 = models.IntegerField(blank=True) time_8 = models.IntegerField(blank=True) time_9 = models.IntegerField(blank=True) time_10 = models.IntegerField(blank=True) time_11 = models.IntegerField(blank=True) time_12 = models.IntegerField(blank=True) time_13 = models.IntegerField(blank=True) time_14 = models.IntegerField(blank=True) time_15 = models.IntegerField(blank=True) time_16 = models.IntegerField(blank=True) time_17 = models.IntegerField(blank=True) time_18 = models.IntegerField(blank=True) time_19 = models.IntegerField(blank=True) time_20 = models.IntegerField(blank=True) time_21 = models.IntegerField(blank=True) time_22 = models.IntegerField(blank=True) time_23 = models.IntegerField(blank=True) # 實驗後問卷 gender = models.StringField( label = "1. 您的生理性別是:", choices=["男", "女"], widget=widgets.RadioSelect ) local = models.StringField( label = "2. 您是否為台灣本地生:", choices=["台灣本地生", "非台灣本地生(例如:僑生、外籍交換生學生)"], widget=widgets.RadioSelect ) econ_manage = models.StringField( label = "3. 您是否是經濟系、農經系、或管理學院的學生:", choices=["是", "否"], widget=widgets.RadioSelect ) class_num = models.StringField( label = "4. 您修過多少門經濟學的課程:", choices=["0門", "1門", "2門", "3門", "4門", "5門", "超過5門"], widget=widgets.RadioSelect ) grade = models.StringField( label = "5. 您的系級是:", choices=["大學部1年級", "大學部2年級", "大學部3年級", "大學部4年級", "大學部5年級以上", "碩士班學生", "博士班學生"], widget=widgets.RadioSelect ) principle = models.LongStringField( label = "6. 請問在實驗過程中,您是依據什麼原則分配自己和對方的報酬?" ) guess = models.LongStringField( label = "7. 請您猜測本實驗的目的為何:" ) class Group(BaseGroup): # dictator chosen_round_real = models.IntegerField() hold_real = models.IntegerField() pass_real = models.IntegerField() price_s_real = models.IntegerField() price_o_real = models.IntegerField() hold_money_real = models.IntegerField() pass_money_real = models.IntegerField() hold_NTD_real = models.IntegerField() pass_NTD_real = models.IntegerField() # recipient chosen_round_unreal = models.IntegerField() hold_unreal = models.IntegerField() pass_unreal = models.IntegerField() price_s_unreal = models.IntegerField() price_o_unreal = models.IntegerField() hold_money_unreal = models.IntegerField() pass_money_unreal = models.IntegerField() # 跳轉 participated = models.IntegerField() # json fields wait_for_ids = models.LongStringField(initial='[]') arrived_ids = models.LongStringField(initial='[]') # print(wait_for_ids, "測試") pass def unarrived_players(group: Group): return set(json_loads(group.wait_for_ids)) - set(json_loads(group.arrived_ids)) # FUNCTIONS def set_payoffs(group: Group): #  抽一回合當報酬&顯示(group.hold_real, group.hold_unreal) import random # 抽中的dictator回合數 # 測試 # group.chosen_round_real = random.choice(range(1, 23)) group.chosen_round_real = random.choice(range(1, (Constants.amount_rounds+1))) chosen_round_real = group.chosen_round_real # players = group.get_players() p1 = group.get_player_by_id(1) p2 = group.get_player_by_id(2) # print(p1.participant) # 抽中的recipient回合數 # group.chosen_round_unreal = random.choice(range(1, 23)) group.chosen_round_unreal = random.choice(range(1, (Constants.amount_rounds+1))) chosen_round_unreal = group.chosen_round_unreal # test = (getattr(p1, 'hold_%d' %chosen_point_index)) # 抽中的dictator pass/hold group.hold_real = getattr(p1, 'hold_%d' %chosen_round_real) group.pass_real = getattr(p1, 'pass_%d' %chosen_round_real) group.price_s_real = eval('Constants.price_s_'+str(chosen_round_real)) group.price_o_real = eval('Constants.price_o_'+str(chosen_round_real)) group.hold_money_real = group.hold_real*group.price_s_real group.pass_money_real = group.pass_real*group.price_o_real # 1法幣 = 2元新台幣 group.hold_NTD_real = group.hold_money_real*2 group.pass_NTD_real = group.pass_money_real*2 # 抽中的recipient pass/hold group.hold_unreal = getattr(p2, 'hold_%d' %chosen_round_unreal) group.pass_unreal = getattr(p2, 'pass_%d' %chosen_round_unreal) group.price_s_unreal = eval('Constants.price_s_'+str(chosen_round_unreal)) group.price_o_unreal = eval('Constants.price_o_'+str(chosen_round_unreal)) group.hold_money_unreal = group.hold_unreal*group.price_s_unreal group.pass_money_unreal = group.pass_unreal*group.price_o_unreal # participant # 抽中的dictator回合數 p1.participant.chosen_round_real = group.chosen_round_real p1.participant.chosen_round_unreal = group.chosen_round_unreal p2.participant.chosen_round_real = group.chosen_round_real p2.participant.chosen_round_unreal = group.chosen_round_unreal # 抽中的dictator pass/hold p1.participant.participated = 1 p1.participant.hold_real = getattr(p1, 'hold_%d' %chosen_round_real) p1.participant.pass_real = getattr(p1, 'pass_%d' %chosen_round_real) p1.participant.price_s_real = eval('Constants.price_s_'+str(chosen_round_real)) p1.participant.price_o_real = eval('Constants.price_o_'+str(chosen_round_real)) p1.participant.hold_money_real = group.hold_real*group.price_s_real p1.participant.pass_money_real = group.pass_real*group.price_o_real # 1法幣 = 2元新台幣 p1.participant.hold_NTD_real = group.hold_money_real*2 p1.participant.pass_NTD_real = group.pass_money_real*2 p1.participant.total_payoff = group.hold_money_real*2 + 50 p2.participant.total_payoff = group.pass_money_real*2 + 50 # 抽中的recipient pass/hold p1.participant.hold_unreal = getattr(p2, 'hold_%d' %chosen_round_unreal) p1.participant.pass_unreal = getattr(p2, 'pass_%d' %chosen_round_unreal) p1.participant.price_s_unreal = eval('Constants.price_s_'+str(chosen_round_unreal)) p1.participant.price_o_unreal = eval('Constants.price_o_'+str(chosen_round_unreal)) p1.participant.hold_money_unreal = group.hold_unreal*group.price_s_unreal p1.participant.pass_money_unreal = group.pass_unreal*group.price_o_unreal # print(p1.participant.pass_money_unreal) # 抽中的dictator pass/hold # p2.participant.participated = 2 p2.participant.hold_real = getattr(p1, 'hold_%d' %chosen_round_real) p2.participant.pass_real = getattr(p1, 'pass_%d' %chosen_round_real) p2.participant.price_s_real = eval('Constants.price_s_'+str(chosen_round_real)) p2.participant.price_o_real = eval('Constants.price_o_'+str(chosen_round_real)) p2.participant.hold_money_real = group.hold_real*group.price_s_real p2.participant.pass_money_real = group.pass_real*group.price_o_real # 1法幣 = 2元新台幣 p2.participant.hold_NTD_real = group.hold_money_real*2 p2.participant.pass_NTD_real = group.pass_money_real*2 # 抽中的recipient pass/hold p2.participant.hold_unreal = getattr(p2, 'hold_%d' %chosen_round_unreal) p2.participant.pass_unreal = getattr(p2, 'pass_%d' %chosen_round_unreal) p2.participant.price_s_unreal = eval('Constants.price_s_'+str(chosen_round_unreal)) p2.participant.price_o_unreal = eval('Constants.price_o_'+str(chosen_round_unreal)) p2.participant.hold_money_unreal = group.hold_unreal*group.price_s_unreal p2.participant.pass_money_unreal = group.pass_unreal*group.price_o_unreal # print(p2.participant.pass_money_unreal) #session # 抽中的dictator回合數 p1.session.chosen_round_real = group.chosen_round_real p1.session.chosen_round_unreal = group.chosen_round_unreal p2.session.chosen_round_real = group.chosen_round_real p2.session.chosen_round_unreal = group.chosen_round_unreal # participant # 抽中的dictator pass/hold p1.session.participated = 1 p1.session.hold_real = getattr(p1, 'hold_%d' %chosen_round_real) p1.session.pass_real = getattr(p1, 'pass_%d' %chosen_round_real) p1.session.price_s_real = eval('Constants.price_s_'+str(chosen_round_real)) p1.session.price_o_real = eval('Constants.price_o_'+str(chosen_round_real)) p1.session.hold_money_real = group.hold_real*group.price_s_real p1.session.pass_money_real = group.pass_real*group.price_o_real # 1法幣 = 2元新台幣 p1.session.hold_NTD_real = group.hold_money_real*2 p1.session.pass_NTD_real = group.pass_money_real*2 # 抽中的recipient pass/hold p1.session.hold_unreal = getattr(p2, 'hold_%d' %chosen_round_unreal) p1.session.pass_unreal = getattr(p2, 'pass_%d' %chosen_round_unreal) p1.session.price_s_unreal = eval('Constants.price_s_'+str(chosen_round_unreal)) p1.session.price_o_unreal = eval('Constants.price_o_'+str(chosen_round_unreal)) p1.session.hold_money_unreal = group.hold_unreal*group.price_s_unreal p1.session.pass_money_unreal = group.pass_unreal*group.price_o_unreal # print(p1.session.pass_money_unreal) # 抽中的dictator pass/hold # p2.session.participated = 2 p2.session.hold_real = getattr(p1, 'hold_%d' %chosen_round_real) p2.session.pass_real = getattr(p1, 'pass_%d' %chosen_round_real) p2.session.price_s_real = eval('Constants.price_s_'+str(chosen_round_real)) p2.session.price_o_real = eval('Constants.price_o_'+str(chosen_round_real)) p2.session.hold_money_real = group.hold_real*group.price_s_real p2.session.pass_money_real = group.pass_real*group.price_o_real # 1法幣 = 2元新台幣 p2.session.hold_NTD_real = group.hold_money_real*2 p2.session.pass_NTD_real = group.pass_money_real*2 # 抽中的recipient pass/hold p2.session.hold_unreal = getattr(p2, 'hold_%d' %chosen_round_unreal) p2.session.pass_unreal = getattr(p2, 'pass_%d' %chosen_round_unreal) p2.session.price_s_unreal = eval('Constants.price_s_'+str(chosen_round_unreal)) p2.session.price_o_unreal = eval('Constants.price_o_'+str(chosen_round_unreal)) p2.session.hold_money_unreal = group.hold_unreal*group.price_s_unreal p2.session.pass_money_unreal = group.pass_unreal*group.price_o_unreal # print(p2.session.pass_money_unreal) # PAGES class Welcome(Page): pass class Round_1(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 # timeout_seconds= Constants.drop_waiting_seconds # 設定時限 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] # print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_1 = choice_dict_num[0], # display in html (shuffle) dis_endow_1 = menu_display[0][0], dis_price_s_1 = menu_display[0][1], dis_price_o_1 = menu_display[0][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 # my_id_in_group = player.id_in_group @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_2(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] return dict( real_choice_num_2 = choice_dict_num[1], dis_endow_2 = menu_display[1][0], dis_price_s_2 = menu_display[1][1], dis_price_o_2 = menu_display[1][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 # my_id_in_group = player.id_in_group @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_3(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] return dict( real_choice_num_3 = choice_dict_num[2], dis_endow_3 = menu_display[2][0], dis_price_s_3 = menu_display[2][1], dis_price_o_3 = menu_display[2][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 # my_id_in_group = player.id_in_group @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_4(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_4 = choice_dict_num[3], dis_endow_4 = menu_display[3][0], dis_price_s_4 = menu_display[3][1], dis_price_o_4 = menu_display[3][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_5(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_5 = choice_dict_num[4], dis_endow_5 = menu_display[4][0], dis_price_s_5 = menu_display[4][1], dis_price_o_5 = menu_display[4][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_6(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_6 = choice_dict_num[5], dis_endow_6 = menu_display[5][0], dis_price_s_6 = menu_display[5][1], dis_price_o_6 = menu_display[5][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_7(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_7 = choice_dict_num[6], dis_endow_7 = menu_display[6][0], dis_price_s_7 = menu_display[6][1], dis_price_o_7 = menu_display[6][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_8(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_8 = choice_dict_num[7], dis_endow_8 = menu_display[7][0], dis_price_s_8 = menu_display[7][1], dis_price_o_8 = menu_display[7][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_9(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_9 = choice_dict_num[8], dis_endow_9 = menu_display[8][0], dis_price_s_9 = menu_display[8][1], dis_price_o_9 = menu_display[8][2], ) # 停留過久跳轉 # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_10(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_10 = choice_dict_num[9], dis_endow_10 = menu_display[9][0], dis_price_s_10 = menu_display[9][1], dis_price_o_10 = menu_display[9][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_11(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_11 = choice_dict_num[10], dis_endow_11 = menu_display[10][0], dis_price_s_11 = menu_display[10][1], dis_price_o_11 = menu_display[10][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_12(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_12 = choice_dict_num[11], dis_endow_12 = menu_display[11][0], dis_price_s_12 = menu_display[11][1], dis_price_o_12 = menu_display[11][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_13(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_13 = choice_dict_num[12], dis_endow_13 = menu_display[12][0], dis_price_s_13 = menu_display[12][1], dis_price_o_13 = menu_display[12][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_14(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_14 = choice_dict_num[13], dis_endow_14 = menu_display[13][0], dis_price_s_14 = menu_display[13][1], dis_price_o_14 = menu_display[13][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_15(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_15 = choice_dict_num[14], dis_endow_15 = menu_display[14][0], dis_price_s_15 = menu_display[14][1], dis_price_o_15 = menu_display[14][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_16(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_16 = choice_dict_num[15], dis_endow_16 = menu_display[15][0], dis_price_s_16 = menu_display[15][1], dis_price_o_16 = menu_display[15][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_17(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_17 = choice_dict_num[16], dis_endow_17 = menu_display[16][0], dis_price_s_17 = menu_display[16][1], dis_price_o_17 = menu_display[16][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_18(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_18 = choice_dict_num[17], dis_endow_18 = menu_display[17][0], dis_price_s_18 = menu_display[17][1], dis_price_o_18 = menu_display[17][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_19(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_19 = choice_dict_num[18], dis_endow_19 = menu_display[18][0], dis_price_s_19 = menu_display[18][1], dis_price_o_19 = menu_display[18][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_20(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_20 = choice_dict_num[19], dis_endow_20 = menu_display[19][0], dis_price_s_20 = menu_display[19][1], dis_price_o_20 = menu_display[19][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_21(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_21 = choice_dict_num[20], dis_endow_21 = menu_display[20][0], dis_price_s_21 = menu_display[20][1], dis_price_o_21 = menu_display[20][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class Round_22(Page): form_model = 'player' form_fields = ['hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22',\ 'hold_coin_1', 'pass_coin_1', 'hold_coin_2', 'pass_coin_2', 'hold_coin_3', 'pass_coin_3', 'hold_coin_4', 'pass_coin_4', 'hold_coin_5', 'pass_coin_5',\ 'hold_coin_6', 'pass_coin_6', 'hold_coin_7', 'pass_coin_7', 'hold_coin_8', 'pass_coin_8', 'hold_coin_9', 'pass_coin_9', 'hold_coin_10', 'pass_coin_10',\ 'hold_coin_11', 'pass_coin_11', 'hold_coin_12', 'pass_coin_12', 'hold_coin_13', 'pass_coin_13', 'hold_coin_14', 'pass_coin_14', 'hold_coin_15', 'pass_coin_15',\ 'hold_coin_16', 'pass_coin_16', 'hold_coin_17', 'pass_coin_17', 'hold_coin_18', 'pass_coin_18', 'hold_coin_19', 'pass_coin_19', 'hold_coin_20', 'pass_coin_20',\ 'hold_coin_21', 'pass_coin_21', 'hold_coin_22', 'pass_coin_22',\ 'time_1', 'time_2', 'time_3','time_4', 'time_5', 'time_6', 'time_7', 'time_8', 'time_9', 'time_10',\ 'time_11', 'time_12', 'time_13','time_14', 'time_15', 'time_16', 'time_17', 'time_18', 'time_19', 'time_20', \ 'time_21', 'time_22'] timer_text = "請您在時間內完成所有回合:" # 停留過久跳轉 @staticmethod def get_timeout_seconds(player): # 標準時間 today_UTC = datetime.utcnow().replace(tzinfo=timezone.utc) # 標準時間+8 today_TW = today_UTC.astimezone(timezone(timedelta(hours=8))) diff = (player.participant.round_drop_time - today_TW).total_seconds() # print(diff) return diff @staticmethod def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] print(choice_dict_num[0]) return dict( # 真實的回合數 real_choice_num_22 = choice_dict_num[21], dis_endow_22 = menu_display[21][0], dis_price_s_22 = menu_display[21][1], dis_price_o_22 = menu_display[21][2], ) # 停留過久跳轉 @staticmethod def before_next_page(player, timeout_happened): import time # 回合結束的時間戳 player.time_23 = int(time.time()) if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] class ChoiceMenu(Page): endow_1 = 75 form_model = 'player' form_fields = [ 'hold_1', 'pass_1', 'hold_2', 'pass_2', 'hold_3', 'pass_3', 'hold_4', 'pass_4', 'hold_5', 'pass_5',\ 'hold_6', 'pass_6', 'hold_7', 'pass_7', 'hold_8', 'pass_8', 'hold_9', 'pass_9', 'hold_10', 'pass_10',\ 'hold_11', 'pass_11', 'hold_12', 'pass_12', 'hold_13', 'pass_13', 'hold_14', 'pass_14', 'hold_15', 'pass_15',\ 'hold_16', 'pass_16', 'hold_17', 'pass_17', 'hold_18', 'pass_18', 'hold_19', 'pass_19', 'hold_20', 'pass_20',\ 'hold_21', 'pass_21', 'hold_22', 'pass_22' ] def vars_for_template(player): player_id = player.id_in_subsession # print(a == ) group_matrix = player.subsession.get_group_matrix() for i in group_matrix: if player_id in i: random_index = group_matrix.index(i) # group_matrix = subsession.get_group_matrix() # print(group_matrix) choice_dict_num = Constants.choice_dict_num[random_index] menu_display = Constants.menu_display[random_index] return dict( # 真實的回合數 real_choice_num_1 = choice_dict_num[0], # display in html (shuffle) dis_endow_1 = menu_display[0][0], dis_price_s_1 = menu_display[0][1], dis_price_o_1 = menu_display[0][2], real_choice_num_2 = choice_dict_num[1], dis_endow_2 = menu_display[1][0], dis_price_s_2 = menu_display[1][1], dis_price_o_2 = menu_display[1][2], real_choice_num_3 = choice_dict_num[2], dis_endow_3 = menu_display[2][0], dis_price_s_3 = menu_display[2][1], dis_price_o_3 = menu_display[2][2], real_choice_num_4 = choice_dict_num[3], dis_endow_4 = menu_display[3][0], dis_price_s_4 = menu_display[3][1], dis_price_o_4 = menu_display[3][2], real_choice_num_5 = choice_dict_num[4], dis_endow_5 = menu_display[4][0], dis_price_s_5 = menu_display[4][1], dis_price_o_5 = menu_display[4][2], real_choice_num_6 = choice_dict_num[5], dis_endow_6 = menu_display[5][0], dis_price_s_6 = menu_display[5][1], dis_price_o_6 = menu_display[5][2], real_choice_num_7 = choice_dict_num[6], dis_endow_7 = menu_display[6][0], dis_price_s_7 = menu_display[6][1], dis_price_o_7 = menu_display[6][2], real_choice_num_8 = choice_dict_num[7], dis_endow_8 = menu_display[7][0], dis_price_s_8 = menu_display[7][1], dis_price_o_8 = menu_display[7][2], real_choice_num_9 = choice_dict_num[8], dis_endow_9 = menu_display[8][0], dis_price_s_9 = menu_display[8][1], dis_price_o_9 = menu_display[8][2], real_choice_num_10 = choice_dict_num[9], dis_endow_10 = menu_display[9][0], dis_price_s_10 = menu_display[9][1], dis_price_o_10 = menu_display[9][2], real_choice_num_11 = choice_dict_num[10], dis_endow_11 = menu_display[10][0], dis_price_s_11 = menu_display[10][1], dis_price_o_11 = menu_display[10][2], real_choice_num_12 = choice_dict_num[11], dis_endow_12 = menu_display[11][0], dis_price_s_12 = menu_display[11][1], dis_price_o_12 = menu_display[11][2], real_choice_num_13 = choice_dict_num[12], dis_endow_13 = menu_display[12][0], dis_price_s_13 = menu_display[12][1], dis_price_o_13 = menu_display[12][2], real_choice_num_14 = choice_dict_num[13], dis_endow_14 = menu_display[13][0], dis_price_s_14 = menu_display[13][1], dis_price_o_14 = menu_display[13][2], real_choice_num_15 = choice_dict_num[14], dis_endow_15 = menu_display[14][0], dis_price_s_15 = menu_display[14][1], dis_price_o_15 = menu_display[14][2], real_choice_num_16 = choice_dict_num[15], dis_endow_16 = menu_display[15][0], dis_price_s_16 = menu_display[15][1], dis_price_o_16 = menu_display[15][2], real_choice_num_17 = choice_dict_num[16], dis_endow_17 = menu_display[16][0], dis_price_s_17 = menu_display[16][1], dis_price_o_17 = menu_display[16][2], real_choice_num_18 = choice_dict_num[17], dis_endow_18 = menu_display[17][0], dis_price_s_18 = menu_display[17][1], dis_price_o_18 = menu_display[17][2], real_choice_num_19 = choice_dict_num[18], dis_endow_19 = menu_display[18][0], dis_price_s_19 = menu_display[18][1], dis_price_o_19 = menu_display[18][2], real_choice_num_20 = choice_dict_num[19], dis_endow_20 = menu_display[19][0], dis_price_s_20 = menu_display[19][1], dis_price_o_20 = menu_display[19][2], real_choice_num_21 = choice_dict_num[20], dis_endow_21 = menu_display[20][0], dis_price_s_21 = menu_display[20][1], dis_price_o_21 = menu_display[20][2], real_choice_num_22 = choice_dict_num[21], dis_endow_22 = menu_display[21][0], dis_price_s_22 = menu_display[21][1], dis_price_o_22 = menu_display[21][2], ) class IntroductionPayoff(Page): timer_text = '請於時間內閱讀完實驗說明,並進入下一頁:' # 停留過久跳轉 timeout_seconds = 300 @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: # 記錄為參加失敗 player.participant.jump_to_next = False player.participant.participated = False player.participant.total_payoff = 0 @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.participated == False: return upcoming_apps[-1] pass # class Offer(Page): # form_model = 'group' # form_fields = ['kept'] # @staticmethod # def is_displayed(player: Player): # return player.id_in_group == 1 def wait_page_live_method(player: Player, data): group = player.group arrived_ids_set = set(json_loads(group.arrived_ids)) arrived_ids_set.add(player.id_in_subsession) group.arrived_ids = json_dumps(list(arrived_ids_set)) if not unarrived_players(group): return {0: dict(finished=True)} # ScratchWaitPage 跳轉 class ScratchWaitPage(Page): # after_all_players_arrive = set_payoffs title_text = "Custom title text" body_text = "Custom body text" timeout_seconds= Constants.drop_waiting_seconds @staticmethod def before_next_page(player, timeout_happened): if timeout_happened: player.participant.jump_to_next = True player.participant.participated = True my_id_in_group = player.id_in_group # 對方中途drop時,從過去紀錄給報酬 import random # p2 drop, p1的報酬算法 if my_id_in_group == 1: chosen_round_unreal = player.session.chosen_round_unreal chosen_round_real = random.choice(range(1, (Constants.amount_rounds+1))) player.participant.chosen_round_real = chosen_round_real player.participant.hold_real = getattr(player, 'hold_%d' %chosen_round_real) player.participant.pass_real = getattr(player, 'pass_%d' %chosen_round_real) player.participant.price_s_real = eval('Constants.price_s_'+str(chosen_round_real)) player.participant.price_o_real = eval('Constants.price_o_'+str(chosen_round_real)) player.participant.hold_money_real = player.participant.hold_real*player.participant.price_s_real player.participant.pass_money_real = player.participant.pass_real*player.participant.price_o_real player.participant.hold_NTD_real = player.participant.hold_money_real*2 player.participant.pass_NTD_real = player.participant.pass_money_real*2 player.participant.total_payoff = player.participant.hold_NTD_real + 50 player.participant.chosen_round_unreal = chosen_round_unreal player.participant.hold_unreal = player.session.hold_unreal player.participant.pass_unreal = player.session.pass_unreal player.participant.price_s_unreal = player.session.price_s_unreal player.participant.price_o_unreal = player.session.price_o_unreal player.participant.hold_money_unreal = player.session.hold_unreal*player.session.price_s_unreal player.participant.pass_money_unreal = player.session.pass_unreal*player.session.price_o_unreal # print(p2.session.pass_money_unreal) # p1 drop, p2的報酬算法 else: chosen_round_real = player.session.chosen_round_real chosen_round_unreal = random.choice(range(1, (Constants.amount_rounds+1))) # p2 被抽中的回合 player.participant.chosen_round_unreal = chosen_round_unreal # p2 持有/給對方的點數 player.participant.hold_unreal = getattr(player, 'hold_%d' %chosen_round_unreal) player.participant.pass_unreal = getattr(player, 'pass_%d' %chosen_round_unreal) # p2 持有/給對方的價格 player.participant.price_s_unreal = eval('Constants.price_s_'+str(chosen_round_unreal)) player.participant.price_o_unreal = eval('Constants.price_o_'+str(chosen_round_unreal)) # p2 持有/給對方的法幣 player.participant.hold_money_unreal = player.participant.hold_unreal*player.participant.price_s_unreal player.participant.pass_money_unreal = player.participant.pass_unreal*player.participant.price_s_unreal # 從過去撈一個 p1 和 p2 配對 # p1 被抽中的回合 player.participant.chosen_round_real = chosen_round_real # p1 持有/給對方的點數 player.participant.hold_real = player.session.hold_real player.participant.pass_real = player.session.pass_real # p1 持有/給對方的價格 player.participant.price_s_real = player.session.price_s_real player.participant.price_o_real = player.session.price_o_real # p1 持有/給對方的法幣 player.participant.hold_money_real = player.session.hold_real*player.session.price_s_real player.participant.pass_money_real = player.session.pass_real*player.session.price_o_real # p1 持有/給對方的NTD player.participant.hold_NTD_real = player.participant.hold_money_real*2 player.participant.pass_NTD_real = player.participant.pass_money_real*2 player.participant.total_payoff = player.participant.pass_NTD_real + 50 else: player.participant.jump_to_next = False @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.jump_to_next == True: return upcoming_apps[-3] @staticmethod def is_displayed(player: Player): group = player.group # first time if not json_loads(group.wait_for_ids): wait_for_ids = [p.id_in_subsession for p in group.get_players()] group.wait_for_ids = json_dumps(wait_for_ids) return unarrived_players(group) @staticmethod def live_method(player: Player, data): if data.get('type') == 'wait_page': return wait_page_live_method(player, data) @staticmethod def error_message(player: Player, values): group = player.group if unarrived_players(group): return "Wait page not finished" class ResultsWaitPage(WaitPage): # timeout = 5 after_all_players_arrive = set_payoffs title_text = "Custom title text" body_text = "Custom body text" class Results(Page): pass class Survey(Page): form_model = 'player' form_fields = ['gender', 'local', 'econ_manage', 'class_num', 'grade', 'principle', 'guess'] # this means player.name, player.age pass class Finished(Page): pass page_sequence = [ Round_1, Round_2, Round_3, Round_4, Round_5, Round_6, Round_7, Round_8, Round_9, Round_10, Round_11, Round_12, Round_13, Round_14, Round_15, Round_16, Round_17, Round_18, Round_19, Round_20, Round_21, Round_22, IntroductionPayoff, ScratchWaitPage, ResultsWaitPage,] # , Introduction, Instruction_rd, Instruction_ud, Ready_to_start, ChoiceMenu, ResultsWaitPage, IntroductionPayoff, Results, Survey, Finished] # Welcome, Instruction_dictator, Instruction_recipient, Ready_to_start, # [Welcome, Introduction, ChoiceMenu, IntroductionPayoff, ResultsWaitPage, Results]