154 lines
3.0 KiB
Python
154 lines
3.0 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 = 'b3_bw_v2'
|
||
|
players_per_group = None
|
||
|
num_rounds = 1
|
||
|
|
||
|
tauxdechange = 1
|
||
|
|
||
|
instructions_BW_template = 'b3_bw_v2/Risk_BinsWanger_qc.html'
|
||
|
|
||
|
gainrisk_red = [8, 7, 6, 5, 4, 3, 2, 1, 0]
|
||
|
gainrisk_green = [8, 10, 12, 14, 16, 18, 20, 22, 24]
|
||
|
|
||
|
|
||
|
|
||
|
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):
|
||
|
|
||
|
|
||
|
game_num = models.IntegerField()
|
||
|
app_sequence_select = models.IntegerField()
|
||
|
app_sequence_select_n = models.StringField()
|
||
|
questionnaire_before = models.IntegerField()
|
||
|
|
||
|
|
||
|
|
||
|
id_in_group_nn = models.IntegerField()
|
||
|
treatment = models.IntegerField()
|
||
|
riskqc_a = models.IntegerField(
|
||
|
choices=[
|
||
|
[1, '10 ECUs'],
|
||
|
[2, '0 ECUs'],
|
||
|
[3, '4 ECUs'],
|
||
|
[4, '7 ECUs'],
|
||
|
],
|
||
|
label="",
|
||
|
widget=widgets.RadioSelectHorizontal,
|
||
|
blank=False
|
||
|
)
|
||
|
|
||
|
riskqc_b = models.IntegerField(
|
||
|
choices=[
|
||
|
[1, '20 ECUs'],
|
||
|
[2, '0 ECUs'],
|
||
|
[3, '5 ECUs'],
|
||
|
[4, '14 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()
|
||
|
|
||
|
tirage_color = models.IntegerField()
|
||
|
tirage_color_n = models.StringField()
|
||
|
|
||
|
gain_bw = models.FloatField()
|
||
|
gain_bw_eur = models.FloatField()
|
||
|
|
||
|
#####
|
||
|
|
||
|
task_start_risk = models.FloatField()
|
||
|
task_time_risk = models.FloatField()
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|