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 = 'quiz' location = 'game_quiz' players_per_group = None num_rounds = 1 action_labels = ['Y','W'] # labels for the player's actions quiz_info = location + '/quiz_info.html' quiz_example = location + '/quiz_example.html' payoff_table = location + '/payoff_table.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 = { 'PD': [[3,1,4,2],[3,1,4,2]], # [[P11_1,P12_1,P21_1,P22_1],[P11_2,P12_2,P21_2,P22_2]]] 'PD2': [[3,-1,4,2],[3,-1,4,2]], # [[P11_1,P12_1,P21_1,P22_1],[P11_2,P12_2,P21_2,P22_2]]] 'BO': [[1,2,4,1],[1,2,4,1]], 'SH': [[3,0,2,1],[3,0,2,1]], 'CH': [[3,1,4,0],[3,1,4,0]], 'CI': [[3,1,2,0],[3,1,2,0]], 'SD': [[2,2,5,3],[2,3,2,5]], 'SD2': [[1,1,4,2],[1,2,1,6]], 'UM': [[4,1,1,2],[1,2,2,1]], 'UL': [[2,2,3,1],[2,1,2,0]], 'SH2': [[4,0,2,1],[3,0,2,1]], 'ex': [[6,7,4,1],[5,2,3,8]], } class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): decision_time = models.IntegerField() # decision time in seconds pmat = models.StringField() # payoff matrix used in the quiz 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}