from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) from otreeutils.surveys import create_player_model_for_survey, generate_likert_field, generate_likert_table from django.forms.widgets import Select import random from .functions import default class Constants(BaseConstants): name_in_url = 'svotree' players_per_group = None num_rounds = 1 max_bonus = 1.0 instructions_slider = 'svotree/SliderInstructions.html' class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): #functions def set_payoff(self): self.payoff = Constants.max_bonus - self.donation def make_field(label): return models.IntegerField( choices=[1, 2, 3, 4, 5], label=label, widget=widgets.RadioSelect, ) #SVO Measures slider1 = models.FloatField() slider2 = models.FloatField() slider3 = models.FloatField() slider4 = models.FloatField() slider5 = models.FloatField() slider6 = models.FloatField() slider_angle = models.DecimalField(decimal_places=2, max_digits=5) slider_classification = models.CharField() #will set this in views.py after DiscreteSlider page before next page default_from_treatment = models.DecimalField(decimal_places=2, max_digits=5, default=0) treatment = models.StringField() trainingQuestion1 = models.IntegerField(label='How many people donated $0.90 in this scenario?', choices=[[50, 50], [21, 21], [27, 27], [0, 0]] ) trainingQuestion2 = models.IntegerField(label='How much did the most people donate in this scenario? In other words, what was the most popular donation amount selected?', choices=[[0, 'All different values – there is no one amount that more people donated than any other amount'], [1, '$0.10'], [2, '$0.60'], [3, 'Most people didn\'t donate anything']])