from random import randint from . import models from ._builtin import Page, WaitPage class Question(Page): form_model = 'player' def vars_for_template(self): return { 'f_news': self.player.participant.vars['f_news']} class Example(Page): form_model = 'player' def vars_for_template(self): avg_response = randint(1, 100) random_number = randint(1, 100) return { 'difference': abs(65 - avg_response), 'avg_response': avg_response, 'random_number': random_number, } def is_displayed(self): return ( self.round_number == 2 or self.round_number == 11 ) class practice1(Page): template_name = "NormElicitation/Practice.html" def vars_for_template(self): avg_response = randint(1, 100) random_number = randint(1, 100) return { 'avg_response': avg_response, 'random_number': random_number, } def is_displayed(self): return ( self.round_number == 2 ) class practice2(Page): template_name = "NormElicitation/Practice.html" def vars_for_template(self): avg_response = randint(1, 100) random_number = randint(1, 100) return { 'avg_response': avg_response, 'random_number': random_number, } def is_displayed(self): return ( self.round_number == 3 ) class practice3(Page): template_name = "NormElicitation/Practice.html" def vars_for_template(self): avg_response = randint(1, 100) random_number = randint(1, 100) return { 'avg_response': avg_response, 'random_number': random_number, } def is_displayed(self): return ( self.round_number == 4 ) class QuestionA(Question): form_fields = ["Act1", "Act2", "Act3"] def before_next_page(self): self.player.participant.vars['response1'] = self.player.Act1, self.player.participant.vars['response2'] = self.player.Act2 def is_displayed(self): return ( self.round_number == 1 or self.round_number == 13 ) class QuestionB(Question): form_fields = ["Act4", "Act5", "Act6"] def before_next_page(self): self.player.participant.vars['response3'] = self.player.Act3, self.player.participant.vars['response4'] = self.player.Act4, self.player.participant.vars['response5'] = self.player.Act5, def is_displayed(self): return ( self.round_number == 3 or self.round_number == 12 ) # class QuestionC(Question): form_fields = ["Act7", "Act8", "Act9"] template_name = 'NormElicitation/QuestionC.html' def before_next_page(self): self.player.participant.vars['response6'] = self.player.Act6, self.player.participant.vars['response7'] = self.player.Act7, self.player.participant.vars['response6'] = self.player.Act8, self.player.participant.vars['response6'] = self.player.Act9, def is_displayed(self): return ( self.round_number == 2 or self.round_number == 11 ) # class QuestionD(Question): # form_fields = ["Act9"] # # def before_next_page(self): # self.player.participant.vars['response10'] = self.player.Act10, # # self.player.participant.vars['response11'] = self.player.Act11, # # def is_displayed(self): # return ( # self.round_number == 4 or self.round_number == 11 # ) # def app_after_this_page(self, upcoming_apps): # if not self.player.participant.vars['f_news']: # return upcoming_apps[1] class HeadLine1(Page): form_model = 'player' form_fields = ['Plausibility', 'Familiarity'] def vars_for_template(self): return { 'f_news': self.player.participant.vars['f_news'], 'title': "Covid-19 News", 'button_text': "Next", } def is_displayed(self): return ( self.player.participant.vars['f_news'] and self.round_number == 5) class HeadLine2(Page): form_model = 'player' form_fields = ['Plausibility', 'Familiarity'] def vars_for_template(self): return { 'f_news': self.player.participant.vars['f_news'], 'title': "Covid-19 News", 'button_text': "Next", } def is_displayed(self): return ( self.player.participant.vars['f_news'] and self.round_number == 6 ) class HeadLine3(Page): form_model = 'player' form_fields = ['Plausibility', 'Familiarity'] def vars_for_template(self): return { 'f_news': self.player.participant.vars['f_news'], 'title': "Covid-19 News", 'button_text': "Next", } def is_displayed(self): return ( self.player.participant.vars['f_news'] and self.round_number == 7 ) class HeadLine4(Page): form_model = 'player' form_fields = ['Plausibility', 'Familiarity'] def vars_for_template(self): return { 'f_news': self.player.participant.vars['f_news'], 'title': "Covid-19 News", 'button_text': "Next", } def is_displayed(self): return ( self.player.participant.vars['f_news'] and self.round_number == 8 ) class HeadLine5(Page): form_model = 'player' form_fields = ['Plausibility', 'Familiarity'] def vars_for_template(self): return { 'f_news': self.player.participant.vars['f_news'], 'title': "Covid-19 News", 'button_text': "Next", } def is_displayed(self): return ( self.player.participant.vars['f_news'] and self.round_number == 9 ) class HeadLine6(Page): form_model = 'player' form_fields = ['Plausibility', 'Familiarity'] def vars_for_template(self): return { 'f_news': self.player.participant.vars['f_news'], 'title': "Covid-19 News", 'button_text': "Next", } def is_displayed(self): return ( self.player.participant.vars['f_news'] and self.round_number == 10 ) class QuestionPage(Page): form_model = 'player' template_name = "NormElicitation/Post_Survey.html" def vars_for_template(self): return {'title': 'A bit about you', 'f_news': self.player.participant.vars['f_news']} class First(QuestionPage): form_fields = ['gender'] def is_displayed(self): return ( (self.player.participant.vars['f_news'] is False and self.round_number == 5) or (self.player.participant.vars['f_news'] is True and self.round_number == 11) ) class Second(QuestionPage): form_fields = ['age', 'literacy'] def is_displayed(self): return ( (self.player.participant.vars['f_news'] is False and self.round_number == 6) or (self.player.participant.vars['f_news'] is True and self.round_number == 11) ) class Third(QuestionPage): form_fields = ['friend_interaction', 'family_interaction', 'colleague_interaction', 'neighbor_interaction'] def is_displayed(self): return ( (self.player.participant.vars['f_news'] is False and self.round_number == 7) or (self.player.participant.vars['f_news'] is True and self.round_number == 11) ) class Fourth(QuestionPage): form_fields = ['gen_soc_trust', 'Prosocial', ] def is_displayed(self): return ( (self.player.participant.vars['f_news'] is False and self.round_number == 8) or (self.player.participant.vars['f_news'] is True and self.round_number == 11) ) class Fifth(QuestionPage): form_fields = ['SMedia_Use_Frequency', 'SMedia_TimeSpent'] def is_displayed(self): return ( (self.player.participant.vars['f_news'] is False and self.round_number == 9) or (self.player.participant.vars['f_news'] is True and self.round_number == 11) ) class Sixth(QuestionPage): form_fields = ['Compliance', 'vaccine_status'] def is_displayed(self): return ( (self.player.participant.vars['f_news'] is False and self.round_number == 10) or (self.player.participant.vars['f_news'] is True and self.round_number == 11) ) # class PostQuestionE(Question): # form_fields = ["Act12", "Act13"] # # def before_next_page(self): # self.player.participant.vars['response1'] = self.player.Act1, # self.player.participant.vars['response2'] = self.player.Act2 # # # class PostQuestionF(Question): # form_fields = ["Act14", "Act15", "Act16"] # # def before_next_page(self): # self.player.participant.vars['response3'] = self.player.Act3, # self.player.participant.vars['response4'] = self.player.Act4, # self.player.participant.vars['response5'] = self.player.Act5, # # # # # class PostQuestionG(Question): # form_fields = ["Act17", "Act18", "Act19", "Act20"] # # def before_next_page(self): # self.player.participant.vars['response6'] = self.player.Act6, # self.player.participant.vars['response7'] = self.player.Act7, # self.player.participant.vars['response6'] = self.player.Act8, # self.player.participant.vars['response6'] = self.player.Act9, # # # class PostQuestionH(Question): # form_fields = ["Act21", "Act22"] # # def before_next_page(self): # self.player.participant.vars['response10'] = self.player.Act10, # self.player.participant.vars['response11'] = self.player.Act11, # page_sequence = [ # Norm Elicitation QuestionA, Example, practice1, QuestionC, QuestionB, # Headlines HeadLine1, HeadLine2, HeadLine3, HeadLine4, HeadLine5, HeadLine6, # Demographics First, Second, Third, Fourth, Fifth, Sixth, # PostQuestionE, # PostQuestionF, # PostQuestionG, # PostQuestionH, ]