from otree.api import models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Page doc = 'vocalics user study' url = 'https://www.mi.hs-rm.de/~mlies002/vocalics/' order_id_to_video = { 0: 'nd0.mp4', # nod 1: 'sh1.mp4', # shake 2: 'sh2.mp4' # jittery shake } order_id_to_audio = { 0: 'nd0.mp3', 1: 'sh1.mp3', 2: 'sh2.mp3' } possible_orders = [[0, 1, 0, 1], # 0 [0, 1, 1, 0], # 1 [1, 0, 0, 1], # 2 [1, 0, 1, 0], # 3 [0, 2, 0, 2], # 4 [0, 2, 2, 0], # 5 [2, 0, 0, 2], # 6 [2, 0, 2, 0]] # 7 class C(BaseConstants): NAME_IN_URL = 'vocalicsapp' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): export_media_order_id = models.IntegerField() user_agent = models.StringField() ms_spent_video_1 = models.IntegerField() ms_spent_video_2 = models.IntegerField() ms_spent_audio_1 = models.IntegerField() ms_spent_audio_2 = models.IntegerField() age = models.IntegerField(label='Wie alt sind Sie?', min=18, max=125) gender = models.IntegerField(label='Mit welchem Geschlecht identifizieren Sie sich?', choices=[[0, 'Ohne Angabe'], [1, 'Weiblich'], [2, 'Männlich'], [3, 'Divers']], initial=0) profession = models.StringField(label='Was sind Sie von Beruf bzw. was studieren Sie?') audio_to_video_1 = models.IntegerField(choices=[[0, 'Video 1'], [1, 'Video 2'], [2, 'nicht sicher']], label='Der Ton gehört zu...', widget=widgets.RadioSelect) audio_to_video_2 = models.IntegerField(choices=[[0, 'Video 1'], [1, 'Video 2'], [2, 'nicht sicher']], label='Der Ton gehört zu...', widget=widgets.RadioSelect) class General(Page): form_model = 'player' form_fields = ['age', 'gender', 'profession', 'user_agent'] # transfer participant's treatment group into this app's database @staticmethod def before_next_page(player, timeout_happened): participant = player.participant player.export_media_order_id = participant.media_order_id class Video1(Page): form_model = 'player' form_fields = ['ms_spent_video_1'] @staticmethod def vars_for_template(player): participant = player.participant return dict( media_url=url+order_id_to_video[possible_orders[participant.media_order_id][0]] ) class Video2(Page): form_model = 'player' form_fields = ['ms_spent_video_2'] @staticmethod def vars_for_template(player): participant = player.participant return dict( media_url=url+order_id_to_video[possible_orders[participant.media_order_id][1]] ) class Audio1(Page): form_model = 'player' form_fields = ['ms_spent_audio_1', 'audio_to_video_1'] @staticmethod def vars_for_template(player): participant = player.participant return dict( media_url=url+order_id_to_audio[possible_orders[participant.media_order_id][2]] ) class Audio2(Page): form_model = 'player' form_fields = ['ms_spent_audio_2', 'audio_to_video_2'] @staticmethod def vars_for_template(player): participant = player.participant return dict( media_url=url+order_id_to_audio[possible_orders[participant.media_order_id][3]] ) @staticmethod def before_next_page(player: Player, timeout_happened): session = player.session participant = player.participant session.completions_by_treatment[participant.media_order_id] += 1 class Final(Page): form_model = 'player' page_sequence = [General, Video1, Video2, Audio1, Audio2, Final]