from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) author = 'Huanren Zhang' doc = """ Quiz questions for the games """ class Constants(BaseConstants): name_in_url = 'esbsac' location = 'games_quiz' players_per_group = None num_rounds = 1 action_labels = ['T','S'] # labels for the player's actions quiz_info = location + '/quiz_info.html' quiz_example = location + '/quiz_example.html' payoff_table_template = location + '/payoff_table.html' payoff_matrix_template = location + '/payoff_matrix.html' instructions_template = location + '/instructions_template.html' instructions_template1 = location + '/instructions_template1.html' instructions_template2 = location + '/instructions_template2.html' # quiz_minutes = 5 # minutes allowed in finishing the quiz quesitons # num_interactions = 1 # number of interactions # payoff matrix for each interaction payoff_matrix = { 'sym': [[-1, 10, 0, -1], [ -1, 10, 0 ,-1]], # [[P11_1,P12_1,P21_1,P22_1],[P11_2,P12_2,P21_2,P22_2]]] 'asym': [[-1, 20, 0, -1], [ -1, 10, 0 ,-1]], # [[P11_1,P12_1,P21_1,P22_1],[P11_2,P12_2,P21_2,P22_2]]] } class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): decision_time = models.IntegerField() # decision time in seconds sym = models.BooleanField() termination = models.BooleanField() distancing = models.BooleanField() matrix_rep = models.BooleanField(initial=False) wrong_attempts = models.PositiveIntegerField(initial=0) # number of wrong attempts on understanding questions page qualified = models.BooleanField(initial=False) def live_attempt(self, data): if data != 'initialization': self.wrong_attempts += 1 print('received message from page', data) print({self.id_in_group: self.wrong_attempts}) return {self.id_in_group: self.wrong_attempts}