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, 'Je consens et je procède'], [1, 'Quitter cette enquête']]) code = models.StringField(label="Insérez votre code ici.") # This is for main choices, each variable is one row in the choice table MPL UG_1 = models.PositiveIntegerField(choices=[[1, '
Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) UG_2 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) UG_3 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) UG_4 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) UG_5 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) UG_6 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) UG_7 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) UG_8 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) UG_9 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) UG_10 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) UG_11 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DB_1 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DB_2 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DB_3 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DB_4 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DB_5 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DB_6 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DB_7 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DB_8 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DB_9 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DB_10 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DB_11 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) HF_1 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) HF_2 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) HF_3 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) HF_4 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) HF_5 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) HF_6 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) HF_7 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) HF_8 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) HF_9 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) HF_10 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) HF_11 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DG_1 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DG_2 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DG_3 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DG_4 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DG_5 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DG_6 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DG_7 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DG_8 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DG_9 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DG_10 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) DG_11 = models.PositiveIntegerField(choices=[[1, 'Très Inapproprié
'], [2, 'Inapproprié
'], [3, 'Plutôt Inapproprié
'], [4, 'Plutôt Approprié
'], [5, 'Approprié
'], [6, 'Très Approprié
']], widget=widgets.RadioSelectHorizontal) a = models.PositiveIntegerField(choices=[[1, 'La Personne A gagne 3€ et la Personne B gagne 7€'], [2, 'La Personne A gagne 5€ et la Personne B gagne 5€.'], [3, 'La Personne A gagne 7€ et la Personne B gagne 3€.']], label="Combien gagnent la Personne A et la Personne B, si la Personne A donne 3€ à la Personne B ?", widget=widgets.RadioSelect) b = models.PositiveIntegerField(choices=[[1, 'La Personne A gagne 3€ et la Personne B gagne 7€.'], [2, 'La Personne A gagne 5€ et la Personne B gagne 5€.'], [3, 'La Personne A gagne 7€ et la Personne B gagne 3€.']], label="Combien gagnent la Personne A et la Personne B, si la Personne A donne 7€ à la Personne B?", widget=widgets.RadioSelect) UG1 = models.PositiveIntegerField(choices=[[1, 'La Personne A gagne 7 € et la Personne B gagne 3 €.'], [2, 'La Personne A gagne 0 € et la Personne B gagne 0 €.'], [3, 'La Personne A gagne 3 € et la Personne B gagne 7 €.']], label="Combien la Personne A et la Personne B gagnent-elles, si la Personne A offre 3 € à la Personne B et que la Personne B rejette l'offre?", widget=widgets.RadioSelect) UG2 = models.PositiveIntegerField(choices=[[1, 'La Personne A gagne 7 € et la Personne B gagne 3 €.'], [2, 'La Personne A gagne 0 € et la Personne B gagne 0 €.'], [3, 'La Personne A gagne 3 € et la Personne B gagne 7 €.']], label="Combien la Personne A et la Personne B gagnent-elles si la Personne A offre 3 € à la Personne B et que la Personne B accepte l'offre?", widget=widgets.RadioSelect) Doubled1 = models.PositiveIntegerField(choices=[[1, 'La Personne A gagne 3 € et la Personne B gagne 7 €.'], [2, 'La Personne A gagne 7 € et la Personne B gagne 6 €.'], [3, 'La Personne A gagne 7 € et la Personne B gagne 3 €.']], label="Combien la Personne A et la Personne B gagnent-elles, si la Personne A donne 3 € à la Personne B ?", widget=widgets.RadioSelect) Doubled2 = models.PositiveIntegerField(choices=[[1, 'La Personne A gagne 3 € et la Personne B gagne 7 €.'], [2, 'La Personne A gagne 7 € et la Personne B gagne 3 €.'], [3, 'La Personne A gagne 3 € et la Personne B gagne 14 €.']], label="Combien la Personne A et la Personne B gagnent-elles, si la Personne A donne 7 € à la Personne B?", widget=widgets.RadioSelect) Half1 = models.PositiveIntegerField(choices=[[1, 'La Personne A gagne 3 € et la Personne B gagne 7 €.'], [2, 'La Personne A gagne 7 € et la Personne B gagne 1,50 €.'], [3, 'La Personne A gagne 7 € et la Personne B gagne 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, 'La Personne A gagne 3 € et la Personne B gagne 7 €.'], [2, 'La Personne A gagne 7 € et la Personne B gagne 3 €.'], [3, 'La Personne A gagne 3 € et la Personne B gagne 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 Sexe = models.StringField(widget=widgets.RadioSelectHorizontal(), choices=['Homme', 'Femme']) Age = models.IntegerField(choices=range(18, 60, 1)) Study = models.TextField(label="Quels sont votre domaine et votre niveau d'études actuels ? (exemple : Droit M1). Si vous n'étudiez pas actuellement, quelles sont vos dernières études ?") Nationality = models.TextField(label="Quelle est votre nationalité ? (Exemple : Français)") # 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="La réponse choisie est incorrecte. La bonne réponse est “La Personne A gagne 7€ et la Personne B gagne 3€“." " Rappelez-vous que la Personne A reçoit 10 €. Par conséquent, " "si la Personne A donne 3 € à la Personne B, la Personne A gagne (10 - 3) = 7 € et la Personne B gagne 3 €.", ), dict( name='b', solution=1, explanation="La réponse choisie est incorrecte. La bonne réponse est “La Personne A gagne 3€ et la" " Personne B gagne 7€“. Rappelez-vous que la Personne A reçoit 10 €. Par conséquent," " si la Personne A donne 7 € à la Personne B, la Personne A gagne (10 - 7) = 3 €" " et la Personne B gagne 7 €.", ), ] def get_quiz_dataUG(): return[ dict( name='UG1', solution=2, explanation="La réponse choisie est incorrecte. La bonne réponse est “La Personne A gagne 0 € et la Personne B gagne 0 €“." "La Personne B a rejeté l'offre. Rappelez-vous que lorsque la Personne B rejette une offre, la Personne A et la Personne B gagnent toutes deux 0 €.", ), dict( name='UG2', solution=1, explanation="La réponse choisie est incorrecte. La bonne réponse est “La Personne A gagne 7 € et la Personne B gagne 3 €“. La Personne B a accepté l'offre. Par conséquent, la Personne A gagne (10 - 3) = 7 € lorsqu'elle donne 3 € à la Personne B. La Personne B gagne 3 €.", ), ] def get_quiz_dataDoubled(): return [ dict( name='Doubled1', solution=2, explanation="La réponse choisie est incorrecte. La bonne réponse est “La Personne A gagne 7€ et la Personne B gagne 6€“. Rappelons que la Personne A reçoit 10 € et que le montant envoyé par la Personne A est doublé. Par conséquent, si la Personne A donne 3 € à la Personne B, la Personne A gagne (10 - 3) = 7 € et la Personne B gagne (3 x 2) = 6 €.", ), dict( name='Doubled2', solution=3, explanation="La réponse choisie est incorrecte. La bonne réponse est “La Personne A gagne 3 € et la Personne B gagne 14 €“. Rappelons que la Personne A reçoit 10 € et que le montant envoyé par la Personne A est doublé. Par conséquent, si la Personne A donne 7 € à la Personne B, la Personne A gagne (10 - 7) = 3 € et la Personne B gagne (7 x 2) = 14 €.", ), ] def get_quiz_dataHalf(): return [ dict( name='Half1', solution=2, explanation="La réponse choisie est incorrecte. La bonne réponse est “La Personne A gagne 7€ et la Personne B gagne 1,50€“. Rappelons que la Personne A reçoit 10 € et que la moitié du montant envoyé par la Personne A est perdue. Par conséquent, si la Personne A donne 3 € à la Personne B, la Personne A gagne (10 - 3) = 7 € et la Personne B gagne (3 x 1/2) = 1,50 €.", ), dict( name='Half2', solution=3, explanation="La réponse choisie est incorrecte. La bonne réponse est “La Personne A gagne 3 € et la Personne B gagne 3,50 €“. Rappelons que la Personne A reçoit 10 € et que la moitié du montant envoyé par la Personne A est perdue. Par conséquent, si la Personne A donne 3 € à la Personne B, la Personne A gagne (10 - 7) = 3 € et la Personne B gagne (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 = ['DB_1', 'DB_2', 'DB_3', 'DB_4', 'DB_5', 'DB_6', 'DB_7', 'DB_8', 'DB_9', 'DB_10', 'DB_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 = ['HF_1', 'HF_2', 'HF_3', 'HF_4', 'HF_5' , 'HF_6', 'HF_7', 'HF_8', 'HF_9', 'HF_10' , 'HF_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', 'Sexe', '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]