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_dynata' 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): psid = models.StringField() tests_passed = models.BooleanField(initial=True) completed = models.IntegerField(initial=0) failed_comprehension = models.BooleanField() # additional question attention_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']