from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'prerating' PLAYERS_PER_GROUP = 3 NUM_ROUNDS = 6 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): choice = models.IntegerField( label="How pleasant do you find this image?", widget=widgets.RadioSelectHorizontal, choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ) color = models.StringField() # PAGES class Fixation(Page): form_model = 'player' timeout_seconds = 1 class RatingChoice(Page): form_model = 'player' form_fields = ['choice'] @staticmethod def vars_for_template(player: Player): #images = ["images/IndianRed_circle.png", "images/SkyBlue_circle.png", "images/PaleGreen_circle.png", "images/LemonChiffon_circle.png"] #colors = ['red', 'blue', 'green', 'yellow'] images = ["images/circle.png", "images/square.png", "images/triangle.png", "images/hexagon.png", "images/x.png"] #new colors = ["IndianRed", "RoyalBlue", "SeaGreen", "Gold", "Lavender", "Indigo"] #revert colors = ["red", "blue", "green", "yellow", "purple", "brown"] player.color = colors[player.round_number-1] color = player.color return dict( image = images[4], color = colors[player.round_number-1] ) class RatingChoiceWaitPage(WaitPage): pass class Results(Page): pass page_sequence = [RatingChoice, Fixation] def custom_export(players): #header row yield ['participantSessionId', 'participantNum', 'preratingChoice', 'color'] #have: session id, otree id, prerating choices, round number, consensus level, choice, binary full consensus, binary reward win, condition, # reward left, reward right, image left, image right, postrating choices # still need: # prerating cellColor # postrating cellColor # trial icon id # whether normal or probe # round condition color # probe condition number # demographics #now, data rows: for p in players: participant = p.participant session = p.session #put all variable names in the following list, including class, for ex: participant.choice, session.cellColors, group.rewardLeft yield [participant.id_in_session, participant.code, p.choice, p.color]