from otree.api import * import math import pandas as pd import itertools import numpy as np import random doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'task2' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 RISK_TEMPLATE = "risk_assessment/templates/risk.html" LOW_VALUES = [28, 24, 20, 16, 12, 2] HIGH_VALUES = [28, 36, 44, 52, 60, 70] GAMBLE_CHOICES = [(i, f'Gamble {i + 1}') for i in range(6)] class Subsession(BaseSubsession): roll = models.IntegerField() def creating_session(subsession): roll = random.randint(0, 1) # zero for high roll and one for low roll #print(roll) subsession.roll = int(roll) class Group(BaseGroup): pass class Player(BasePlayer): gamble_choice = models.IntegerField(initial = -1) payoff_task2 = models.FloatField(initial = 0) def set_payoffs(self): if self.subsession.roll == 0: self.payoff_task2 = C.LOW_VALUES[self.gamble_choice] self.participant.event_task_2 = "A" else: self.payoff_task2 = C.HIGH_VALUES[self.gamble_choice] self.participant.event_task_2 = "B" self.participant.chosen_task_2 = self.gamble_choice + 1 self.participant.payoff_task2 = np.round(self.payoff_task2,2) # PAGES def make_gamble(gamble): html = "