from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer ) import csv author = 'Eveline Vandewal' doc = """ Social Preferences """ class Constants(BaseConstants): name_in_url = 'CTBS1_Part2A' players_per_group = None with open('CTBS1_Part2A/payoffs.csv') as problems_file: problems = list(csv.DictReader(problems_file)) num_rounds = len(problems) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): problem_id = models.IntegerField() x_you = models.IntegerField() x_other = models.IntegerField() y_you = models.IntegerField() y_other = models.IntegerField() randomized_order = models.IntegerField() colors_reversed = models.IntegerField() options_reversed = models.IntegerField() q1 = models.IntegerField( choices=[ [1, 'Yes'], [2, 'No'] ], widget=widgets.RadioSelect ) q2 = models.IntegerField() q3 = models.IntegerField() q1_error = models.BooleanField() q2_error = models.BooleanField() q3_error = models.BooleanField() cq_error = models.BooleanField() submitted_choice = models.IntegerField( choices=[ [1, 'Distribution X'], [2, 'Distribution Y'] ], widget=widgets.RadioSelect ) def current_problem(self): return self.participant.vars['randomized_problems2'][self.round_number - 1]