from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants from . import models from django.views.decorators.csrf import csrf_exempt from django.utils.decorators import method_decorator from otree.api import safe_json import random class Task2_P0_WaitingPage(Page): form_model = 'player' form_fields = ['continue10'] def error_message(self, values): print('value is', values) if not values["continue10"] == 400: return 'This is not the number given to you. Please raise your hand for assistance.' class Task2_P1_Instructions_Before(Page): form_model = 'player' form_fields = ['continue3','checkurnF1'] def error_message(self, values): print('value is', values) if not values["continue3"] == 30: return 'This is not the number given to you. Please raise your hand for assistance.' def before_next_page(self): self.player.set_variables_previousapp() #Function that sets initial value of the prior at random# self.player.set_initial () self.player.set_initial1 () self.player.set_initial2 () class Task2_P1_Belief_Prior(Page): form_model = 'player' form_fields = ['choice_prior_x'] def before_next_page(self): #Function that set the slider initial value at previous elicited belief# self.player.set_initial_posterior1() class NormalWaitPage1(WaitPage): title_text = "Wait Page" def after_all_players_arrive(self): self.group.set_teammate_exchangeofvariables() class Task2_P1_Instructions_AfterPrior_Feedback(Page): form_model = 'player' form_fields = ['continue4'] def error_message(self, values): print('value is', values) if not values["continue4"] == 40: return 'This is not the number given to you. Please raise your hand for assistance.' #class Task2_P1_Instructions_Partnering(Page): # form_model = 'player' # form_fields = ['choice_feedback'] class Task2_P1_Instructions_AfterPrior_Feedback_CQ (Page): form_model = 'player' form_fields = ['Task2b_P1_CQ1', 'Task2b_P1_CQ2', 'Task2b_P1_CQ3', 'Task2b_P1_CQ4','Task2b_P1_CQ5'] def error_message(self, values): print ('values is', values) if values["Task2b_P1_CQ1"] != 3 or values["Task2b_P1_CQ2"] != 3 or values["Task2b_P1_CQ3"] != 3 or values["Task2b_P1_CQ4"] !=3 or values["Task2b_P1_CQ5"] !=1: return 'There is at least one incorrect answer. Please, reconsider.' class AllGroupsWaitPage1(WaitPage): wait_for_all_groups = True class NormalWaitPageAll(WaitPage): title_text = "Wait Page" def after_all_players_arrive(self): self.group.set_choice_partner() class Task2_P1_DecisionFeedback(Page): form_model = 'player' form_fields = ['choice_feedback'] def before_next_page(self): self.player.feedbackmode() self.player.feedbackmode1() self.player.def_signal_own() class NormalWaitPage2(WaitPage): title_text = "Wait Page" def after_all_players_arrive(self): self.group.set_choice_partner() class Task2_P1_Fast(Page): timeout_seconds = 0 def before_next_page(self): self.player.def_signal_partner() #self.player.choice_feedback_partner() class Task2_P1_Judgment_1(Page): form_model = 'player' form_fields = ['choice_prior_partner'] def is_displayed(self): return self.player.choice_feedback_partner == 1 def vars_for_template(self): return { 'signal1': self.player.signal_partner, } class Task2_P1_Judgment_2(Page): form_model = 'player' form_fields = ['choice_prior_partner'] def is_displayed(self): return self.player.choice_feedback_partner == 2 def vars_for_template(self): return { 'signal1': self.player.signal_partner, } class NormalWaitPage3(WaitPage): title_text = "Wait Page" def after_all_players_arrive(self): self.group.set_choice_judgment() class Task2_P1_Belief_Posterior(Page): form_model = 'player' form_fields = ['choice_posterior1_x','checkurnF2'] def vars_for_template(self): return { 'signal1': self.player.signal_own, 'urn': self.player.feedbackmode, } class AllGroupsWaitPage2(WaitPage): wait_for_all_groups = True class Task3_Instructions(Page): form_model = 'player' form_fields = ['continue8'] def error_message(self, values): print('value is', values) if not values["continue8"] == 150: return 'This is not the number given to you. Please raise your hand for assistance.' def before_next_page(self): #Functions to calculate the payoffs regarding the beliefs# self.player.set_payoff_prior(), self.player.set_payoff_posterior1() class Task3_PostQuestions(Page): form_model = models.Player form_fields = ['Task3_PQ1'] def vars_for_template(self): return { 'chosen': self.player.feedbackmode, 'notchosen': self.player.feedbackmode1, } class Task3_GPtask(Page): form_model = models.Player form_fields = ['choice_risk'] def before_next_page(self): self.player.set_payoff_risk() self.player.set_payoff() def error_message(self, values): print('value is', values) if values["choice_risk"] < 0 or values["choice_risk"]>100: return 'Please insert a number between 0 and 100.' class Task3_Quest1 (Page): form_model = 'player' form_fields = ['Q1a','Q2a','Q3a','Q4a','Q5a','Q6a','Q7a','Q8a','Q9a','Q10a', 'Q1b', 'Q2b', 'Q3b', 'Q4b', 'Q5b', 'Q6b', 'Q7b', 'Q8b', 'Q9b', 'Q10b', 'Q2c','Q5c','Q6c','Q9c','Q10c'] class Task3_Demographics(Page): form_model = 'player' form_fields = ['Gender','Gender1','Age','Language','Country','Ethnicity','Education','Department', 'Experiments','Experiments1','Risk'] class Task3_FinalSlide(Page): pass page_sequence = [ Task2_P0_WaitingPage, Task2_P1_Instructions_Before, Task2_P1_Belief_Prior, NormalWaitPage1, Task2_P1_Instructions_AfterPrior_Feedback, #Task2_P1_Instructions_Partnering, Task2_P1_Instructions_AfterPrior_Feedback_CQ, AllGroupsWaitPage1, Task2_P1_DecisionFeedback, NormalWaitPage2, Task2_P1_Fast, Task2_P1_Judgment_1, Task2_P1_Judgment_2, NormalWaitPage3, Task2_P1_Belief_Posterior, AllGroupsWaitPage2, Task3_Instructions, Task3_PostQuestions, Task3_GPtask, Task3_Quest1, Task3_Demographics, Task3_FinalSlide ]