from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Introduction(Page): pass class Quiz(Page): form_model = 'player' form_fields = ['Quiz11','Quiz12','Quiz21','Quiz22','Quiz31','Quiz32','Quiz41','Quiz42','Quiz51','Quiz52','Quiz6'] def Quiz11_error_message(self, value): print('value is', value) is_correct = (value == 21) if not (is_correct): return 'Your answer is wrong' def Quiz12_error_message(self, value): print('value is', value) is_correct = (value == 21) if not (is_correct): return 'Your answer is wrong' def Quiz21_error_message(self, value): print('value is', value) is_correct = (value == 21) if not (is_correct): return 'Your answer is wrong' def Quiz22_error_message(self, value): print('value is', value) is_correct = (value == 21) if not (is_correct): return 'Your answer is wrong' def Quiz31_error_message(self, value): print('value is', value) is_correct = (value == 9) if not (is_correct): return 'Your answer is wrong' def Quiz32_error_message(self, value): print('value is', value) is_correct = (value == 42) if not (is_correct): return 'Your answer is wrong' def Quiz41_error_message(self, value): print('value is', value) is_correct = (value == 9) if not (is_correct): return 'Your answer is wrong' def Quiz42_error_message(self, value): print('value is', value) is_correct = (value == 30) if not (is_correct): return 'Your answer is wrong' def Quiz51_error_message(self, value): print('value is', value) is_correct = (value == 45) if not (is_correct): return 'Your answer is wrong' def Quiz52_error_message(self, value): print('value is', value) is_correct = (value == 30) if not (is_correct): return 'Your answer is wrong' def Quiz6_error_message(self, Strings): print('Strings is', Strings) is_correct = (Strings == "ABCD") if not (is_correct): return 'Your answer is wrong' class Quizwait(WaitPage): wait_for_all_groups = True class Bsendmessage(Page): """This page is only for B B sends message to A B: send a message """ form_model = 'group' form_fields = ['message'] def is_displayed(self): return self.player.id_in_group == 2 class MessageWaitPage(WaitPage): body_text = "You are Participant A, Please wait for B to write a message." wait_for_all_groups = True def is_displayed(self): return self.player.id_in_group == 1 class Areceivedmessage(Page): """This page is only for A A received the message from B""" def is_displayed(self): return self.player.id_in_group == 1 class A_decision(Page): form_model = 'player' form_fields = ['Invest'] def is_displayed(self): return self.player.id_in_group == 1 class Investwaitpage(WaitPage): wait_for_all_groups = True class B_decision1(Page): form_model = 'player' form_fields = ['Roll'] def is_displayed(self): return self.player.id_in_group == 2 class B_decision2(Page): form_model = 'player' form_fields = ['Dice'] def is_displayed(self): return self.player.id_in_group == 2 class Rollwaitpage(WaitPage): wait_for_all_groups = True class TaskresultsWaitPage(WaitPage): def after_all_players_arrive(self): playerA,playerB = self.group.get_players() if playerA.Invest == 0: playerA.taskpayoffs = Constants.A_out_payoff playerB.taskpayoffs = Constants.B_out_payoff if playerA.Invest == 1: if playerB.Roll == 0: playerA.taskpayoffs = Constants.A_dontroll_payoff playerB.taskpayoffs = Constants.B_dontroll_payoff if playerB.Roll == 1: if playerB.Dice == 1 or 2: playerA.taskpayoffs = Constants.A_succeed_payoff playerB.taskpayoffs = Constants.B_roll_payoff if playerB.Dice == 3 or 4 or 5 or 6: playerA.taskpayoffs = Constants.A_failed_payoff playerB.taskpayoffs = Constants.B_roll_payoff class Elicit_A1page(Page): form_model = 'player' form_fields = ['Elicit_A1'] def is_displayed(self): return self.player.id_in_group == 1 class Elicit_A2page(Page): form_model = 'player' form_fields = ['Elicit_A2'] def is_displayed(self): return self.player.id_in_group == 1 class Elicit_A3page(Page): form_model = 'player' form_fields = ['Elicit_A3'] def is_displayed(self): return self.player.id_in_group == 1 class Elicit_B1page(Page): form_model = 'player' form_fields = ['Elicit_B1'] def is_displayed(self): return self.player.id_in_group == 2 class Elicit_B2page(Page): form_model = 'player' form_fields = ['Elicit_B2'] def is_displayed(self): return self.player.id_in_group == 2 class Elicit_B3page(Page): form_model = 'player' form_fields = ['Elicit_B3'] def is_displayed(self): return self.player.id_in_group == 2 class Elicit_B4page(Page): form_model = 'player' form_fields = ['Elicit_B4'] def is_displayed(self): return self.player.id_in_group == 2 class Elicit_AB1page(Page): form_model = 'player' form_fields = ['Elicit_AB1'] class Elicit_AB2page(Page): form_model = 'player' form_fields = ['Elicit_AB2'] class Elicitwaitpage(WaitPage): wait_for_all_groups = True class Elicitwaitpage2(WaitPage): def after_all_players_arrive(self): self.subsession.set_rate_broll() self.subsession.set_elicita1_payoffs() self.subsession.set_rate_bsucceed() self.subsession.set_elicita2_payoffs() self.subsession.set_rate_ain() self.subsession.set_elicitb1_payoffs() self.subsession.set_elicita1_inavg() self.subsession.set_elicitb2_payoffs() self.subsession.set_elicita2_inavg() self.subsession.set_elicitb3_payoffs() self.subsession.set_elicita3_inavg() self.subsession.set_elicitb4_payoffs() self.subsession.set_elicitab1_most() self.subsession.set_elicitab1_payoffs() self.subsession.set_elicitab2_most() self.subsession.set_elicitab2_payoffs() class Taskresult(Page): form_model = 'player' form_fields = ['task2payoffs'] class Survey_C(Page): form_model = 'player' form_fields = ['Survey_C_1', 'Survey_C_2', 'Survey_C_3', 'Survey_C_4', 'Survey_C_5', 'Survey_C_6', 'Survey_C_7', 'Survey_C_8', 'Survey_C_9', 'Survey_C_10', ] class Survey_M(Page): form_model = 'player' form_fields = ['Survey_M_1', 'Survey_M_2', 'Survey_M_3', 'Survey_M_4', 'Survey_M_5', 'Survey_M_6', 'Survey_M_7', 'Survey_M_8','Survey_M_9','Survey_M_10', 'Survey_M_11', 'Survey_M_12', 'Survey_M_13', 'Survey_M_14', 'Survey_M_15', 'Survey_M_16', 'Survey_M_17', 'Survey_M_18','Survey_M_19','Survey_M_20', ] class Survey_D(Page): form_model = 'player' form_fields = ['Survey_D_1', 'Survey_D_2', 'Survey_D_3', 'Survey_D_4', 'Survey_D_5', 'Survey_D_6'] class Resultwaitpage2(WaitPage): wait_for_all_groups = True def after_all_players_arrive(self): self.player.set_payoffs() class ResultofA(Page): def is_displayed(self): return self.player.id_in_group == 1 class ResultofB(Page): def is_displayed(self): return self.player.id_in_group == 2 page_sequence = [ Quiz, Quizwait, Bsendmessage, MessageWaitPage, Areceivedmessage, A_decision, Investwaitpage, B_decision1, B_decision2, Rollwaitpage, TaskresultsWaitPage, Elicit_A1page, Elicit_A2page, Elicit_A3page, Elicit_B1page, Elicit_B2page, Elicit_B3page, Elicit_B4page, Elicit_AB1page, Elicit_AB2page, Elicitwaitpage, Elicitwaitpage2, Taskresult, Survey_C, Survey_M, Survey_D, ResultofA, ResultofB, ]