from otree.api import * doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = "post_experiment_survey" PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): questions_clear = models.StringField() questions_clear_text = models.LongStringField(blank=True, label="") conversation_smooth = models.StringField() conversation_smooth_text = models.LongStringField(blank=True, label="") experiment_purpose = models.LongStringField(label="What do you think was the purpose of the experiment?") # PAGES class Questions1(Page): form_model = "player" @staticmethod def get_form_fields(player: Player): # Don't ask for conversation if player hasn't had communication partner if not len(player.participant.previous_comm_partners): return ["questions_clear", "questions_clear_text"] return ["questions_clear", "questions_clear_text", "conversation_smooth", "conversation_smooth_text"] @staticmethod def vars_for_template(player: Player): return dict( had_comm_partner=len(player.participant.previous_comm_partners), multiple_choice_questions=[ dict( name="questions_clear", label="Were the instructions clear? You can use the box below to elaborate.", choices=["very clear", "somewhat clear", "somewhat unclear", "very unclear"], ), dict( name="conversation_smooth", label="Did you find the communication with the conversation partner smooth? You can use the box below to elaborate.", choices=["very smooth", "somewhat smooth", "somewhat difficult", "very difficult"], ), ], ) class Questions2(Page): form_model = "player" form_fields = ["experiment_purpose"] page_sequence = [Questions1, Questions2]