from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, safe_json ) import random import numpy as np import math author = 'Zheng Li' doc = """ Calculate payoff for study """ class Constants(BaseConstants): name_in_url = 'ending_multipart_2' players_per_group = None num_rounds = 1 # to generate the certainty-uncertainty spectrum bar list1 = np.arange(1 * 20, - 1, -1) list2 = [] list2.append(0) for x in range(20): list2.append((x + 1) * 5) class Subsession(BaseSubsession): pass class Group(BaseGroup): """Contains group-level objects of the current experiment app.""" pass class Player(BasePlayer): bonus_amount = models.CurrencyField() tests_passed = models.BooleanField(initial=True) completed = models.IntegerField(initial=0) invited = models.IntegerField(initial=0) failed_comprehension = models.BooleanField() end_qn_1 = models.IntegerField( widget=widgets.RadioSelect, choices=[ [1, 'You'], [2, 'You'] ] ) end_qn_2 = models.IntegerField() end_qn_3 = models.IntegerField() # repeated question repeated_check = models.FloatField( blank=False, label="" ) income_guess = models.IntegerField( label="Please provide your best guess of your annual household income:", blank=False ) def set_comprehension(self): self.failed_comprehension = self.participant.vars['failed_comprehension'] def set_payoff(self): self.participant.payoff = self.session.config['completion_award'] self.bonus_amount = self.session.config['completion_award']