from otree.api import Currency as c, currency_range from . import models from ._builtin import Page, WaitPage from .models import Constants from django.http.response import HttpResponseRedirect def vars_for_all_templates(self): """ get variables from session configs level """ return { 'radio_amounts': zip(Constants.list2, Constants.list1), 'additional_radio': range(0, 11, 1), 'total_fixed_payment': c(self.session.config['participation_fee'] + self.session.config['completion_award']), 'participation_fee': c(self.session.config['participation_fee']), } class EndQuestions(Page): def is_displayed(self): return self.participant.vars['tests_passed'] form_model = 'player' form_fields = ['end_qn_1', 'end_qn_2', 'end_qn_3'] class RepeatedCheck(Page): def is_displayed(self): return self.participant.vars['tests_passed'] form_model = 'player' form_fields = ['repeated_check'] class FinishedTasks(Page): def is_displayed(self): return self.participant.vars['tests_passed'] class Debriefing(Page): def is_displayed(self): return not self.participant.vars['failed_attention'] def before_next_page(self): if self.participant.vars['tests_passed']: self.participant.payoff = self.session.config['completion_award'] self.player.bonus_amount = self.session.config['completion_award'] if self.participant.vars['timeout_once']: self.player.bonus_amount -= self.session.config['timeout_penalty'] self.player.completed = self.participant.vars['completed'] self.player.failed_comprehension = self.participant.vars['failed_comprehension'] class PayoffandGoodbye(Page): def vars_for_template(self): return { 'total_payment': self.session.config['participation_fee'] + self.player.bonus_amount, } class ToProlific(Page): def is_displayed(self): return self.participant.vars['completed'] page_sequence = [ EndQuestions, RepeatedCheck, Debriefing, PayoffandGoodbye, ToProlific ]