from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import numpy as np from otreeutils.surveys import create_player_model_for_survey, generate_likert_field, generate_likert_table author = 'Huanren Zhang' doc = """ survey questions """ class Constants(BaseConstants): name_in_url = 'wlpoibadv' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): def creating_session(self): for p in self.get_players(): p.positive = np.random.choice([0,1]) class Group(BaseGroup): pass SURVEY_DEFINITIONS = ( { 'page_title': '', 'survey_fields': [ generate_likert_table(('1', '2', '3', '4', '5', '6', '7', '8', '9', '10'), [('alan', '')], form_help_initial="""

Alan's friends give the following description of him:

intelligent, industrious, impulsive, critical, stubborn, envious.

On a scale of 1 (very bad) to 10 (very good), what is your impression of Alan?

""", # HTML to be placed on top of form form_help_final='

', # HTML to be placed below form table_row_header_width_pct=0, ), ] }, { 'page_title': '', 'survey_fields': [ generate_likert_table(('1', '2', '3', '4', '5', '6', '7', '8', '9', '10'), [('ben', '')], form_help_initial="""

Ben's friends give the following description of him:

envious, stubborn, critical, impulsive, industrious, intelligent

On a scale of 1 (very bad) to 10 (very good), what is your impression of Ben?

""", # HTML to be placed on top of form form_help_final='

', # HTML to be placed below form table_row_header_width_pct=0, ), ] }, ) # now dynamically create the Player class from the survey definitions # we can also pass additional (non-survey) fields via `other_fields` Player = create_player_model_for_survey('confirmation_bias.models', SURVEY_DEFINITIONS, other_fields={ 'custody': models.IntegerField(choices=[[1, 'A'], [2, 'B']],widget=widgets.RadioSelectHorizontal), 'positive': models.BooleanField(), })