from email.policy import default from otree.api import * import numpy as np from numpy import random from random import SystemRandom, sample from random import choices import pandas as pd import csv from sqlalchemy import true doc = """ Creates Table with Visual Tracing """ class Constants(BaseConstants): name_in_url = 'Main-Task' # Sustainability Sets lS1, lS2 = [[0,1],[1,2],[0,2]], [[0,0],[1,1],[2,2]] ## Quality Sets lQc,lQs, lQe= [[1,0],[2,0],[2,1]], [[0,1],[0,2],[1,2]], [[0,0],[1,1],[2,2]] ## Price Sets lPrices = [1,1.5,2,2.5,3,3] lPoe, lPse, lPeq = [],[],[] for x in lPrices: for y in lPrices: lPair = [x,y] if x>y: lPoe.append(lPair) elif x Constants.num_prounds): participant.iOutFocus = int(participant.iOutFocus) + player.iFocusLost participant.iFullscreenChanges = int(participant.iFullscreenChanges) + player.iFullscreenChange participant.dTimeOutFocus = float(participant.dTimeOutFocus) + player.dFocusLostT # If this is selected trial, save relevant variables if (participant.SelectedTrial==player.round_number): if (player.iDec==0): participant.Price = player.P0 participant.Q = player.Q0 participant.S = player.S0 else: participant.Price = player.P1 participant.Q = player.Q1 participant.S = player.S1 class Between(Page): template_name = 'ecotask/Between.html' form_model = 'player' form_fields = [ 'dRTbetween', ] @staticmethod def js_vars(player: Player): session = player.subsession.session p = player.participant return { 'StartLeft' : player.bStartLeft, 'bRequireFS' : session.config['bRequireFS'], 'bCheckFocus' : session.config['bCheckFocus'], 'dPixelRatio' : p.dPixelRatio, } class Ready(Page): template_name = 'ecotask/Ready.html' @staticmethod def vars_for_template(player: Player): # Choose text depending round if (player.round_number==1): sText = 'Now, you will have '+str(Constants.num_prounds)+' practice rounds.
These rounds will not count for your final payment.' else: sText = 'The practice rounds are over. Now, we will continue with the experiment.' # Return selected text return dict( text = sText ) @staticmethod def is_displayed(player): # Displayed on: First round of each block or first round after the trials return ( (player.round_number==1) or (player.round_number==Constants.num_prounds+1) ) page_sequence = [Ready, Between, Task]