Test_Johanne/exp_e4c_fr_p3_risk_binswanger/models.py
2025-03-06 10:33:03 +01:00

154 lines
3.1 KiB
Python

import random
from otree.api import (
models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer,
Currency as c, currency_range
)
doc = """
Author : Wael Bousselmi
"""
class Constants(BaseConstants):
name_in_url = 'exp_e4c_fr_p3_risk_binswanger'
players_per_group = None
num_rounds = 1
tauxdechange = 1
instructions_BW_template = 'exp_e4c_fr_risk_p3_binswanger/Risk_BinsWanger_qc.html'
gainriskAred = 8#4
gainriskBred = 6#3
gainriskCred = 4#2
gainriskDred = 2#1
gainriskEred = 0#0
gainriskAgreen = 8#4
gainriskBgreen = 12#6
gainriskCgreen = 16#8
gainriskDgreen = 20#10
gainriskEgreen = 24#12
tauxchange = 0.8
class Subsession(BaseSubsession):
def vars_for_admin_report(self):
report = list()
for p in self.get_players():
report.append(dict(id=p.participant.id_in_session, label=p.participant.label, answers=p.gainrisk))
return dict(report=report)
class Group(BaseGroup):
pass
#############################
def imi_inv(label):
return models.IntegerField(
choices=[
[0, '0'],
[1, '1'],
[2, '2'],
[3, '3'],
[4, '4'],
[5, '5'],
[6, '6'],
[7, '7']
],
label=label,
widget=widgets.RadioSelect,
blank=False
)
# Define template for Goal commitment questions
def goal_com(label):
return models.IntegerField(
choices=[
[0, '0'],
[1, '1'],
[2, '2'],
[3, '3'],
[4, '4'],
[5, '5'],
],
label=label,
widget=widgets.RadioSelect,
blank=False
)
#############################
class Player(BasePlayer):
treatment = models.IntegerField()
riskqc_a = models.IntegerField(
choices=[
[1, '12 ECUs'],
[2, '0 ECUs'],
[3, '4 ECUs'],
[4, '6 ECUs'],
],
label="",
widget=widgets.RadioSelectHorizontal,
blank=False
)
riskqc_b = models.IntegerField(
choices=[
[1, '20 ECUs'],
[2, '0 ECUs'],
[3, '2 ECUs'],
[4, '12 ECUs'],
],
label="",
widget=widgets.RadioSelectHorizontal,
blank=False
)
riskqc_c = models.IntegerField(
choices=[
[1, '0 ECUs'],
[2, '2 ECUs'],
[3, '24 ECUs'],
[4, '8 ECUs'],
],
label="",
widget=widgets.RadioSelectHorizontal,
blank=False
)
choicerisk = models.IntegerField(
blank=False,
)
choicerisknn = models.StringField()
tc3 = models.StringField()
tiragecolor = models.FloatField()
colorbutton = models.IntegerField()
colorselect = models.IntegerField()
colorselectnn = models.StringField()
gainrisk = models.FloatField()
gainriskeur = models.FloatField()
gainriskeurfinal = models.FloatField()
task_start_risk = models.FloatField()
task_time_risk = models.FloatField()