from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer ) import csv author = 'Eveline Vandewal' doc = """ Part 4: Dictator Games - Reciprocity """ class Constants(BaseConstants): name_in_url = 'RECI1_Part4' players_per_group = None with open('RECI1_Part4/problems.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() option = models.StringField() reciprocity = models.StringField() colors_reversed = models.IntegerField() options_reversed = models.IntegerField() submitted_choice = models.IntegerField( choices=[ [1, 'Distribution X'], [2, 'Distribution Y'] ], widget=widgets.RadioSelect ) submitted_time = models.FloatField() def current_problem(self): return self.participant.vars['randomized_problems4'][self.round_number - 1]