from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) from otreeutils.surveys import create_player_model_for_survey, generate_likert_field, generate_likert_table author = 'Huanren Zhang' doc = """ survey questions at the end of the experiment """ class Constants(BaseConstants): name_in_url = 'big5' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass # some pre-defined choices GENDER_CHOICES = ( ('female', 'Female'), ('male', 'Male'), # ('no_answer', 'Prefer not to answer'), ) YESNO_CHOICES = ( ('yes', 'Yes'), ('no', 'No'), ) # define a Likert 5-point scale with its labels likert_5_labels = ( 'Strongly disagree', 'Disagree', 'Neither agree nor disagree', 'Agree', 'Strongly agree' ) likert_7_labels = ( 'Strongly Disagree', 'Moderately Disagree', 'Slightly Disagree', 'Neutral', 'Slightly Agree', 'Moderately Agree', 'Strongly Agree' ) likert_5point_field = generate_likert_field(likert_5_labels) likert_7point_field = generate_likert_field(likert_7_labels) # define survey questions per page # for each page define a page title and a list of questions # the questions have a field name, a question text (input label), and a field type (model field class) SURVEY_DEFINITIONS = ( { 'page_title': '', 'survey_fields': [ # create a table of Likert scale choices # we use the same 5-point scale a before and specify four rows for the table, # each with a tuple (field name, label) ## Big-five (OCEAN: Openness, Conscientiousness, Extraversion, Agreeableness, Neuroticism) generate_likert_table(likert_7_labels, [ ('extraversion', "Extraverted, enthusiastic"), ('agreeablenessR', "Critical, quarrelsome"), ('conscientiousness', "Dependable, self-disciplined"), ('neuroticism', "Anxious, easily upset"), ('openness', "Open to new experiences, complex"), ('extraversionR', "Reserved, quiet"), ('agreeableness', "Sympathetic, warm"), ('conscientiousnessR', "Disorganized, careless"), ('neuroticismR', "Calm, emotionally stable"), ('opennessR', "Conventional, uncreative"), ], form_help_initial='

Below are a number of traits that may or may not apply to you.' + 'Please indicate the extent to which you agree or disagree with that statement ' + 'on a scale of 1 (strongly disagree) to 7 (strongly agree).

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

', # HTML to be placed below form table_row_header_width_pct=50, # width of row header (first column) in percent. default: 25 table_rows_randomize=True, # randomize order of displayed rows ), ] }, ) # 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('big5.models', SURVEY_DEFINITIONS, other_fields={})