from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random author = 'Patrick Julius' doc = """ This app implements the standard 'Klee-Kandinsky' group paradigm. Participants are shown a number of paintings and asked to choose which they prefer, and then grouped based on which artist they chose most often. Group logic is set to ensure that groups satisfy two constraints: (1) Everyone in an artist's group strictly preferred more of that artist (2) Both groups are the same size Participants that cannot be matched using these criteria are told to leave the experiment early. """ class Constants(BaseConstants): name_in_url = 'Klee_Kandinsky' # This is used to ensure that there are always an even number of participants players_per_group = 2 # This should be the number of paintings plus one, as the last round assigns groups num_rounds = 6 participation_fee = 7 class Subsession(BaseSubsession): def creating_session(self): for player in self.get_players(): if not self.session.config['assign_groups']: player.participant.vars['artist'] = None # True if Klee then Kandinsky, false if reverse # Randomize ordering to make it harder to know which mug is which player.Klee_first = random.random() < 0.5 print("Klee first? " + str(player.Klee_first)) class Group(BaseGroup): artist = models.StringField() class Player(BasePlayer): Klee_first = models.BooleanField() Klee_chosen = models.IntegerField(initial=0) Kandinsky_chosen = models.IntegerField(initial=0) choice = models.StringField( choices=['A', 'B'], widget=widgets.RadioSelectHorizontal, )