from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random import csv option_list = [] with open("_static/no_choice/options_input.csv", newline='') as csvfile: my_list = csv.reader(csvfile, delimiter=',') for row in my_list: option_list.append(row) empty = {''} for i in range(len(option_list)): option_list[i] = [j for j in option_list[i] if j not in empty] class Constants(BaseConstants): name_in_url = 'survey' players_per_group = None options = option_list num_rounds = len(options) class Subsession(BaseSubsession): def creating_session(self): for p in self.get_players(): p.participant.vars['order'] = list(range(20)) random.shuffle(p.participant.vars['order']) class Group(BaseGroup): pass class Player(BasePlayer): age = models.IntegerField( label='What is your age?', min=13, max=125) gender = models.StringField( choices=['Male', 'Female', 'Other'], label='What is your gender?', widget=widgets.RadioSelect) choice_options = models.IntegerField( label = 'Please select one available option', widget=widgets.RadioSelect ) def choice_options_choices(self): #return Constants.options[self.participant.vars['order'][self.round_number-1]] return [[1, _static\no_choice\option_images\d_1_o_1.png],] options_o10a20 = models.StringField( choices=["00010011011001011111","00010100011001101100","00110000010101111000","00110011101011110000","00110011101101101011","00111000001101001101","10011101110101001001","10100110100100001101","11010000011100010111","11100001001011110000"], label='Please select one available option', widget=widgets.RadioSelect) options_o20a20 = models.StringField( choices=["33335355533333555535","33533353333335535535","33535353535335533333","33553355355535353335","33555355355333353353","33555555533333333333","35335553353553353533","35355353553335533333","35355533555333555335","35555333353555335333","53355555355353555355","53533335355533355353","53533355555555355355","53535333555335333533","53555533353535555535","55335353333333553333","55353333555333555533","55355533533535533553","55535333553533535535","55555555553535555535" ], label='Please select one available option', widget=widgets.RadioSelect) options_o10a30 = models.StringField( choices=["000110100101011111111001010000","000110111100100111000110100000","000111100111000100001000110000","001000000001110011001001000101","010000110010101001000111110001","010010111011101111001110010100","011110100000101011011101100010","100111001100011000001000101000","101111100110001111010001100110","111010110000011000000110011101"], label='Please select one available option', widget=widgets.RadioSelect) options_o20a30 = models.StringField( choices=["666669996966966699999669996699","666996666966666669669969666969","666996699696999699966699699696","666999696666999966996996699999","696666696969966966966966696969","696996696966696999699999666966","699669999966696699996699669969","699969969669666969969999996996","699999699999966699966666966669","966666666969969699969669696669","966696666966696999696999699669","966699696699696966999666996666","969669969966666696669666699996","969969699699669999669966999969","996666969699969699999699999669","996669969666996996969699666699","996999669666666669999996699999","996999699696666996669969966969","999696696966696996966969666999","999969696696666669696666999966" ], label='Please select one available option', widget=widgets.RadioSelect) crt_bat = models.IntegerField( label=''' A bat and a ball cost 22 dollars in total. The bat costs 20 dollars more than the ball. How many dollars does the ball cost?''' ) crt_widget = models.IntegerField( label=''' "If it takes 5 machines 5 minutes to make 5 widgets, how many minutes would it take 100 machines to make 100 widgets?" ''' ) crt_lake = models.IntegerField( label=''' In a lake, there is a patch of lily pads. Every day, the patch doubles in size. If it takes 48 days for the patch to cover the entire lake, how many days would it take for the patch to cover half of the lake? ''' )