from ._builtin import Page, WaitPage from .models import Constants import json import random ######################## ## INTRO ## ######################## class Introduction(Page): form_model = 'player' form_fields = ['consent', 'recontact'] def before_next_page(self): self.player.setting_labels() ######################## ## READING ARTICLE ## ######################## # PRIOR PREDICTIONS class Prior(Page): form_model = 'player' form_fields = ['prior_prediction', 'prior_conf'] def vars_for_template(self): if self.player.econ_topic == 1: return dict( prior_prediction_label='What do you think, how will the German Stock Market Index DAX develop over the next month?' ) else: return dict( prior_prediction_label='What do you think, how will the number of Covid 19 cases develop over the next month?' ) # ACTUAL ARTICLE TO READ class Article(Page): pass # CONTROLS QUESTIONS class ControlQuestions(Page): form_model = 'player' form_fields = ['control_1', 'control_2', 'control_3'] def vars_for_template(self): if self.player.econ_topic == 1: return dict( L1='Control Question Econ 1?', L2='Control Question Econ 2?', L3='Control Question Econ 3?' ) else: return dict( L1='Control Question Covid 1?', L2='Control Question Covid 2?', L3='Control Question Covid 3?' ) def before_next_page(self): self.player.payoffs_() # RATING OF ARTICLES class ArticleRating(Page): form_model = 'player' form_fields = ['skew', 'reliance', 'inspiring', 'objectivity', 'helpful'] random.shuffle(form_fields) # POSTERIOR PREDICTION class Posterior(Page): form_model = 'player' form_fields = ['post_prediction', 'post_conf'] def vars_for_template(self): if self.player.econ_topic == 1: return dict( post_prediction_label='What do you think, how will the German Stock Market Index DAX develop over the next month?', prior=self.participant.vars['labels_'][self.player.prior_prediction]) else: return dict( post_prediction_label='What do you think, how will the number of Covid19 cases develop over the next month?', prior=self.participant.vars['labels_'][self.player.prior_prediction]) ######################## ## QUESTIONNAIRE ## ######################## class Questionnaire(Page): form_model = 'player' form_fields = ['rosen_1', 'rosen_2', 'rosen_3', 'rosen_4', 'rosen_5', 'rosen_6', 'rosen_7', 'rosen_8', 'rosen_9', 'rosen_10',] random.shuffle(form_fields) ######################## ## ARTICLE SUMMARY ## ######################## class Summary(Page): form_model = 'player' form_fields = ['summary_', 'conf_'] ######################## ## RESULTS ## ######################## class Results(Page): def vars_for_template(self): return dict(corr_answers=self.participant.vars['correct_answers'], corr_income=self.participant.vars['income_answers']) ########################################## ##### APP SEQUENCE ##### ########################################## page_sequence = [Introduction, Prior, Article, ArticleRating, ControlQuestions, Posterior, Summary, Questionnaire, Results]