from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random author = 'Razvan' doc = """ Attention check """ class Constants(BaseConstants): name_in_url = 'Instructions' players_per_group = None num_rounds = 4 template_instructions='attention/instructions_template.html' Number_questions=8 Correct_1=1 Correct_2=6 Correct_3=1 Correct_4=2 Correct_5=1 Correct_6=1 Correct_7=1 Correct_8=1 class Subsession(BaseSubsession): def creating_session(self): if self.round_number == 1: for p in self.get_players(): if 'treatment_info' in self.session.config: p.participant.vars['treatment_info'] = self.session.config['treatment_info'] else: p.participant.vars['treatment_info'] = random.choice([0, 1, 2]) #0=outcome only #1=outcome+effort #2=effort only class Group(BaseGroup): pass class Player(BasePlayer): payment_task = models.PositiveIntegerField() ip=models.StringField() quiz_passed = models.BooleanField() understanding_questions_wrong_attempts = models.PositiveIntegerField(initial=0) correct_answers= models.PositiveIntegerField(initial=0) question_1 = models.IntegerField(label="How will your total payoff be determined?", choices=[ [1, 'I win a bonus for each period in which I and another group member choose the common number'], [2, 'My total payoff depends only on my choices'], [3, 'My compensation in this study is fixed'], ], widget=widgets.RadioSelect ) question_2 = models.IntegerField(label="How many participants, including yourself, are in a group?", choices=[0, 2, 4, 6], widget=widgets.RadioSelect )