from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random import statistics import time class _seatnumber(Page): form_model = 'player' form_fields = ['seat_number'] def is_displayed(self): return self.player.round_number == 1 def before_next_page(self): self.participant.vars['seat_number'] = self.player.seat_number class _standby(Page): def is_displayed(self): return self.player.round_number == 1 def before_next_page(self): self.session.vars['start_time'] = int(time.time()) #print(self.session.vars['start_time']) #self.session.vars['end_time'] = int(time.time()) + 28 #print(self.session.vars['end_time']) #self.session.vars['spent_time'] = round((self.session.vars['end_time'] - self.session.vars['start_time'])/60, 2) #print(self.session.vars['spent_time']) self.session.label = str(self.session.config['session']) self.participant.label = str(self.player.seat_number) class a__InstructionsT1(Page): def is_displayed(self): return self.player.round_number == 1 and self.participant.vars['treatment'] == 1 #def get_timeout_seconds(self): # if self.participant.vars.get('is_dropout'): # return 1 # else: # return 10 def before_next_page(self): #player = self.player # timeout_happened = self.timeout_happened #if timeout_happened: # print('hello') # self.participant.vars['is_dropout'] = True #a=len(self.subsession.get_players()) * 3 #print(a) self.participant.vars['Q1_first_attempt'] = self.request.POST.get('Q1_first_attempt') self.participant.vars['Q2_first_attempt'] = self.request.POST.get('Q2_first_attempt') self.participant.vars['Q3_first_attempt'] = self.request.POST.get('Q3_first_attempt') self.participant.vars['Q4_first_attempt'] = self.request.POST.get('Q4_first_attempt') self.participant.vars['Q5_first_attempt'] = self.request.POST.get('Q5_first_attempt') self.participant.vars['Q6_first_attempt'] = self.request.POST.get('Q6_first_attempt') self.participant.vars['Q7_first_attempt'] = self.request.POST.get('Q7_first_attempt') #print(self.session.config.get('real_world_currency_per_point', None) * 3) #print(self.participant.vars['Q1_first_attempt']) #print(self.participant.vars['Q2_first_attempt']) #print(self.participant.vars['Q3_first_attempt']) #print(self.participant.vars['Q4_first_attempt']) #print(self.participant.vars['Q5_first_attempt']) #print(self.participant.vars['Q6_first_attempt']) #print(self.participant.vars['Q7_first_attempt']) #def vars_for_template(self): # self.participant.vars['treatment'] = self.session.config.get('treatment', None) #print(self.participant.vars['treatment']) self.session.vars['n_instr_finished'] = self.session.vars['n_instr_finished'] + 1 #print(self.session.vars['n_instr_finished']) class a__InstructionsT2(Page): def is_displayed(self): return self.player.round_number == 1 and self.participant.vars['treatment'] == 2 def before_next_page(self): self.participant.vars['Q1_first_attempt'] = self.request.POST.get('Q1_first_attempt') self.participant.vars['Q2_first_attempt'] = self.request.POST.get('Q2_first_attempt') self.participant.vars['Q3_first_attempt'] = self.request.POST.get('Q3_first_attempt') self.participant.vars['Q4_first_attempt'] = self.request.POST.get('Q4_first_attempt') self.participant.vars['Q5_first_attempt'] = self.request.POST.get('Q5_first_attempt') self.participant.vars['Q6_first_attempt'] = self.request.POST.get('Q6_first_attempt') self.participant.vars['Q7_first_attempt'] = self.request.POST.get('Q7_first_attempt') #print(self.participant.vars['Q1_first_attempt']) #print(self.participant.vars['Q2_first_attempt']) #print(self.participant.vars['Q3_first_attempt']) #print(self.participant.vars['Q4_first_attempt']) #print(self.participant.vars['Q5_first_attempt']) #print(self.participant.vars['Q6_first_attempt']) #print(self.participant.vars['Q7_first_attempt']) self.session.vars['n_instr_finished'] = self.session.vars['n_instr_finished'] + 1 #print(self.session.vars['n_instr_finished']) class a__InstructionsT3(Page): def is_displayed(self): return self.player.round_number == 1 and self.participant.vars['treatment'] == 3 def before_next_page(self): self.participant.vars['Q1_first_attempt'] = self.request.POST.get('Q1_first_attempt') self.participant.vars['Q2_first_attempt'] = self.request.POST.get('Q2_first_attempt') self.participant.vars['Q3_first_attempt'] = self.request.POST.get('Q3_first_attempt') self.participant.vars['Q4_first_attempt'] = self.request.POST.get('Q4_first_attempt') self.participant.vars['Q5_first_attempt'] = self.request.POST.get('Q5_first_attempt') self.participant.vars['Q6_first_attempt'] = self.request.POST.get('Q6_first_attempt') self.participant.vars['Q7_first_attempt'] = self.request.POST.get('Q7_first_attempt') #print(self.participant.vars['Q1_first_attempt']) #print(self.participant.vars['Q2_first_attempt']) #print(self.participant.vars['Q3_first_attempt']) #print(self.participant.vars['Q4_first_attempt']) #print(self.participant.vars['Q5_first_attempt']) #print(self.participant.vars['Q6_first_attempt']) #print(self.participant.vars['Q7_first_attempt']) self.session.vars['n_instr_finished'] = self.session.vars['n_instr_finished'] + 1 #print(self.session.vars['n_instr_finished']) class a__InstructionsT4(Page): def is_displayed(self): return self.player.round_number == 1 and self.participant.vars['treatment'] == 4 def before_next_page(self): self.participant.vars['Q1_first_attempt'] = self.request.POST.get('Q1_first_attempt') self.participant.vars['Q2_first_attempt'] = self.request.POST.get('Q2_first_attempt') self.participant.vars['Q3_first_attempt'] = self.request.POST.get('Q3_first_attempt') self.participant.vars['Q4_first_attempt'] = self.request.POST.get('Q4_first_attempt') self.participant.vars['Q5_first_attempt'] = self.request.POST.get('Q5_first_attempt') self.participant.vars['Q6_first_attempt'] = self.request.POST.get('Q6_first_attempt') self.participant.vars['Q7_first_attempt'] = self.request.POST.get('Q7_first_attempt') #print(self.participant.vars['Q1_first_attempt']) #print(self.participant.vars['Q2_first_attempt']) #print(self.participant.vars['Q3_first_attempt']) #print(self.participant.vars['Q4_first_attempt']) #print(self.participant.vars['Q5_first_attempt']) #print(self.participant.vars['Q6_first_attempt']) #print(self.participant.vars['Q7_first_attempt']) self.session.vars['n_instr_finished'] = self.session.vars['n_instr_finished'] + 1 #print(self.session.vars['n_instr_finished']) class a__InstructionsT5(Page): def is_displayed(self): return self.player.round_number == 1 and self.participant.vars['treatment'] == 5 def before_next_page(self): self.participant.vars['Q1_first_attempt'] = self.request.POST.get('Q1_first_attempt') self.participant.vars['Q2_first_attempt'] = self.request.POST.get('Q2_first_attempt') self.participant.vars['Q3_first_attempt'] = self.request.POST.get('Q3_first_attempt') self.participant.vars['Q4_first_attempt'] = self.request.POST.get('Q4_first_attempt') self.participant.vars['Q5_first_attempt'] = self.request.POST.get('Q5_first_attempt') self.participant.vars['Q6_first_attempt'] = self.request.POST.get('Q6_first_attempt') self.participant.vars['Q7_first_attempt'] = self.request.POST.get('Q7_first_attempt') #print(self.participant.vars['Q1_first_attempt']) #print(self.participant.vars['Q2_first_attempt']) #print(self.participant.vars['Q3_first_attempt']) #print(self.participant.vars['Q4_first_attempt']) #print(self.participant.vars['Q5_first_attempt']) #print(self.participant.vars['Q6_first_attempt']) #print(self.participant.vars['Q7_first_attempt']) self.session.vars['n_instr_finished'] = self.session.vars['n_instr_finished'] + 1 #print(self.session.vars['n_instr_finished']) class a_IntroWaitPage_cus(Page): template_name = 'a_instructions/a_IntroWaitPage_cus.html' #form_model = 'group' wait_for_all_groups = True live_method = 'live_wait' def is_displayed(self): return self.player.round_number == 1 page_sequence = [_seatnumber, _standby, a__InstructionsT1, a__InstructionsT2, a__InstructionsT3, a__InstructionsT4, a__InstructionsT5, a_IntroWaitPage_cus]