from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random author = 'Your name here' doc = """ Your app description """ import random class Constants(BaseConstants): name_in_url = 'its' players_per_group = 4 num_rounds = 1 class Subsession(BaseSubsession): def creating_session(self): self.group_randomly() Player.c1 = 0 pass class Group(BaseGroup): pass class Player(BasePlayer): #name #email email1 = models.StringField(label = "EMAIL (For Amazon eGift card)") email2 = models.StringField(label = "CONFIRM EMAIL (For Amazon eGift card)") #answer for the five quetions option1 = models.IntegerField(label = 'Please make your decision:', choices = [ [1, 'Option A'], [2, 'Option B'] ], widget=widgets.RadioSelect ) option2 = models.IntegerField(label = 'Please make your decision:', choices = [ [1, 'Option A'], [2, 'Option B'] ], widget=widgets.RadioSelect ) option3 = models.IntegerField(label = 'Please make your decision:', choices = [ [1, 'Option A'], [2, 'Option B'] ], widget=widgets.RadioSelect ) option4 = models.IntegerField(label = 'Please make your decision:', choices = [ [1, 'Option A'], [2, 'Option B'] ], widget=widgets.RadioSelect ) option5 = models.IntegerField(label = 'Please make your decision:', choices = [ [1, 'Option A'], [2, 'Option B'] ], widget=widgets.RadioSelect ) optionah = models.IntegerField(label = 'If Coin 1 lands on H, please make your decision:', choices = [ [1, 'Option A'], [2, 'Option B'] ], widget=widgets.RadioSelect ) optionat = models.IntegerField(label = 'If Coin 1 lands on T, please make your decision:', choices = [ [1, 'Option A'], [2, 'Option B'] ], widget=widgets.RadioSelect ) #payments #deciding question to pay qtp = models.IntegerField() qtp2 = models.IntegerField() #recording subjects' decisions for the question to pay dtp = models.StringField() dtph = models.StringField() dtpt = models.StringField() #deciding random coin flip numbs = models.IntegerField() coin1 = models.IntegerField() coin2 = models.IntegerField() #deciding two payments payA = models.IntegerField() payB = models.IntegerField() #deciding chance event = models.StringField() #recording answers for instruction tests test_q1 = models.StringField() test_q2 = models.StringField() #deciding order of appearances of the five questions o_1 = models.IntegerField() o_2 = models.IntegerField() o_3 = models.IntegerField() o_4 = models.IntegerField() o_5 = models.IntegerField() o_a = models.IntegerField() #recording participant choices for specific question c1 = models.IntegerField() c2 = models.IntegerField() c3 = models.IntegerField() c4 = models.IntegerField() c5 = models.IntegerField() cch = models.IntegerField() cct = models.IntegerField() #deciding participant option appearance order s1 = models.IntegerField() s2 = models.IntegerField() s3 = models.IntegerField() s4 = models.IntegerField() s5 = models.IntegerField() sc = models.IntegerField() #recording option appearnce order for the qtp ss = models.IntegerField() def set_error_message(self,value): correct_answers = { "test_q1" : '5', "test_q2" : '15', } list_answers = list(value.items())[0:] list_correct_answers = list(correct_answers.items()) if list_answers != list_correct_answers: self.test_q1 = ' ' self.test_q2 = ' ' Text = 'You did not answer all questions correctly. Please read the instructions again and correct your answers.' return Text