from otree.api import * doc = """ Group decision-making game: Leader's part """ ## CONSTANTS class C(BaseConstants): NAME_IN_URL = 'leader' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 GROUP_REWARD = cu(8) # reward per correct answer GROUP_OUTSIDE = cu(7) # reward per rejected answer PATCPN_FEE = cu(8) PAYOFF_MAX = GROUP_REWARD*3 class Subsession(BaseSubsession): pass ## MODELS - DATA TO BE COLLECTED class Group(BaseGroup): pass class Player(BasePlayer): prolific_id = models.StringField(default = str(" ")) consent = models.BooleanField(blank = True) factual = models.BooleanField(blank = True) engname = models.StringField( label = "Your legal English first name:" ) vnmname = models.StringField( label = "Your legal Vietnamese first name (in Vietnamese characters, TELEX keyboard input):" ) age = models.IntegerField( label = 'What is your age?', min=18, max=50 # need to incorporate this in completion path Prolific ) atten1 = models.IntegerField(blank = True) atten2 = models.IntegerField(blank = True) ques1 = models.StringField( choices = [ ['1', '1'], ['2', '2'], ['3', '3'], ['4', '4'], ['5', '5'], ['6', '6'], ['7', '7'], ['8', '8'] ], widget = widgets.RadioSelectHorizontal, label = ''' Your answer: ''' ) ques7 = models.StringField( choices = [ ['1', '1'], ['2', '2'], ['3', '3'], ['4', '4'], ['5', '5'], ['6', '6'], ['7', '7'], ['8', '8'] ], widget = widgets.RadioSelectHorizontal, label = ''' Your answer: ''' ) ques8 = models.StringField( choices = [ ['1', '1'], ['2', '2'], ['3', '3'], ['4', '4'], ['5', '5'], ['6', '6'], ['7', '7'], ['8', '8'] ], widget = widgets.RadioSelectHorizontal, label = ''' Your answer: ''' ) ques9 = models.StringField( choices = [ ['1', '1'], ['2', '2'], ['3', '3'], ['4', '4'], ['5', '5'], ['6', '6'], ['7', '7'], ['8', '8'] ], widget = widgets.RadioSelectHorizontal, label = ''' Your answer: ''' ) atten3 = models.BooleanField( label = 'Were you paying sufficient attention throughout the study, and do you believe your data should remain in the dataset?' ) ### Don't need these because they are provided by Prolific as long as you included them in list of built-in prescreeners """ prolificid = models.StringField( label = 'Enter your Prolific ID' ) age = models.IntegerField( label = 'What is your age?', min=18, max=50 # need to incorporate this in completion path Prolific ) sex = models.StringField( choices = [['Male', 'Male'], ['Female', 'Female']], label = 'What is your sex, as recorded on official documents?', widget = widgets.RadioSelect, ) atten1 = models.IntegerField( label = 'How many questions will be picked to decide whether you can win a bonus payment?', choices = [[1, '1'], [2, '2'], [3, '3'], [4, '4']], widget = widgets.RadioSelect ) atten2 = models.IntegerField( label = 'Your role in this experiment is to ___', choices = [[1, 'pick a member'], [2, 'vote on answer'], [3, 'propose answer'], [4, 'collect bonus payment']], widget = widgets.RadioSelect ) """ ## FUNCTIONS (no functions here cos no payoffs calculated yet, purely a survey collecting responses) ## PAGES ### Welcome page for Leader class Welcome(Page): form_model = 'player' form_fields = ['consent', 'factual'] preserve_unsubmitted_inputs = True """ # In template, include {{ formfield "prolificid" }} # Prolific ID validation def prolificid_error_message(player, value): if len(value) != 24: return "Your Prolific ID must have 24 alphanumeric characters." ### Attention check 1 class Attention1(Page): form_model = 'player' form_fields = ['atten1'] @staticmethod def atten1_vars(player, values): if player.atten1 > 1: return dict( completionlink= player.subsession.session.config['completionlink'] ) ### Attention check 2 class Attention2(Page): form_model = 'player' form_fields = ['atten2'] @staticmethod def atten2_vars(player, values): if player.atten2 != 3: return dict( completionlink= player.subsession.session.config['completionlink'] ) """ ### Demographics page for Leader class Demographics(Page): form_model = 'player' form_fields = ['engname', 'vnmname', 'age'] @staticmethod def before_next_page(self, timeout_happened): self.prolific_id = self.participant.label pass ### Instructions page for Leader class Instruction(Page): pass ### Attention check 1 class Attention1(Page): form_model = 'player' form_fields = ['atten1'] ### Attention check 2 class Attention2(Page): form_model = 'player' form_fields = ['atten2'] ### Introduction page for Leader class Intro(Page): pass ### Question 1 for Leader class Leader1(Page): form_model = 'player' form_fields = ['ques1'] ### Question 2 for Leader class Leader7(Page): form_model = 'player' form_fields = ['ques7'] ### Question 3 for Leader class Leader8(Page): form_model = 'player' form_fields = ['ques8'] ### Question 4 for Leader class Leader9(Page): form_model = 'player' form_fields = ['ques9'] ### Attention check class Attention3(Page): form_model = 'player' form_fields = ['atten3'] ### End page - Redirects to Prolific class End(Page): pass ### Redirect page class Redirect(Page): @staticmethod def js_vars(player): return dict( completionlink= player.subsession.session.config['completionlink'] ) pass page_sequence = [Welcome, Demographics, Instruction, Attention1, Attention2, Intro, Leader1, Leader7, Leader8, Leader9, Attention3, End, Redirect]