from markupsafe import Markup
from otree.api import *
from intro import C as CIntro, survey_third_party_is_ai, treatment_is_single
doc = """
Your app description
"""
class C(CIntro):
NAME_IN_URL = 'end'
PLAYERS_PER_GROUP = None
NUM_ROUNDS = 1
class Subsession(BaseSubsession):
pass
class Group(BaseGroup):
pass
class Player(BasePlayer):
cubicle_number = models.StringField(
label=Markup("Please select the LETTER on your workstation again"),
choices=[chr(i) for i in range(65, 80)],
widget=widgets.RadioSelect
)
gender = models.IntegerField(
label="Please indicate your gender:",
choices=[
(0, 'Female'),
(1, 'Male'),
(2, 'I prefer not to disclose')
],
widget=widgets.RadioSelect
)
own_trust = models.IntegerField(
choices=list(range(1,8)),
label="Please rate your degree of trust in your own prediction.",
widget=widgets.RadioSelectHorizontal
)
partner_trust = models.IntegerField(
choices=list(range(1,8)),
label="Please rate your degree of trust in your partner's prediction.",
widget=widgets.RadioSelectHorizontal
)
ai_trust = models.IntegerField(
choices=list(range(1,8)),
label="",
widget=widgets.RadioSelectHorizontal
)
cooperation = models.IntegerField(
choices=list(range(1,8)),
label="Please rate the degree of cooperation with your partner during the task.",
widget=widgets.RadioSelectHorizontal
)
final_prediction = models.LongStringField(
label="How do you and your partner conform to a final prediction?"
)
ai_impact = models.IntegerField(
choices=list(range(1,8)),
label="",
widget=widgets.RadioSelectHorizontal
)
bug_report = models.LongStringField(
label="Did you experience any bugs or problems during the study? If so, please describe briefly. (Optional)",
blank=True,
)
# FUNCTIONS
# PAGES
class GenderSurvey(Page):
form_model = 'player'
form_fields = ['cubicle_number','gender']
@staticmethod
def before_next_page(player: Player, timeout_happened):
player.participant.vars['cubicle_number'] = player.cubicle_number
class Survey(Page):
form_model = 'player'
@staticmethod
def vars_for_template(player: Player):
treatment = player.participant.treatment or ''
return dict(
survey_third_party_is_ai=survey_third_party_is_ai(treatment),
is_single=treatment_is_single(treatment),
)
@staticmethod
def get_form_fields(player: Player):
treatment = player.participant.treatment or ''
is_single = treatment_is_single(treatment)
if is_single:
# S1: no partner questions
fields = ['own_trust']
if treatment != 'CG':
fields.append('ai_trust')
fields.append('ai_impact')
else:
# Team treatments: include partner questions
fields = ['own_trust', 'partner_trust', 'cooperation']
if treatment != 'CG':
fields.insert(2, 'ai_trust')
fields.append('ai_impact')
fields.append('final_prediction')
fields.append('bug_report')
return fields
class Results(Page):
@staticmethod
def vars_for_template(player: Player):
participant = player.participant
participant.finished = True
return dict(
total_earnings=participant.payoff_plus_participation_fee(),
is_single=treatment_is_single(participant.treatment or ''),
)
class EndOfStudy(Page):
def vars_for_template(player: Player):
participant = player.participant
return dict(
total_earnings=participant.payoff_plus_participation_fee()
)
page_sequence = [GenderSurvey, Survey, Results, EndOfStudy]