#from otree.api import Currency as c, currency_range #from ._builtin import Page, WaitPage #from .models import Constants from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants from otree.models import Participant import csv class Part1PlayDG1(Page): def is_displayed(self): return self.round_number == self.participant.vars['task_rounds']['DG1'] form_model = 'player' form_fields = ['decision_1'] def before_next_page(self): self.participant.vars['DG_dec1'] = self.player.decision_1 self.player.part_label = str(self.participant.label) class Part1PlayDG2(Page): def is_displayed(self): return self.round_number == self.participant.vars['task_rounds']['DG2'] form_model = 'player' form_fields = ['decision_2'] def before_next_page(self): self.participant.vars['DG_dec2'] = self.player.decision_2 class Part1PlayDG3(Page): def is_displayed(self): return self.round_number == self.participant.vars['task_rounds']['DG3'] form_model = 'player' form_fields = ['decision_3'] def before_next_page(self): self.participant.vars['DG_dec3'] = self.player.decision_3 class Part1PlayDG4(Page): def is_displayed(self): return self.round_number == self.participant.vars['task_rounds']['DG4'] form_model = 'player' form_fields = ['decision_4'] def before_next_page(self): self.participant.vars['DG_dec4'] = self.player.decision_4 class Part1PlayDG5(Page): def is_displayed(self): return self.round_number == self.participant.vars['task_rounds']['DG5'] form_model = 'player' form_fields = ['decision_5'] def before_next_page(self): self.participant.vars['DG_dec5'] = self.player.decision_5 class Part1PlayDG6(Page): def is_displayed(self): return self.round_number == self.participant.vars['task_rounds']['DG6'] form_model = 'player' form_fields = ['decision_6'] def before_next_page(self): self.participant.vars['DG_dec6'] = self.player.decision_6 class Part1PlayDG7(Page): def is_displayed(self): return self.round_number == self.participant.vars['task_rounds']['DG7'] form_model = 'player' form_fields = ['decision_7'] def before_next_page(self): self.participant.vars['DG_dec7'] = self.player.decision_7 class Part1PlayDG8(Page): def is_displayed(self): return self.round_number == self.participant.vars['task_rounds']['DG8'] form_model = 'player' form_fields = ['decision_8'] def before_next_page(self): self.participant.vars['DG_dec8'] = self.player.decision_8 class Part1PlayDG9(Page): def is_displayed(self): return self.round_number == self.participant.vars['task_rounds']['DG9'] form_model = 'player' form_fields = ['decision_9'] def before_next_page(self): self.participant.vars['DG_dec9'] = self.player.decision_9 class Part1PlayDG10(Page): def is_displayed(self): return self.round_number == self.participant.vars['task_rounds']['DG10'] form_model = 'player' form_fields = ['decision_10'] def before_next_page(self): self.participant.vars['DG_dec10'] = self.player.decision_10 # class End(Page): # def is_displayed(self): # return self.round_number == Constants.num_rounds # # def before_next_page(self): # self.participant.vars['part_label'] = str(self.participant.label) # self.player.part_label = str(self.participant.label) # # ps = Participant.objects.all() # all_participant_vars = [p.vars for p in ps] # all_participant_codes = [{'participant_code': p.code, 'session_code': p.session.code} for p in ps] # # for i in range(0, len(all_participant_vars)): # all_participant_vars[i].update(all_participant_codes[i]) # # csv_columns = ['DG_dec1', 'DG_dec2', 'DG_dec3', 'DG_dec4', 'DG_dec5', 'part_label', 'label'] # # with open('survey_draft1b/part_vars_DGplay.csv', 'w') as csvfile: # writer = csv.DictWriter(csvfile, fieldnames=csv_columns, extrasaction='ignore') # writer.writeheader() # for data in all_participant_vars: # writer.writerow(data) page_sequence = [ Part1PlayDG1, Part1PlayDG2, Part1PlayDG3, Part1PlayDG4, Part1PlayDG5, Part1PlayDG6, Part1PlayDG7, Part1PlayDG8, Part1PlayDG9, Part1PlayDG10 #End ] #class MyPage(Page): # pass #class ResultsWaitPage(WaitPage): # def after_all_players_arrive(self): # pass #class Results(Page): # pass #page_sequence = [MyPage, ResultsWaitPage, Results]