first commit

This commit is contained in:
duartegoncalvesds 2026-03-12 21:05:38 +00:00
commit 73fc2121bf
30 changed files with 13308 additions and 0 deletions

139
Finish/__init__.py Normal file
View file

@ -0,0 +1,139 @@
from otree.api import *
import numpy as np
import random
import operator
doc = """
App to characterise complexity of decision-making, with sums with varying numbers of elements in each sum.
"""
class C(BaseConstants):
NAME_IN_URL = 'end'
PLAYERS_PER_GROUP = None
NUM_ROUNDS = 1
class Subsession(BaseSubsession):
pass
class Group(BaseGroup):
pass
class Player(BasePlayer):
participation_fee= models.CurrencyField()
# Standard survey questions
Age = models.IntegerField(min=18, label="Please enter your age:")
EducationLevel = models.StringField(
label="What is the highest level of education that you <span style='font-weight:bold'>completed</span>?",
choices=[
"Primary Education or Less",
"Secondary Education/High School",
"Business, technical, or vocational school after Secondary Education/High School",
"Some college or university qualification, but not a Bachelor",
"Bachelor or equivalent",
"Master or Post-graduate training or professional schooling after college (e.g., law or medical school)",
"Ph.D. or equivalent"
],
widget = widgets.RadioSelect
)
EducationField = models.StringField(
label="Choose the field that best describes your <span style='font-weight:bold'>primary field of education</span>.",
choices=[
"Generic",
"Arts and Humanities",
"Social Sciences and Journalism",
"Economics",
"Education",
"Business, Administration, and Law",
"Computer Science, Information, and Communication Technologies",
"Natural Sciences",
"Mathematics and Statistics",
"Engineering, Manufacturing, and Construction",
"Agriculture, Forestry, Fisheries, and Veterinary",
"Health and Welfare",
"Services (Transport, Hygiene and Health, Security, and Other)"
],
widget = widgets.RadioSelect
)
Comments = models.LongStringField(
label="If you have any comments, please leave them below.",
blank=True
)
# PAGES
class Demographics(Page):
"""Socio-demographic questions"""
form_model = 'player'
form_fields = ['Age', 'EducationLevel', 'EducationField']
@staticmethod
def is_displayed(player):
return player.round_number == C.NUM_ROUNDS
class Comments(Page):
"""Comments"""
form_model = 'player'
form_fields = ['Comments']
@staticmethod
def is_displayed(player):
return player.round_number == C.NUM_ROUNDS
class EndOfExperiment(Page):
@staticmethod
def vars_for_template(player):
return dict(
context=player.session.config['context']
)
class RedirectProlific(Page):
@staticmethod
def is_displayed(player):
return (
player.round_number == C.NUM_ROUNDS and
player.session.config['context'] == "prolific" and
not player.participant.vars.get('failed_captcha', False)
)
@staticmethod
def js_vars(player):
return dict(
completionlink=
player.subsession.session.config['completionlink']
)
class RedirectQualtrics(Page):
@staticmethod
def is_displayed(player):
return (
player.round_number == C.NUM_ROUNDS and
player.session.config['context'] == "lab" and
not player.participant.vars.get('failed_captcha', False)
)
@staticmethod
def js_vars(player):
return dict(
elfecompletionlink=
player.session.config['elfecompletionlink']+"participantid="+player.participant.code+"&sessionid="+player.session.config['elfesessionid']
)
page_sequence = [
Demographics,
Comments,
EndOfExperiment,
RedirectProlific,
RedirectQualtrics
]