from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class MsQuestions1(Page): template_name = 'questionnaire/MiscQuestion1.html' form_model = 'player' form_fields = ['misc_1'] def is_displayed(self): return self.participant.vars.get('year') == 2 \ and not self.participant.vars.get('is_teacher') def vars_for_template(self): return {'specialist_subjects': Constants.miscellaneous_specialist_subjects} class MsQuestions2(Page): template_name = 'questionnaire/MiscQuestion2.html' form_model = 'player' form_fields = ['ses_term1', 'ses_term2', 'ses_term3', 'ses_no'] def is_displayed(self): return self.participant.vars.get('year') == 2 \ and not self.participant.vars.get('is_teacher') class MsQuestions3(Page): template_name = 'questionnaire/MiscQuestion3.html' form_model = 'player' form_fields = ['pfeg_term1', 'pfeg_term2', 'pfeg_term3', 'pfeg_no'] def is_displayed(self): return self.participant.vars.get('year') == 2 \ and not self.participant.vars.get('is_teacher') class MsQuestions4(Page): template_name = 'questionnaire/MiscQuestion4.html' form_model = 'player' form_fields = ['misc_4'] def is_displayed(self): return not self.participant.vars.get('is_teacher') def vars_for_template(self): return {'specialist_uni': Constants.miscellaneous_specialist_uni} class MsQuestions5(Page): template_name = 'questionnaire/MiscQuestion5.html' form_model = 'player' form_fields = ['misc_5'] def is_displayed(self): return not self.participant.vars.get('is_teacher') class MsQuestions6(Page): template_name = 'questionnaire/MiscQuestion6.html' form_model = 'player' form_fields = ['misc_6'] def is_displayed(self): return not self.participant.vars.get('is_teacher') class MsQuestions7(Page): template_name = 'questionnaire/MiscQuestion7.html' form_model = 'player' form_fields = ['misc_7'] def is_displayed(self): if not self.participant.vars.get('is_teacher') and self.participant.vars.get('classmates'): return True else: return False def vars_for_template(self): self.participant.vars.get('classmates').sort() return {'network': self.participant.vars.get('classmates')} class MsQuestions8(Page): template_name = 'questionnaire/MiscQuestion8.html' form_model = 'player' form_fields = ['misc_8', 'misc_9'] def is_displayed(self): return not self.participant.vars.get('is_teacher') def vars_for_template(self): return {'newspapers': Constants.miscellaneous_newspapaers} class MsQuestions9(Page): template_name = 'questionnaire/MiscQuestion9.html' form_model = 'player' form_fields = ['misc_10'] def vars_for_template(self): touch = False if self.participant.vars.setdefault('is_mobile', self.request.user_agent.is_mobile) or \ self.participant.vars.setdefault('is_tablet', self.request.user_agent.is_tablet): touch = True return {'touch': touch} def is_displayed(self): return not self.participant.vars.get('is_teacher') class TaskF(Page): template_name = 'questionnaire/FinancialLiteracy.html' form_model = 'player' form_fields = [f'financial_{n}' for n in range(len(Constants.financial_questions))] def is_displayed(self): return not self.participant.vars.get('is_teacher') class TaskChD(Page): template_name = 'questionnaire/CharityDonation.html' form_model = 'player' form_fields = ['charity_decision', 'charity_amount', 'charity_name'] def is_displayed(self): return not self.participant.vars.get('is_creteil') def vars_for_template(self): return {'total_credits_so_far': self.participant.payoff} page_sequence = [ MsQuestions1, MsQuestions2, MsQuestions3, MsQuestions4, MsQuestions5, MsQuestions6, MsQuestions7, MsQuestions8, MsQuestions9, TaskF, TaskChD, ]