import random from otree.api import * doc = """ Introduction """ class C(BaseConstants): NAME_IN_URL = 'intro' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 MIN_TIME = 15 # in minutes MAX_TIME = 20 # in minutes BONUS_PER_CORRECT_TASK_PART1 = cu(0.15) OUTSIDE_OPTION = cu(1.5) NUMBER_OF_TASKS_PART1 = 2 NUMBER_OF_TASKS_PART2 = 10 PART1_INTRO_TEMPLATE = 'intro/part1.html' PART2_INTRO_TEMPLATE = 'intro/part2.html' BONUS_INTRO_TEMPLATE = 'intro/bonus.html' COMPUTER_INTRO_TYPES = 'intro/computerTypes.html' REVIEW_INSTRUCTIONS = 'intro/reviewInstructions.html' NUMBER_OF_STAGES = 3 # modify jointly with word below NUMBER_OF_STAGES_WORD = 'three' # modify jointly with number above INSTRUCTIONS1_TEMPLATE = 'informational_cost/instructions1_template.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): arepid = models.StringField(label='Please enter you AREP id code below. You can find it in the login email you received or under "my profile".') # treatment = models.StringField() # cq1 = models.IntegerField(blank=True, # choices=[ # [1, 'It does not do anything.'], # [2, 'It solves different tasks.'], # [3, 'It decides what task it solves.'] # ], # widget=widgets.RadioSelect, # label='What does the computer do?' # ) # cq2 = models.IntegerField(blank=True, # choices=[ # [1, 'Only one, which can be of Good or the Bad quality.'], # [2, 'Two, one of Good quality and one of Bad quality.'], # [3, 'There are no computers.'] # ], # widget=widgets.RadioSelect, # label='How many computers are there in each decision in this stage?' # ) # cq3 = models.IntegerField(blank=True, # choices=[ # [1, 'Yes, there is only one computer which solves tasks in both part 1 ' # 'and part 2, but the computer can be of a different quality in part 1 and part 2.'], # [2, 'No, there are two computers, one for each part.'], # [3, 'Yes, there is only one computer for each decision which solves tasks in both ' # 'part 1 and part 2, and the computer is of the same quality in both parts. ' # 'However, the computer can be of different quality in different decisions.'] # ], # widget=widgets.RadioSelect, # label='Is the computer that solves the task in part 1 the same as the one that solves the' # ' task in part 2 for each decision in this stage?' # ) # cq4 = models.IntegerField(blank=True, # choices=[ # [1, 'Only one.'], # [2, 'Five decisions.'], # [3, 'I do not have to make any decisions.'] # ], # widget=widgets.RadioSelect, # label='How many decisions will you face in this stage?' # ) # cq5 = models.IntegerField(blank=True, # choices=[ # [1, 'No, you will never learn exactly how many mistakes it made.'], # [2, 'Yes, you will learn about it but only once the experiment ends and you get your' # ' bonus payment.'], # [3, 'Yes, you will learn about it before part 2.'], # ], # widget=widgets.RadioSelect, # label='Will you learn the number of mistakes that the computer makes in part 1, if any?' # ) # cq1_det = models.IntegerField(blank=True, # choices=[ # [1, 'They do not do anything.'], # [2, 'They solve different tasks.'], # [3, 'They decide what task they solve.'] # ], # widget=widgets.RadioSelect, # label='What do the computers do?' # ) # cq2_det = models.IntegerField(blank=True, # choices=[ # [1, 'Only one, which can be of Good or the Bad quality.'], # [2, 'Two, one of Good quality and one of Bad quality.'], # [3, 'There are many computers.'] # ], # widget=widgets.RadioSelect, # label='How many computers are there in each decision in this stage?' # ) # cq3_det = models.IntegerField(blank=True, # choices=[ # [1, 'Yes, there are two computers in part 1 ' # 'and part 2, but the computers can change quality between part 1 and part 2.'], # [2, 'No, there are two computers, one for each part.'], # [3, 'Yes, there are two computers in part 1 ' # 'and part 2, and the computers do not change their quality between parts.'] # ], # widget=widgets.RadioSelect, # label='Are the computers that solve tasks in part 1 the same as the ones' # ' in part 2 for each decision in this stage?' # ) # cq4_det = models.IntegerField(blank=True, # choices=[ # [1, 'Only one.'], # [2, 'Five decisions.'], # [3, 'I do not have to make any decisions.'] # ], # widget=widgets.RadioSelect, # label='How many decisions will you face in this stage?' # ) # for j in range(1, 6): # locals()['cq' + str(j) + '_mistakes'] = models.IntegerField(blank=True, initial=0) # del j # for j in range(1, 6): # locals()['cq' + str(j) + '_det_mistakes'] = models.IntegerField(blank=True, initial=0) # del j # intro_cq_mistakes = models.IntegerField(blank=True) # PAGES class Welcome(Page): pass class Consent(Page): pass class Instructions(Page): form_model = 'player' form_fields = ['arepid'] @staticmethod def app_after_this_page(player, upcoming_apps): if player.participant.treatment == 'strategy': return upcoming_apps[1] # class IntroduceStages(Page): # pass # class Instructions1(Page): # pass # class CQ(Page): # form_model = 'player' # # @staticmethod # def get_form_fields(player): # questions = ['cq1', 'cq2', 'cq3', 'cq4'] # if player.participant.det: # questions = [x + '_det' for x in questions] # return questions # # @staticmethod # def error_message(player, values): # if not player.session.config['development']: # if not player.participant.det: # solutions = dict(cq1=2, # cq2=1, # cq3=3, # cq4=2, # # cq5=3 # ) # else: # solutions = dict(cq1_det=2, # cq2_det=2, # cq3_det=3, # cq4_det=2 # ) # error_messages = dict() # for field_name in solutions: # if values[field_name] is None: # error_messages[field_name] = 'Please, answer the question.' # elif values[field_name] != solutions[field_name]: # error_messages[field_name] = 'Please, correct your answer!' # name = 'player.' + str(field_name) + '_mistakes' # exec("%s += 1" % name) # return error_messages # # @staticmethod # def before_next_page(player: Player, timeout_happened): # player.intro_cq_mistakes = player.cq1_mistakes + player.cq2_mistakes + player.cq3_mistakes + player.cq4_mistakes + \ # player.cq5_mistakes + player.cq1_det_mistakes + player.cq2_det_mistakes + player.cq3_det_mistakes + \ # player.cq4_det_mistakes # # class Instructions2(Page): # pass page_sequence = [ Welcome, Consent, Instructions # IntroduceStages, # 3 PARTS, MAYBE ONLY PAY ONE. # Instructions1, # INSTRUCTIONS 1, ADAPT TO NEW FRAMEWORK # CQ, # Instructions2 ]