from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random import csv import numpy doc = """ Part 1 - CQ: Instructions and Control Questions before Part 1: Rounds 1 to 10 (same for both Players A and B) """ class Constants(BaseConstants): name_in_url = 'code_SS_part1_instr_and_CQ' players_per_group = 4 # --> only relevant for Players B - Part 2 # basically the group brings together all Players A from the same batch/session num_rounds = 1 class Subsession(BaseSubsession): cq1_n1_solution = models.IntegerField() cq1_n2_solution = models.IntegerField() cq1_n2_solution_to_show = models.StringField() cq1_n3_solution = models.IntegerField() cq1_n4_solution = models.IntegerField() cq1_n4_solution_to_show = models.StringField() cq1_n5_solution = models.IntegerField() cq1_n5_solution_to_show = models.StringField() cq1_n6_solution = models.IntegerField() cq1_n6_solution_to_show = models.StringField() n_tokens_equal_to_1_eur = models.IntegerField() def creating_session(self): self.cq1_n1_solution = self.session.config['cq1_n1_solution'] self.cq1_n2_solution = self.session.config['cq1_n2_solution'] self.cq1_n2_solution_to_show = self.session.config['cq1_n2_solution_to_show'] self.cq1_n3_solution = self.session.config['cq1_n3_solution'] self.cq1_n4_solution = self.session.config['cq1_n4_solution'] self.cq1_n4_solution_to_show = self.session.config['cq1_n4_solution_to_show'] self.cq1_n5_solution = self.session.config['cq1_n5_solution'] self.cq1_n5_solution_to_show = self.session.config['cq1_n5_solution_to_show'] self.cq1_n6_solution = self.session.config['cq1_n6_solution'] self.cq1_n6_solution_to_show = self.session.config['cq1_n6_solution_to_show'] self.n_tokens_equal_to_1_eur = self.session.config['n_tokens_equal_to_1_eur'] for p in self.get_players(): p.cq1_n1_solution = self.session.config['cq1_n1_solution'] # Correct answer = 10 Rounds p.cq1_n2_solution = self.session.config['cq1_n2_solution'] p.cq1_n2_solution_to_show = self.session.config['cq1_n2_solution_to_show'] # Correct answer = Paid only for one randomly selected round out of the 10 played p.cq1_n3_solution = self.session.config['cq1_n3_solution'] p.cq1_n3_solution_to_show = self.session.config['cq1_n3_solution_to_show'] # Correct answer = 0 Tokens, opening the first box is costless p.cq1_n4_solution = self.session.config['cq1_n4_solution'] p.cq1_n4_solution_to_show = self.session.config['cq1_n4_solution_to_show'] # Correct answer = The computer randomly selects which box is opened first. p.cq1_n5_solution = self.session.config['cq1_n5_solution'] p.cq1_n5_solution_to_show = self.session.config['cq1_n5_solution_to_show'] # Correct answer = Opening the second box costs either 1 or 5 tokens, the computer randomly determines # what is the cost at the beginning of each round. p.cq1_n6_solution = self.session.config['cq1_n6_solution'] p.cq1_n6_solution_to_show = self.session.config['cq1_n6_solution_to_show'] # Correct answer = The computer randomly draws one of the 9 scenarios at the beginning of each round. # The same scenario will have the same probability to be re-drawn in subsequent rounds. p.n_tokens_equal_to_1_eur = self.session.config['n_tokens_equal_to_1_eur'] # Conversion rate: number of tokens equal to 1 Euro class Group(BaseGroup): pass class Player(BasePlayer): cq1_n1 = models.IntegerField(label="", min=0, max=100) cq1_n2 = models.IntegerField(label="", choices=[[1, 'Tutti i round giocati (secondo il tasso conversione: 3 gettoni = 1 Euro)'], [2, 'Solo un round, selezionato casualmente (secondo il tasso conversione: 3 gettoni = 1 Euro)']], widget=widgets.RadioSelect, ) cq1_n3 = models.IntegerField(label="", min=0, max=100) cq1_n4 = models.IntegerField(label="", choices=[[1, 'Io, posso decidere liberamente quale delle due scatole voglio aprire per prima'], [2, 'Il computer determina casualmente quale delle due scatole aprire per prima']], widget=widgets.RadioSelect, ) cq1_n5 = models.IntegerField(label="", choices=[[1, 'Nessuno, aprire la seconda scatola non ha costi.'], [2, 'Aprire la seconda scatola costa 1 o 5 gettoni, il computer determina casualmente \ (con uguale probabilità) qual è il costo all’inizio di ciascun round.'], [3, 'Aprire la seconda scatola costa 1 o 5 gettoni, il computer determina casualmente \ (con uguale probabilità) qual è il costo all’inizio della Parte 1 e il costo è lo stesso per tutti i round.']], widget=widgets.RadioSelect, ) cq1_n6 = models.IntegerField(label="", choices=[[1, 'All’inizio di ciascun round, il computer seleziona uno dei nove scenari possibili casualmente.\ Lo stesso scenario avrà una probabilità di essere ri-selezionato inferiore nei round successivi.'], [2, 'All’inizio della Parte 1, il computer seleziona uno dei nove scenari possibili casualmente e \ lo scenario rimane lo stesso per tutti i round.'], [3, 'All’inizio di ciascun round, il computer seleziona uno dei nove scenari possibili casualmente.\ Lo stesso scenario avrà la stessa una probabilità di essere ri-selezionato nei round successivi.']], widget=widgets.RadioSelect, ) # cq1_n2_to_show = models.StringField() cq1_n4_to_show = models.StringField() cq1_n5_to_show = models.StringField() cq1_n6_to_show = models.StringField() # cq1_n1_solution = models.IntegerField() cq1_n2_solution = models.IntegerField() cq1_n2_solution_to_show = models.StringField() cq1_n3_solution = models.IntegerField() cq1_n3_solution_to_show = models.StringField() cq1_n4_solution = models.IntegerField() cq1_n4_solution_to_show = models.StringField() cq1_n5_solution = models.IntegerField() cq1_n5_solution_to_show = models.StringField() cq1_n6_solution = models.IntegerField() cq1_n6_solution_to_show = models.StringField() # n_tokens_equal_to_1_eur = models.IntegerField() # re_read_instructions = models.IntegerField(initial=0)