from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random class Constants(BaseConstants): name_in_url = 'SB2_CT' players_per_group = None num_rounds = 1 instructions_template = 'SB2_CT/Instructions.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): def set_payoffs(self): all_players = self.get_players() correct1 = [m for m in all_players if m.ct_1 == 4] correct2 = [m for m in all_players if m.ct_2 == 3] correct3 = [m for m in all_players if m.ct_3 == 2] correct4 = [m for m in all_players if m.ct_4 == 2] correct5 = [m for m in all_players if m.ct_5 == 3] correct6 = [m for m in all_players if m.ct_6 == 5] correct7 = [m for m in all_players if m.ct_7 == 4] correct8 = [m for m in all_players if m.ct_8 == 1] correct9 = [m for m in all_players if m.ct_9 == 5] correct10 = [m for m in all_players if m.ct_10 == 4] correct11 = [m for m in all_players if m.ct_11 == 5] for a in correct1: a.c_ct_1 = 1 for b in correct2: b.c_ct_2 = 1 for c in correct3: c.c_ct_3 = 1 for d in correct4: d.c_ct_4 = 1 for e in correct5: e.c_ct_5 = 1 for f in correct6: f.c_ct_6 = 1 for g in correct7: g.c_ct_7 = 1 for h in correct8: h.c_ct_8 = 1 for i in correct9: i.c_ct_9 = 1 for j in correct10: j.c_ct_10 = 1 for k in correct11: k.c_ct_11 = 1 for m in all_players: m.correct_num = m.c_ct_1 + m.c_ct_2 + m.c_ct_3 + m.c_ct_4 + m.c_ct_5 + m.c_ct_6 + m.c_ct_7 + m.c_ct_8 + m.c_ct_9 + m.c_ct_10 + m.c_ct_11 m.payoff = m.correct_num * 100 class Player(BasePlayer): ct_1 = models.IntegerField( blank=True, choices=[ [1, 'A'],[2, 'B'],[3, 'C'],[4, 'D'],[5, 'E'],[6, 'F'] ], widget=widgets.RadioSelectHorizontal, label='問1') ct_2 = models.IntegerField( blank=True, choices=[ [1, 'A'],[2, 'B'],[3, 'C'],[4, 'D'],[5, 'E'],[6, 'F'] ], widget=widgets.RadioSelectHorizontal, label='問2') ct_3 = models.IntegerField( blank=True, choices=[ [1, 'A'],[2, 'B'],[3, 'C'],[4, 'D'],[5, 'E'],[6, 'F'] ], widget=widgets.RadioSelectHorizontal, label='問3') ct_4 = models.IntegerField( blank=True, choices=[ [1, 'A'],[2, 'B'],[3, 'C'],[4, 'D'],[5, 'E'],[6, 'F'] ], widget=widgets.RadioSelectHorizontal, label='問4') ct_5 = models.IntegerField( blank=True, choices=[ [1, 'A'],[2, 'B'],[3, 'C'],[4, 'D'],[5, 'E'],[6, 'F'] ], widget=widgets.RadioSelectHorizontal, label='問5') ct_6 = models.IntegerField( blank=True, choices=[ [1, 'A'],[2, 'B'],[3, 'C'],[4, 'D'],[5, 'E'],[6, 'F'] ], widget=widgets.RadioSelectHorizontal, label='問6') ct_7 = models.IntegerField( blank=True, choices=[ [1, 'A'],[2, 'B'],[3, 'C'],[4, 'D'],[5, 'E'],[6, 'F'] ], widget=widgets.RadioSelectHorizontal, label='問7') ct_8 = models.IntegerField( blank=True, choices=[ [1, 'A'],[2, 'B'],[3, 'C'],[4, 'D'],[5, 'E'],[6, 'F'] ], widget=widgets.RadioSelectHorizontal, label='問8') ct_9 = models.IntegerField( blank=True, choices=[ [1, 'A'],[2, 'B'],[3, 'C'],[4, 'D'],[5, 'E'],[6, 'F'] ], widget=widgets.RadioSelectHorizontal, label='問9') ct_10 = models.IntegerField( blank=True, choices=[ [1, 'A'],[2, 'B'],[3, 'C'],[4, 'D'],[5, 'E'],[6, 'F'] ], widget=widgets.RadioSelectHorizontal, label='問10') ct_11 = models.IntegerField( blank=True, choices=[ [1, 'A'],[2, 'B'],[3, 'C'],[4, 'D'],[5, 'E'],[6, 'F'] ], widget=widgets.RadioSelectHorizontal, label='問11') c_ct_1 = models.IntegerField(initial=0) c_ct_2 = models.IntegerField(initial=0) c_ct_3 = models.IntegerField(initial=0) c_ct_4 = models.IntegerField(initial=0) c_ct_5 = models.IntegerField(initial=0) c_ct_6 = models.IntegerField(initial=0) c_ct_7 = models.IntegerField(initial=0) c_ct_8 = models.IntegerField(initial=0) c_ct_9 = models.IntegerField(initial=0) c_ct_10 = models.IntegerField(initial=0) c_ct_11 = models.IntegerField(initial=0) correct_num = models.IntegerField(initial=0)