from otree.api import * c = cu doc = '' class C(BaseConstants): NAME_IN_URL = 'Part2' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 SLIDERSTYLE_TEMPLATE = 'Part2/sliderstyle.html' WEBKITSTYLE_TEMPLATE = 'Part2/webkitstyle.html' MOZSTYLE_TEMPLATE = 'Part2/mozstyle.html' INSTRUCTIONS_TEMPLATE = 'Part2/instructions.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): one = models.IntegerField(blank=True, initial=0, label='1,0', max=100, min=0) onethree = models.IntegerField(blank=True, initial=0, label='1,3', max=100, min=0) oneseven = models.IntegerField(blank=True, initial=0, label='1,7', max=100, min=0) two = models.IntegerField(blank=True, initial=0, label='2,0', max=100, min=0) twothree = models.IntegerField(blank=True, initial=0, label='2,3', max=100, min=0) twoseven = models.IntegerField(blank=True, initial=0, label='2,7', max=100, min=0) three = models.IntegerField(blank=True, initial=0, label='3,0', max=100, min=0) threethree = models.IntegerField(blank=True, initial=0, label='3,3', max=100, min=0) threeseven = models.IntegerField(blank=True, initial=0, label='3,7', max=100, min=0) four = models.IntegerField(blank=True, initial=0, label='4,0', max=100, min=0) fourthree = models.IntegerField(blank=True, initial=0, label='4,3', max=100) fourseven = models.IntegerField(blank=True, label='4,7', max=100, min=0) five = models.IntegerField(blank=True, initial=0, label='5,0', max=100, min=0) age = models.IntegerField(label='How old are you?', max=100, min=14) gender = models.StringField(choices=[['Male', 'Male'], ['Female', 'Female'], ['Divers', 'Non-binary'], ['Prefer not to say', 'Prefer not to say']], label='What is your gender?', widget=widgets.RadioSelect) programme = models.StringField(choices=[['TUM-BWL', 'Management & Technology'], ['Bioeconomy', 'Bioeconomy'], ['Other', 'Other']], label='Please select your field of study:') Sum = models.IntegerField(label='You have already distributed:') Confirmation = models.StringField(choices=[['Confirmed', 'I confirm that I left no field empty and that my guesses about the probabilities of each grade add up to 100 percentage points.']], label='', widget=widgets.RadioSelect) rest = models.IntegerField(label='') grade = models.FloatField() otherprogramme = models.StringField(label='Please specify your field of study:') best_guess = models.FloatField(choices=[[1, '1.0'], [1.3, '1.3'], [1.7, '1.7'], [2, '2.0'], [2.3, '2.3'], [2.7, '2.7'], [3, '3.0'], [3.3, '3.3'], [3.7, '3.7'], [4, '4.0'], [4.3, '4.3'], [4.7, '4.7'], [5, '5.0']], label='Please select your best guess about your exam grade in Economics I:', widget=widgets.RadioSelectHorizontal) browser = models.StringField() firefox = models.BooleanField(blank=True, initial=False) delay_group = models.BooleanField(label='') further_explanation = models.BooleanField(blank=True, initial=False) competition = models.StringField(choices=[['Option1', 'Option 1'], ['Option2', 'Option 2']], label='', widget=widgets.RadioSelect) email = models.StringField(label='') cognitive1 = models.FloatField(label='') cognitive2 = models.FloatField(label='') cognitive3 = models.FloatField(label='') paypal = models.BooleanField(choices=[[True, 'PayPal'], [False, 'Cash']], label='', widget=widgets.RadioSelect) correct_filler = models.IntegerField(initial=0, label='') symbols1 = models.IntegerField(blank=True, label='Please count the → symbols in the matrix:') symbols2 = models.IntegerField(blank=True, label='Please count the → symbols in the matrix:') symbols3 = models.IntegerField(blank=True, label='Please count the → symbols in the matrix:') symbols4 = models.IntegerField(blank=True, label='Please count the → symbols in the matrix:') symbols5 = models.IntegerField(blank=True, label='Please count the → symbols in the matrix:') symbols6 = models.IntegerField(blank=True, label='Please count the → symbols in the matrix:') decode1 = models.StringField(blank=True, label='Please enter the text decoded by the number:') decode2 = models.StringField(blank=True, label='Please enter the text decoded by the number:') decode3 = models.StringField(blank=True, label='Please enter the text decoded by the number:') decode4 = models.StringField(blank=True, label='Please enter the text decoded by the number:') decode5 = models.StringField(blank=True, label='Please enter the text decoded by the number:') decode6 = models.StringField(blank=True, label='Please enter the text decoded by the number:') zeros1 = models.IntegerField(blank=True, label='Please count the zeros in the matrix:') zeros2 = models.IntegerField(blank=True, label='Please count the zeros in the matrix:') zeros3 = models.IntegerField(blank=True, label='Please count the zeros in the matrix:') zeros4 = models.IntegerField(blank=True, label='Please count the zeros in the matrix:') zeros5 = models.IntegerField(blank=True, label='Please count the zeros in the matrix:') zeros6 = models.IntegerField(blank=True, label='Please count the zeros in the matrix:') comprehension1 = models.IntegerField(choices=[[1, '...22 percent of your answers are correct.'], [2, '...40 percent of your answers are correct.'], [3, '...50 percent of your answers are correct.'], [4, '...60 percent of your answers are correct.']], label='You will always pass the exam if...', widget=widgets.RadioSelect) comprehension2 = models.IntegerField(choices=[[1, '...you have solved at least 50 percent but less than 75 percent of all questions correctly.'], [2, '...you have solved at least 25 percent but less than 50 percent of all questions correctly.'], [3, '...you have solved at least 50 percent but less than 75 percent of the questions beyond the passing limit correctly.'], [4, '...you have solved one more question than the passing limit.']], label='The grade of your examination will be “good” if...', widget=widgets.RadioSelect) D_comprehension = models.IntegerField(choices=[[1, '...will be published in TUM Online, typically 2 to 3 weeks after the examination.'], [2, '...will be published in Moodle, typically 4 to 5 weeks after the examination.'], [3, '...will be published in Moodle, typically 2 to 3 weeks after the examination.'], [4, '...will be published in TUM Online, typically 4 to 5 weeks after the examination.']], label='The grade of your Economics 1 exam...', widget=widgets.RadioSelect) I_comprehension = models.IntegerField(choices=[[1, '...will be published in TUM Online, in approximately one hour.'], [2, '...will be published in Moodle, in approximately one week.'], [3, '...will be published in Moodle, in approximately one hour.'], [4, '...will be published in TUM Online, in approximately one week.']], label='The grade of your Economics 1 exam...', widget=widgets.RadioSelect) tries_comprehension = models.IntegerField(initial=1, label='') risk_preferences = models.IntegerField(label='Please tell us, in general, how willing or unwilling you are to take risks. Please use a scale from 0 to 10, where 0 means “completely unwilling to take risks” and a 10 means you are “very willing to take risks”. You can also use any numbers between 0 and 10 to indicate where you fall on the scale, like 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.', max=10, min=0) time_preferences = models.IntegerField(label='Please tell us, in general, how willing or unwilling are you to give up something that is beneficial for you today in order to benefit more from that in the future. Please use a scale from 0 to 10, where 0 means “completely unwilling” and a 10 means you are “very willing”. You can also use any numbers between 0 and 10 to indicate where you fall on the scale, like 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.', max=10, min=0) studentID = models.StringField(label='Please enter your matriculation number (e.g. 03717232)') def get_group(player: Player): group = player.group import random player.delay_group = random.choice([True, False]) class Welcome(Page): form_model = 'player' form_fields = ['firefox'] @staticmethod def before_next_page(player: Player, timeout_happened): group = player.group get_group(player); @staticmethod def error_message(player: Player, values): pass class WaitPage1(WaitPage): @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group==False: return True class D_Filler(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group==True: return True class D_Symbols(Page): form_model = 'player' form_fields = ['symbols1', 'symbols2', 'zeros6'] timeout_seconds = 30 @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group==True: return True @staticmethod def before_next_page(player: Player, timeout_happened): if player.field_maybe_none('symbols1')==11: player.correct_filler+=1 if player.field_maybe_none('symbols2')==12: player.correct_filler+=1 class D_Decoding(Page): form_model = 'player' form_fields = ['decode1', 'decode2'] timeout_seconds = 30 @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group==True: return True @staticmethod def before_next_page(player: Player, timeout_happened): if player.field_maybe_none('decode1')=="DIHET": player.correct_filler+=1 if player.field_maybe_none('decode2')=="JCTZX": player.correct_filler+=1 class D_Zeros(Page): form_model = 'player' form_fields = ['zeros1', 'zeros2'] timeout_seconds = 30 @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group==True: return True @staticmethod def before_next_page(player: Player, timeout_happened): if player.field_maybe_none('zeros1')==16: player.correct_filler+=1 if player.field_maybe_none('zeros2')==20: player.correct_filler+=1 class I_Filler(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group==False: return True class I_Symbols(Page): form_model = 'player' form_fields = ['symbols1', 'symbols2', 'symbols3', 'symbols4', 'symbols5', 'symbols6'] timeout_seconds = 90 @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group==False: return True @staticmethod def before_next_page(player: Player, timeout_happened): if player.field_maybe_none('symbols1')==11: player.correct_filler+=1 if player.field_maybe_none('symbols2')==12: player.correct_filler+=1 if player.field_maybe_none('symbols3')==10: player.correct_filler+=1 if player.field_maybe_none('symbols4')==12: player.correct_filler+=1 if player.field_maybe_none('symbols5')==10: player.correct_filler+=1 if player.field_maybe_none('symbols6')==9: player.correct_filler+=1 class I_Decoding(Page): form_model = 'player' form_fields = ['decode1', 'decode2', 'decode3', 'decode4', 'decode5', 'decode6'] timeout_seconds = 90 @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group==False: return True @staticmethod def before_next_page(player: Player, timeout_happened): if player.field_maybe_none('decode1')=="DIHET": player.correct_filler+=1 if player.field_maybe_none('decode2')=="JCTZX": player.correct_filler+=1 if player.field_maybe_none('decode3')=="HKDJE": player.correct_filler+=1 if player.field_maybe_none('decode4')=="IXMWQ": player.correct_filler+=1 if player.field_maybe_none('decode5')=="AGNKQ": player.correct_filler+=1 if player.field_maybe_none('decode6')=="ESNTK": player.correct_filler+=1 class I_Zeros(Page): form_model = 'player' form_fields = ['zeros1', 'zeros2', 'zeros3', 'zeros4', 'zeros5', 'zeros6'] timeout_seconds = 90 @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group==False: return True @staticmethod def before_next_page(player: Player, timeout_happened): if player.field_maybe_none('zeros1')==16: player.correct_filler+=1 if player.field_maybe_none('zeros2')==20: player.correct_filler+=1 if player.field_maybe_none('zeros3')==23: player.correct_filler+=1 if player.field_maybe_none('zeros4')==23: player.correct_filler+=1 if player.field_maybe_none('zeros5')==19: player.correct_filler+=1 if player.field_maybe_none('zeros6')==18: player.correct_filler+=1 class WaitPage2(WaitPage): @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group==False: return True class General_Instructions(Page): form_model = 'player' class I_Treatment1(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group == False: return True class D_Treatment1(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group == True: return True class I_Treatment2(Page): form_model = 'player' form_fields = ['comprehension1', 'comprehension2', 'I_comprehension'] @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group == False: return True @staticmethod def error_message(player: Player, values): if values['comprehension1']!=4 or values['comprehension2']!=3 or values['I_comprehension']!=1: player.tries_comprehension+=1; return 'You chose at least one wrong answer, please try again' class D_Treatment2(Page): form_model = 'player' form_fields = ['comprehension1', 'comprehension2', 'D_comprehension'] @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group == True: return True @staticmethod def error_message(player: Player, values): if values['comprehension1']!=4 or values['comprehension2']!=3 or values['D_comprehension']!=1: player.tries_comprehension+=1; return 'You chose at least one wrong answer, please try again' class I_Feedback(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group == False: return True class D_Feedback(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): group = player.group if player.delay_group == True: return True class Part_2_1_Decision(Page): form_model = 'player' form_fields = ['best_guess'] class Part_2_2_Decision(Page): form_model = 'player' form_fields = ['competition'] class Part_2_3_Explanation(Page): form_model = 'player' form_fields = ['further_explanation'] class Part_2_3_Payment_Mechanism(Page): form_model = 'player' form_fields = ['oneseven'] @staticmethod def is_displayed(player: Player): if player.further_explanation == True: return True class Part_2_3_Decision(Page): form_model = 'player' form_fields = ['one', 'onethree', 'oneseven', 'two', 'twothree', 'twoseven', 'three', 'threethree', 'threeseven', 'four', 'fourthree', 'fourseven', 'five', 'Sum', 'Confirmation', 'rest'] @staticmethod def error_message(player: Player, values): pass class CRT(Page): form_model = 'player' form_fields = ['cognitive1', 'cognitive2', 'cognitive3'] timeout_seconds = 60 class Risk_Preferences(Page): form_model = 'player' form_fields = ['risk_preferences'] class Time_Preferences(Page): form_model = 'player' form_fields = ['time_preferences'] class Demographics(Page): form_model = 'player' form_fields = ['gender', 'age', 'programme'] class Demographics2(Page): form_model = 'player' form_fields = ['gender', 'age', 'programme', 'otherprogramme'] @staticmethod def is_displayed(player: Player): if player.programme == "Other": return True class MatriculationNR(Page): form_model = 'player' form_fields = ['studentID'] @staticmethod def error_message(player: Player, values): print('values is', values) if len(values['studentID']) != 8: return 'Your matriculation number should have exactly 8 digits. Please correct it.' class Payment(Page): form_model = 'player' form_fields = ['paypal'] class PayPal(Page): form_model = 'player' form_fields = ['email'] @staticmethod def is_displayed(player: Player): if player.paypal==True: return True class Contact(Page): form_model = 'player' form_fields = ['email'] @staticmethod def is_displayed(player: Player): if player.paypal!=True: return True class End(Page): form_model = 'player' page_sequence = [Welcome, WaitPage1, D_Filler, D_Symbols, D_Decoding, D_Zeros, I_Filler, I_Symbols, I_Decoding, I_Zeros, WaitPage2, General_Instructions, I_Treatment1, D_Treatment1, I_Treatment2, D_Treatment2, I_Feedback, D_Feedback, Part_2_1_Decision, Part_2_2_Decision, Part_2_3_Explanation, Part_2_3_Payment_Mechanism, Part_2_3_Decision, CRT, Risk_Preferences, Time_Preferences, Demographics, Demographics2, MatriculationNR, Payment, PayPal, Contact, End]