from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup ) from otree.db.models import ForeignKey from slider_task.models import BaseSlider, SliderPlayer import csv author = 'Eveline Vandewal' doc = """ Part 3: Strategic Games - Reciprocity """ class Constants(BaseConstants): name_in_url = 'RECI1_Part3' players_per_group = None with open('RECI1_Part3/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(SliderPlayer): problem_id = models.IntegerField() problem_type = models.IntegerField() payoff_a = models.IntegerField() payoff_b = models.IntegerField() payoff_c = models.IntegerField() payoff_d = models.IntegerField() payoff_e = models.IntegerField() payoff_f = models.IntegerField() payoff_g = models.IntegerField() payoff_h = models.IntegerField() option = models.StringField() reciprocity = models.StringField() colors_reversed = models.IntegerField() roles_reversed = models.IntegerField() q1 = models.IntegerField( choices=[ [1, 'Option A'], [2, 'Option B'] ], 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() clicks_a = models.TextField(blank=True) clicks_b = models.TextField(blank=True) clicks_c = models.TextField(blank=True) clicks_d = models.TextField(blank=True) clicks_e = models.TextField(blank=True) clicks_f = models.TextField(blank=True) clicks_g = models.TextField(blank=True) clicks_h = models.TextField(blank=True) submitted_choice = models.IntegerField( widget=widgets.RadioSelect ) submitted_belief = models.IntegerField() submitted_time = models.FloatField() def current_problem(self): return self.participant.vars['randomized_problems3'][self.round_number - 1] class Slider(BaseSlider): player = ForeignKey( Player, on_delete=models.CASCADE )