from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, safe_json ) import random import numpy as np from django import forms from django.forms import widgets as django_widgets import math author = 'Zheng Li' doc = """ Calculate payoff for study """ class Constants(BaseConstants): """Contains constants of the current experiment app.""" name_in_url = 'risk_uncertainty_goodbye_v5' players_per_group = None num_rounds = 1 attention_options = [ [1, "Extremely interested"], [2, "Very interested"], [3, "A little bit interested"], [4, "Very little interested"], [5, "Not at all interested"] ] # 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): """Contains player-level objects of the current experiment app.""" # total payment tests_passed = models.BooleanField(initial=True) completed = models.IntegerField(initial=0) bonus_amount = models.CurrencyField() failed_comprehension = models.BooleanField() gender_spec = models.StringField() # additional question add_qn_1 = models.IntegerField() add_qn_2 = models.IntegerField() add_qn_3 = models.IntegerField() attention_check = models.FloatField( blank=False, label="" ) def set_payoff(self): self.participant.payoff = self.session.config['completion_award'] self.bonus_amount = self.session.config['completion_award'] def set_comprehension(self): self.failed_comprehension = self.participant.vars['failed_comprehension']