import random from otree.api import * doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'Study' players_per_group = None tasks = ['UG', 'Doubled', 'Half', 'DG'] num_rounds = len(tasks) FORM_TEMPLATE = __name__ + '/form.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): consent = models.IntegerField(widget=widgets.RadioSelect, label="", choices=[[0, 'Consent and Proceed'], [1, 'Leave this survey']]) code = models.StringField(label="Insert your code here") # This is for main choices, each variable is one row in the choice table MPL UG_1 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_3 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_5 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_7 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_9 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) UG_11 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_1 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_3 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_5 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_7 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_9 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Doubled_11 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_1 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_3 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_5 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_7 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_9 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) Half_11 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_1 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_2 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_3 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_4 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_5 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_6 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_7 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_8 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_9 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_10 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) DG_11 = models.PositiveIntegerField(choices=[[1, '

Very Inappropriate

'], [2, '

Inappropriate

'], [3, '

Rather Inappropriate

'], [4, '

Rather Appropriate

'], [5, '

Appropriate

'], [6, '

Very Appropriate

']], widget=widgets.RadioSelectHorizontal) a = models.PositiveIntegerField(choices=[[1, 'Person A earns 3€ and Person B earns 7€.'], [2, 'Person A earns 5€ and Person B earns 5€.'], [3, 'Person A earns 7€ and Person B earns 3€.']], label="How much does Person A and Person B earn, if Person A gives 3€ to Person B?", widget=widgets.RadioSelect) b = models.PositiveIntegerField(choices=[[1, 'Person A earns 3€ and Person B earns 7€.'], [2, 'Person A earns 5€ and Person B earns 5€.'], [3, 'Person A earns 7€ and Person B earns 3€.']], label="How much does Person A and Person B earn, if Person A gives 7€ to Person B?", widget=widgets.RadioSelect) UG1 = models.PositiveIntegerField(choices=[[1, 'Person A earns 7€ and Person B earns 3€.'], [2, 'Person A earns 0€ and Person B earns 0€.'], [3, 'Person A earns 3€ and Person B earns 7€.']], label="How much does Person A and Person B earn, if Person A offers 3€ to " "Person B and Person B rejects the offer?", widget=widgets.RadioSelect) UG2 = models.PositiveIntegerField(choices=[[1, 'Person A earns 7€ and Person B earns 3€.'], [2, 'Person A earns 0€ and Person B earns 0€.'], [3, 'Person A earns 3€ and Person B earns 7€.']], label="How much does Person A and Person B earn, if Person A offers 3€" " to Person B and Person B accepts the offer? ", widget=widgets.RadioSelect) Doubled1 = models.PositiveIntegerField(choices=[[1, 'Person A earns 3€ and Person B earns 7€.'], [2, 'Person A earns 7€ and Person B earns 6€.'], [3, 'Person A earns 7€ and Person B earns 3€. ']], label="How much does Person A and Person B earn, if Person A gives 3€ to Person B?", widget=widgets.RadioSelect) Doubled2 = models.PositiveIntegerField(choices=[[1, 'Person A earns 3€ and Person B earns 7€.'], [2, 'Person A earns 7€ and Person B earns 3€.'], [3, 'Person A earns 3€ and Person B earns 14€.']], label="How much does Person A and Person B earn, if Person A gives 7€ to Person B?", widget=widgets.RadioSelect) Half1 = models.PositiveIntegerField(choices=[[1, 'Person A earns 3€ and Person B earns 7€.'], [2, 'Person A earns 7€ and Person B earns 1.50€.'], [3, 'Person A earns 7€ and Person B earns 3€.']], label="How much does Person A and Person B earn, if Person A gives 3€ to Person B?", widget=widgets.RadioSelect) Half2 = models.PositiveIntegerField(choices=[[1, 'Person A earns 3€ and Person B earns 7€.'], [2, 'Person A earns 7€ and Person B earns 3€.'], [3, 'Person A earns 3€ and Person B earns 3.50€. ']], label="How much does Person A and Person B earn, if Person A gives 7€ to Person B?", widget=widgets.RadioSelect) # # These variables are collected in the final questionnaire gender = models.StringField(widget=widgets.RadioSelectHorizontal(), choices=['Male', 'Female']) age = models.IntegerField(choices=range(18, 60, 1)) Study = models.TextField(label="What are your current field and level of studies? (example: Law M1). In case you " "are not" " currently studying, what are your last studies?") Nationality = models.TextField(label="What is your nationality? (example: French)") # FUNCTIONS def creating_session(subsession: Subsession): if subsession.round_number == 1: for p in subsession.get_players(): round_numbers = list(range(1, Constants.num_rounds + 1)) random.shuffle(round_numbers) p.participant.vars['task_rounds'] = dict(zip(Constants.tasks, round_numbers)) p.participant.vars['consent1'] = 2 def get_quiz_data(): return [ dict( name='a', solution=3, explanation="The selected answer is incorrect. The correct answer is “Person A earns 7€ and Person B " "earns 3€”. Recall that Person A receives 10€. Therefore, if Person A gives 3€ to Person B," " Person A earns (10 - 3) = 7€ and Person B earns 3€.", ), dict( name='b', solution=1, explanation="The selected answer is incorrect. The correct answer is “Person A earns 3€ " "and Person B earns 7€”. Recall that Person A receives 10€. " "Therefore, if Person A gives 7€ to Person B, Person A earns (10 - 7) = 3€ " "and Person B earns 7€. ", ), ] def get_quiz_dataUG(): return[ dict( name='UG1', solution=2, explanation="The selected answer is incorrect. The correct answer is “Person A earns 0€ and " "Person B earns 0€”. Person B rejected the offer. Recall that when Person B " "rejects an offer both Person A and Person B earn 0€.", ), dict( name='UG2', solution=1, explanation="The selected answer is incorrect. The correct answer is “Person A " "earns 7€ and Person B earns 3€”. Person B accepted the offer. " "Therefore, Person A earns (10 - 3) = 7€ when he gives 3€ to Person B. Person B earns 3€.", ), ] def get_quiz_dataDoubled(): return [ dict( name='Doubled1', solution=2, explanation="The selected answer is incorrect. The correct answer is “Person A earns 7€ and Person" " B earns 6€”. Recall that Person A receives 10€, and that the amount send by Person A" " is doubled. Therefore, if Person A gives 3€ to Person B, Person A earns (10 - 3) =" " 7€ and Person B earns (3 x 2) = 6€.", ), dict( name='Doubled2', solution=3, explanation="The selected answer is incorrect. The correct answer is “Person A earns 3€ and Person B" " earns 14€”. Recall that Person A receives 10€, and that the amount send by " "Person A is doubled. Therefore, if Person A gives 7€ to Person B, Person A" " earns (10 - 7) = 3€ and Person B earns (7 x 2) = 14€.", ), ] def get_quiz_dataHalf(): return [ dict( name='Half1', solution=2, explanation="The selected answer is incorrect. The correct answer is “Person A earns 7€ and Person B" " earns 1.50€”. Recall that Person A receives 10€, and that half the amount send " "by Person A is lost. Therefore, if Person A gives 3€ to Person B, Person A earns" " (10 - 3) = 7€ and Person B earns (3 x 1/2) = 1.50€.", ), dict( name='Half2', solution=3, explanation="The selected answer is incorrect. The correct answer is “Person A earns 3€ and Person B earns" " 3.50€”. Recall that Person A receives 10€, and that half the amount " "send by Person A is lost. Therefore, if Person A gives 3€ to Person B," " Person A earns (10 - 7) = 3€ and Person B earns (7 x 1/2) = 3.50€.", ), ] # PAGE class ElicitationNormsUG(Page): @staticmethod def is_displayed(player: Player): return player.round_number == player.participant.vars['task_rounds']['UG'] and player.participant.vars['consent1'] == 0 # which forms are needed from class player form_model = 'player' form_fields = ['UG_1', 'UG_2', 'UG_3', 'UG_4', 'UG_5', 'UG_6', 'UG_7', 'UG_8', 'UG_9', 'UG_10', 'UG_11'] # all 11 options class ElicitationNormsDoubled(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Doubled'] and player.participant.vars['consent1'] == 0 # which forms are needed from class player form_model = 'player' form_fields = ['Doubled_1', 'Doubled_2', 'Doubled_3', 'Doubled_4', 'Doubled_5', 'Doubled_6', 'Doubled_7', 'Doubled_8', 'Doubled_9', 'Doubled_10', 'Doubled_11'] # all 11 options class ElicitationNormsHalf(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Half'] and player.participant.vars['consent1'] == 0 # which forms are needed from class player form_model = 'player' form_fields = ['Half_1', 'Half_2', 'Half_3', 'Half_4', 'Half_5', 'Half_6', 'Half_7', 'Half_8', 'Half_9', 'Half_10', 'Half_11'] class ElicitationNormsDG(Page): # which forms are needed from class player form_model = 'player' form_fields = ['DG_1', 'DG_2', 'DG_3', 'DG_4', 'DG_5', 'DG_6', 'DG_7', 'DG_8', 'DG_9', 'DG_10', 'DG_11'] # all 11 options @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['DG'] and player.participant.vars['consent1'] == 0 class Instructions1(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 and player.participant.vars['consent1'] == 0 class ExampleSituation(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 and player.participant.vars['consent1'] == 0 class SituationDescriptionUG(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['UG'] and player.participant.vars['consent1'] == 0 # which forms are needed from class player class SituationDescriptionDoubled(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Doubled'] and player.participant.vars['consent1'] == 0 # which forms are needed from class player form_model = 'player' class SituationDescriptionDG(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['DG'] and player.participant.vars['consent1'] == 0 # which forms are needed from class player form_model = 'player' class SituationDescriptionHalf(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Half'] and player.participant.vars['consent1'] == 0 form_model = 'player' class ConsentForm(Page): # which forms are needed from class player form_model = 'player' form_fields = ['consent'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 def before_next_page(player, timeout_happened): player.participant.vars['consent1'] = player.consent class GeneralInstructions(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 and player.participant.vars['consent1'] == 0 class Questionnaire(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == Constants.num_rounds and player.participant.vars['consent1'] == 0 # forms to retrieve individual information form_model = 'player' form_fields = ['age', 'gender', 'Nationality', 'Study'] class Code1(Page): form_model = 'player' form_fields = ['code'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 and player.participant.vars['consent1'] == 0 class InstructionsExperiment(Page): # which forms are needed from class player form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == 1 and player.participant.vars['consent1'] == 0 class InstructionsNormsUG(Page): @staticmethod def is_displayed(player: Player): return player.round_number == player.participant.vars['task_rounds']['UG'] and player.participant.vars['consent1'] == 0 # which forms are needed from class player form_model = 'player' form_fields = ['UG1', 'UG2'] # all 11 options class InstructionsNormsDoubled(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Doubled'] and player.participant.vars['consent1'] == 0 # which forms are needed from class player form_model = 'player' form_fields = ['Doubled1', 'Doubled2'] class InstructionsNormsHalf(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Half'] and player.participant.vars['consent1'] == 0 # which forms are needed from class player form_model = 'player' form_fields = ['Half1', 'Half2'] class InstructionsNormsDG(Page): @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['DG'] and player.participant.vars['consent1'] == 0 # which forms are needed from class player form_model = 'player' form_fields = ['a', 'b'] # all 11 options @staticmethod def vars_for_template(player: Player): fields = get_quiz_data() return dict(fields=fields, show_solutions=False) class ResultsDG(Page): form_model = 'player' form_fields = ['a', 'b'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['DG'] and player.participant.vars['consent1'] == 0 @staticmethod def vars_for_template(player: Player): fields = get_quiz_data() # we add an extra entry 'is_correct' (True/False) to each field for d in fields: d['is_correct'] = getattr(player, d['name']) == d['solution'] return dict(fields=fields, show_solutions=True) class ResultsUG(Page): form_model = 'player' form_fields = ['UG1', 'UG2'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['UG'] and player.participant.vars['consent1'] == 0 @staticmethod def vars_for_template(player: Player): fields = get_quiz_dataUG() # we add an extra entry 'is_correct' (True/False) to each field for d in fields: d['is_correct'] = getattr(player, d['name']) == d['solution'] return dict(fields=fields, show_solutions=True) class ResultsDoubled(Page): form_model = 'player' form_fields = ['Doubled1', 'Doubled2'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Doubled'] and player.participant.vars['consent1'] == 0 @staticmethod def vars_for_template(player: Player): fields = get_quiz_dataDoubled() # we add an extra entry 'is_correct' (True/False) to each field for d in fields: d['is_correct'] = getattr(player, d['name']) == d['solution'] return dict(fields=fields, show_solutions=True) class ResultsHalf(Page): form_model = 'player' form_fields = ['Half1', 'Half2'] @staticmethod def is_displayed(player: Player): participant = player.participant return player.round_number == player.participant.vars['task_rounds']['Half'] and player.participant.vars['consent1'] == 0 @staticmethod def vars_for_template(player: Player): fields = get_quiz_dataHalf() # we add an extra entry 'is_correct' (True/False) to each field for d in fields: d['is_correct'] = getattr(player, d['name']) == d['solution'] return dict(fields=fields, show_solutions=True) page_sequence = [ConsentForm, Code1, InstructionsExperiment, InstructionsNormsUG, ResultsUG, ElicitationNormsUG, InstructionsNormsDoubled, ResultsDoubled, ElicitationNormsDoubled, InstructionsNormsHalf, ResultsHalf, ElicitationNormsHalf, InstructionsNormsDG, ResultsDG, ElicitationNormsDG, Questionnaire]