from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, ) import random author = '' doc = """ urns_ """ class Constants(BaseConstants): name_in_url = 'urnsT' players_per_group = None tasks = ['PageOneT', 'PageTwoT', 'PageFourT'] num_rounds = len(tasks)+1 instructions_template = 'urns2/InstructionsT.html' completion_codes = ['WEOXBQETN', 'GYJ29BN9R', 'OY8CJE0WW', 'OWIOHOP00', 'LCYQHQP1W', 'Y77YJKQWK', 'C3V4NZ1CE', 'ERT14KN5Z', 'E4YXSTMPA', 'L7PKSL6SQ', 'JAUW5WZUF', 'M8JVOZBK4', 'J9XZGQHRW', 'J760S8QVC', '3SL95FGQF', 'YG5HD4Z3C', 'LVXEZBU0J', 'ZE413OTLM', 'RAONVEGYY', '9GOUSVLQN', 'DZNR3YUXC', 'M3A69PZ59', 'FAU2OM6OK', '72SZM65QG', '4W19D2NII', 'FVZ6FWW0P', '3L7JHHP2K', 'HGO134F14', 'O2N09UJSV', 'TNWXTXPOF', 'PH5LPQSV7', 'L6HX4ADMB', 'LU7FKK9VQ', '6VHOY8GNN', 'JJLPIV6AX', 'JII1N8GSA', '5VVO0UQFD', 'O72MHCPXL', 'GMZ0PREA5', 'OC1CZWJE2', 'JKPV3BBG9', '2RZD2LMDL', 'SYU7BJ04J', 'S0BBAE37Y', 'BHIPOYEWR', 'VHDM3T0WQ', '65RSBKBNV', 'Q5RXXH2MZ', 'DL407MKZV', 'CCYI3HH2P', '6DEJF5BXH', 'BW1T7PWJA', 'UI9FWZ5I6', 'S3GT5VV8D', '4LYZVSMGT', 'HV4HH54ST', '34KXPOY9A', '11HXCMGL8', '7XACFY8MT', '1HWVXVKZM', 'N3QME08DQ', 'XM4IQM48D', 'LTHX9CB4Z', 'JVDKIWEON', 'YXJY6GWTS', 'G4Q2D8NES', 'S060H8TZL', 'HXSEE8EW5', 'X6QEFM9KA', '5R36CQT64', 'E4MDTNL14', 'JAVBSPMFV', '3N12774XT', 'SIYMBNB76', '9G46USFMT', 'L6W1AAJBH', 'DWGE69WG3', 'GNM6VTXQ1', '7T1FP5N9Z', 'XC2AZKE9D', 'LKLLMIWZH', 'WG1QJ2VJL', 'VFWCU3NFY', '2HJMHBCA9', 'YVMMIXXP8', 'USZSHJ1MN', 'G24G9ID75', 'FK5RAAP93', 'X8HWA8MNH', 'EEPUCMO3P', '6HVRSTVL9', 'QZSY6EXWS', '2UVV2DH99', 'QW6SRZCEL', 'PN5KAL1N9', '1BTTKUH8K', '6Q5BN72PF', '1SYYDZXS2', 'A9456XOR1', '5VK1KF4RV', 'QPAX8HF3U', 'K44V670KE', 'DDV78MMO9', 'X1V1WDCP9', 'MABZNZ9LP', 'K9DUHZBZ4', 'BVQJLYJK7', '69XY1KG07', 'U17IYOQFC', 'NW8L03XPR', '66G0ZAEHT', 'MXH6O3Z0X', 'NISBTK62H', '1GCSH4PY6', 'S9XPMDSQU', 'PPNRJVKV0', '2XC5WSNX7', 'ZM9470NEQ', 'ABQN32KIU', 'NL133XO8K', '6RCL4M5GQ', '4N99BW4XE', 'BK1CYPW3Q', 'T78IY5875', '4WQX1ZZOJ', 'TP8XXI3L8', 'RP4WM7QUM', 'ERV48GMET', 'J8TXKFTEF', 'HPXC32OR7', 'D7H585OS2', 'X9J1K0T9B', 'AJK6SEET8', 'QQ324QMPW', 'F7LSPU0FW', '6LB4H86DA', 'J55TA8JRP', 'ZPLPJ641J', 'OHWT2NQ2P', '8F3Y2CJT9', 'RMWWTU6WC', 'LUYH93971', '5RSK02R0E', 'DOJLD0L7R', 'DA05I6LIL', 'KMH8WIXQE', 'TSFPYKOW3', '0D958JBM5', 'NQEEWESTX', 'L3EMYUEAR', '4Z9IA089H', 'S6HLU7DRQ', '5BQEY83HE', 'G9MIKXZB3', 'F9XHTGOY9', 'MJCDXHL7T', '2SN45W50N', '9X7D9QEV2', '4EODACL4Q', 'ZY3S0DYB3', '4Q90N8OKQ', 'KULJ0WNGI', '5DSG9TRCI', 'I32X1SEYP', 'G49G6PXON', 'EGWB4G5KF', 'ORFT1WM1R', 'HO6B9IZ58', '64E0GL3ZM', 'X8RQW6XG9', 'SUQDLTZ0W', 'GPKAUPPCM', 'Z6WDNDCY7', 'F6ACE5KB1', '92V6ZYWSC', 'T3FDFK8TV', 'KV5RVFYWX', 'MXTBGB2NB', 'QLME9M1AE', 'J55MZI9U2', 'KXN10VKYD', 'YXXFJY6DW', '6Y3NJ426O', 'A92EC3P54', 'KZAQ9OHB3', 'GMBPRJ5TQ', 'IOXBTOWXM', 'FHOBULMAY', 'TL5RP6GUJ', 'Q2JJLWV5O', '2CIWIVFMD', 'KBVCUQAIG', 'UDVXQCS5A', '50Z0UURRA', 'QIZG2C96P', '66L5XR81O', 'FNLR4NGQ2', 'BIWIFR2WO', '1XM4YFPXH', '73FU58Z97', '0YV0V6LSI', 'RLC1MP4IP', '7HEIVAUEX', 'D8HZXLAXD', '15HLP551R', '46RJMYY0Q', 'H44SLX90E', 'U2G7OQLMX', 'A9GQ2TQOD', '7JD5N7SKN', '3A2Q2X3CB', 'N4QZKB09M', 'MFM6OA9L3', 'F6JJYV2OM', '4JFNS3790', 'C2XWXEJBS', 'JO6RJHVTA', 'T3EZFHZBZ', 'AQQBPCLI2', 'QRI397OH7', '9ABB0SB9J', '8TALFW7R7', 'POZVRKZZG', 'CGX9HALGK', '1RHKHCTVD', 'V7M1T89E6', 'R6VT0G7UF', 'VFMOCFXCY', 'D4LCPIOT3', '229Y4FS5T', '6V14PHGSN', 'ULUG5HDDK', 'C8WHSZ3YK', '2E6BNYFXG', '1IEW6DVXC', 'Q2IGQ1ORG', 'F2KP5PZ9X', 'QEWJ6QC4P', '0D5QJ496H', '55HAUXVQ6', 'DP5PEOMI8', 'GTP6KU2B2', '8UH35TLFT', 'WOE452HUA', 'JFQDGTGSC', 'XSNZS92S8', '70791AXBS', 'J855QFSAV', 'GB3QVX1CH', 'FF939SAAZ', 'RUDR5Y9EU', 'F95MLJV0O', '2RZYISH4Z', 'TS217Z05N', 'PCIVBW2Q5', '7G6LODQO2', '1CR1GDAUH', 'MO67OSI0N', 'JXXHBSYTR', 'VBM86LV60', '477DDC0XL', '9WIAS1DDD', '2BICCFORW', '96VQELG2H', 'EFUYC81KQ', 'WLVT8U4CQ', '1O6YPRX15', '6N5FUTHKE', '8JRT5YY82', 'EQAENI8VD', 'MLF3OGX29', 'MI811NJPC', 'SOIP8QGTC', 'HNBR24534', '79TF1R9O7', 'QKM129W50', 'WYZ2OIUNQ', 'VKAFV5C9P', 'RLT2JDMES', 'UI1M9LM6I', 'NTZAHXONC', 'WK2AZ8RX5', 'L6HPQP2KX', 'FUJ2SF573', 'NZQ9F61ZC', 'E2B9E85OM', 'ECP6GPLVE', '14YL5U2HO', '56HEE65P7', '54AORSSHZ', '8M761S1OD', 'VIQ30JLZN', 'CTS8NGT77', 'KR83RDJMS', 'GKP78QCUX', '2EILSWX9G', 'TPASNN4SI', 'ZX14NUHVU', '3M4248VP5', 'EKB3SQK0A', 'HNFW9GE5H', '5EMKBLPUE', 'PNVVTM16D', 'B4H9W0RQF', '08LSXWQ8G', 'M6UNAKDDL', 'FI5PUA3R1', 'AKV31YPHX', '7E747URR2', '1HFLTVF5D', 'SHI6L6MLP', 'W7N7DZ3M7', 'RIAPXY4GJ', 'FB45Y6GSJ', 'C8C9DZ6P4', 'S0I5AWZZ6', '3VLXKSD51', 'E6APOFD7K', 'FPGAUBWO1', '5WF8PQ4I3', 'ICQ7P7GSD', 'YUESTOU4M', 'YN38NQMM3', 'V25HR7DNU', 'FSZYSFWVE', '4FJC2PQR2', 'HUXALAGBX', 'SOA6W2PFQ', '6LSRS57OD', '94A8LZ4RF', 'N35C3R7BW', 'M4L2S2LDG', 'XC5HNYJGJ', 'VPSQW779K', 'A9YOD9QGL', 'GTZLTSFHL', 'NJQOYZVS8', 'ZUIT3F1U2', 'QMP8A6JNJ', '8XA3C1D3F', 'KGOH0SBA8', 'HYMCAPA1W', 'N007O7AXQ', 'KS5CVE5Y6', 'MV7NA2QAX', '4K3OBXGRN', 'RRU94PNX9', '22FQISQSX', 'C702IV7F7', 'KBF7UP0YZ', 'TV0SUTX5J', '0OB18E8IX', 'T3CSSB9E5', 'H6KM47DOO', '2Q2U7FYN1', '922ZJN1X2', 'T2FQM3RBD', 'OMDBIPBOW', '3EFZ5LODG', '2F2NKFKMX', 'MCW6JI0RP', 'J8B0YEY14', 'JB1WMN6TE', 'Z14EUH2EW', '1EQQEMB6U', 'AGTZ7DZBA', '7W0VYIYD0', 'S2GT2LNBV', 'ZBGX0X9VE', '84L7BZU8V', 'DOWAYOYZ2', 'SDVK4M34Q', 'M4ZQZ27T9', 'HPYNV5X1Q', 'BIFRFJDB8', 'WBLGH819L', 'K8H27FANK', 'VTI80OXKC'] class Subsession(BaseSubsession): def creating_session(self): if self.round_number == 2: for p in self.get_players(): round_numbers = list(range(2, Constants.num_rounds+1)) random.shuffle(round_numbers) p.participant.vars['task_rounds_urn2'] = dict(zip(['PageOneT', 'PageTwoT', 'PageFourT'], round_numbers)) for player in self.get_players(): player.completion_code = self.my_function() player.participant.vars['generated_code'] = player.completion_code def my_function(self): return "".join((random.choices(Constants.completion_codes))) class Group(BaseGroup): pass class Player(BasePlayer): def true_false_1_choices(self): choices = ['TRUE', 'FALSE'] random.shuffle(choices) return choices def true_false_2_choices(self): choices = ['TRUE', 'FALSE'] random.shuffle(choices) return choices def true_false_3_choices(self): choices = ['TRUE', 'FALSE'] random.shuffle(choices) return choices def true_false_7_choices(self): choices = ['TRUE', 'FALSE'] random.shuffle(choices) return choices def urn_choice_red_2_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def urn_choice_blue_2_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def urn_choice_red_3_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def urn_choice_blue_3_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def urn_choice_red_4_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def urn_choice_blue_4_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def social_info_2_R_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def social_info_2_B_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def social_info_3_RR_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def social_info_3_RB_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def social_info_3_BR_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def social_info_3_BB_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def social_info_4_RRR_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def social_info_4_BBB_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def social_info_4_RRB_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def social_info_4_BBR_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def social_info_4_RBR_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def social_info_4_BRB_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def social_info_4_BRR_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def social_info_4_RBB_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def urn_choice_position1_red_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def urn_choice_position1_blue_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def information_channel_2_choices(self): choices = ['Draw a ball from the actual urn selected for your 4-member group in this round', 'See the group urn guess by the player in position 1'] random.shuffle(choices) return choices def information_channel_3_choices(self): choices = ['Draw a ball from the actual urn selected for your 4-member group in this round', 'See the respective group urn guesses by players in position 1 and position 2'] random.shuffle(choices) return choices def information_channel_4_choices(self): choices = ['Draw a ball from the actual urn selected for your 4-member group in this round', 'See the respective group urn guesses by players in position 1, position 2, and position 3'] random.shuffle(choices) return choices def get_form_fields(self): fields = self.form_fields random.shuffle(fields) return fields def outcome3_P1_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def outcome3_P2_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def outcome4_P1_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices def outcome4_P2_choices(self): choices = ['Red urn', 'Blue urn'] random.shuffle(choices) return choices information_channel_2 = models.StringField( choices=[ 'Draw a ball from the actual urn selected for your 4-member group in this round', 'See the group urn guess by the player in position 1'], widget=widgets.RadioSelect ) information_channel_3 = models.StringField( choices=[ 'Draw a ball from the actual urn selected for your 4-member group in this round', 'See the respective group urn guesses by players in position 1 and position 2'], widget=widgets.RadioSelect ) information_channel_4 = models.StringField( choices=[ 'Draw a ball from the actual urn selected for your 4-member group in this round', 'See the respective group urn guesses by players in position 1, position 2, and position 3'], widget=widgets.RadioSelect ) urn_choice_red_2 = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...one ball has been randomly drawn from the actual group urn and it is red:' ) urn_choice_blue_2 = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...one ball has been randomly drawn from the actual group urn and it is blue:' ) urn_choice_red_3 = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...one ball has been randomly drawn from the actual group urn and it is red:' ) urn_choice_blue_3 = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...one ball has been randomly drawn from the actual group urn and it is blue:' ) urn_choice_red_4 = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...one ball has been randomly drawn from the actual group urn and it is red:' ) urn_choice_blue_4 = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...one ball has been randomly drawn from the actual group urn and it is blue:' ) urn_choice_position1_red = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...one ball has been randomly drawn from the actual group urn and it is red:' ) urn_choice_position1_blue = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...one ball has been randomly drawn from the actual group urn and it is blue:' ) social_info_2_R = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...the player in position 1 has guessed the Red urn?' ) social_info_2_B = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...the player in position 1 has guessed the Blue urn?' ) social_info_3_RR = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...players in position 1 and position 2 have respectively guessed Red urn; and Red urn?' ) social_info_3_RB = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...players in position 1 and position 2 have respectively guessed Red urn; and Blue urn?' ) social_info_3_BR = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...players in position 1 and position 2 have respectively guessed Blue urn; and Red urn?' ) social_info_3_BB = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...players in position 1 and position 2 have respectively guessed Blue urn; and Blue urn?' ) social_info_4_RRR = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...players in position 1, position 2, and position 3 have respectively guessed Red urn; Red urn,' ' and Red urn?' ) social_info_4_RRB = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...players in position 1, position 2, and position 3 have respectively guessed Red urn; Red urn,' ' and Blue urn?' ) social_info_4_RBR = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...players in position 1, position 2, and position 3 have respectively guessed Red urn; Blue urn,' ' and Red urn?' ) social_info_4_BRR = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...players in position 1, position 2, and position 3 have respectively guessed Blue urn; Red urn,' ' and Red urn?' ) social_info_4_BBB = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...players in position 1, position 2, and position 3 have respectively guessed Blue urn; Blue urn,' ' and Blue urn?' ) social_info_4_BBR = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...players in position 1, position 2, and position 3 have respectively guessed Blue urn; Blue urn,' ' and Red urn?' ) social_info_4_BRB = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...players in position 1, position 2, and position 3 have respectively guessed Blue urn; Red urn,' ' and Blue urn?' ) social_info_4_RBB = models.StringField( choices=[ 'Red urn', 'Blue urn'], widget=widgets.RadioSelect, label='...players in position 1, position 2, and position 3 have respectively guessed Red urn; Blue urn,' ' and Blue urn?' ) true_false_1 = models.StringField( choices=[ 'TRUE', 'FALSE'], widget=widgets.RadioSelect, label='The actual group urn selected in each round is equally likely to be “Red” or “Blue”.' ' (additional $0.20 to your bonus if correct)' ) true_false_2 = models.StringField( choices=[ 'TRUE', 'FALSE'], widget=widgets.RadioSelect, label='The other 3 participants in your group face the same problem as you: guessing the selected group' ' urn in every round. (additional $0.20 to your bonus if correct)' ) true_false_3 = models.StringField( choices=[ 'TRUE', 'FALSE'], widget=widgets.RadioSelect, label='For a given round, the randomly selected group urn is the same for all members of your 4-member group.' ' (additional $0.20 to your bonus if correct)' ) true_false_7 = models.StringField( choices=[ 'TRUE', 'FALSE'], widget=widgets.RadioSelect, label='The “Red” urn always contains two red balls and one blue ball. The “Blue” urn always contains two ' 'blue balls and one red ball. (additional $0.20 to your bonus if correct)' ) outcome3_P1 = models.StringField( choices=['Red urn', 'Blue urn'], label='' ) outcome3_P2 = models.StringField( choices=['Red urn', 'Blue urn'], label='' ) outcome4_P1 = models.StringField( choices=['Red urn', 'Blue urn'], label='' ) outcome4_P2 = models.StringField( choices=['Red urn', 'Blue urn'], label='' ) answer_1 = models.IntegerField( min=0, label='There were 20 wolves in a forest. All wolves but 7 were hunted. How many wolves remain in the forest?' ) answer_2 = models.IntegerField( min=0, label='10 machines make 10 toys in 5 minutes. In how many minutes would 20 machines make 20 toys?' ) answer_3 = models.CurrencyField( min=0, label='The price of a $100 wrist watch was reduced by another 10 percent. What is the current price of the' ' wrist watch?' ) completion_code = models.StringField()