from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) from os import environ import itertools import math import time import pandas import numpy from ipware import get_client_ip import ipinfo author = 'FAU_CET' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'cet_resume' players_per_group = None #whats this? num_rounds = 200 ### warning: this goes out of not_finished now idkey = '1,5,2,6,3,4' #'1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24' #idtoadd = environ.get('IDKEY') idtoadd = "121, 15" idtoadd = idtoadd.split(',') #i.e. idtoremove! try: idtoadd = list(map(int, idtoadd)) except: idtoadd = [] with open("./cet_resume/notfinished.txt", "r+") as file_notfinished: #file_notfinished = open("./cet_resume/notfinished.txt", "r+") notfinished = file_notfinished.read() idkey = [int(i) for i in notfinished.split(",")] notin = list(set(idkey) - set(idtoadd)) idkey = notin if len(idkey) > 0: file_notfinished.seek(0) file_notfinished.write(str(int(idkey[0]))) if len(idkey) > 1: for i in idkey[1:]: file_notfinished.write(", " + str(int(i))) file_notfinished.truncate() #file_notfinished.close() session = 1 number_particip = len(idkey) #number I want in session, also number of idkey numbers there should be, mturk participants = (otree paticipants/2) numTreats = 6 numGroups = int(math.ceil(number_particip / numTreats)) treatments = ['Treat1_1', 'Treat1_2', 'Con_1', 'Con_2', 'Treat2_1', 'Treat2_2'] myTreatmentTool = [] myGroupsTool = [] for i in idkey: myTreatmentTool.append(treatments[(i % 6)-1]) myGroupsTool.append(math.ceil(i/6)) MyParticipTable = {'myIDtool': list(idkey), 'myTreatmentTool': list(myTreatmentTool), 'myGroupsTool': list(myGroupsTool), 'started': list([0] * number_particip), 'replaced': list([0] * number_particip), 'last_active': list([time.time()] * number_particip), 'finishedp1': list([0] * number_particip), } # MyParticipTable = {'myIDtool': list(range((session-1)*number_particip+1, session*number_particip + 1, 1)), # 'myTreatmentTool': list(treatments*numGroups), # 'myGroupsTool': list(numpy.repeat([range((session-1)*numGroups+1, session*numGroups + 1)], numTreats)), # 'started': list([0]*number_particip), # 'replaced': list([0]*number_particip), # 'last_active': list([time.time()]*number_particip) # } MyParticipTable_df = pandas.DataFrame(MyParticipTable) ############################ IF NEED TO MANUALLY ADD SOME PARTICIPANTS IN ########################### #toadd = pandas.DataFrame([[11, 'Treat2_1', 2, 0, 0, time.time()]], columns=list(MyParticipTable_df.columns)) #MyParticipTable_df = MyParticipTable_df.append(toadd) #MyParticipTable_df = pandas.DataFrame(toadd) MyParticipTable_df = MyParticipTable_df.set_index('myIDtool') print(MyParticipTable_df) print("constants") class Subsession(BaseSubsession): print("subsession") def creating_session(self): #print("creating sesh") if self.round_number == 1: myIDtool = itertools.cycle(list(Constants.MyParticipTable_df.index)) #range(1, (Constants.number_particip) + 1, 1))) for p in self.get_players(): p.participant.vars['initial'] = True p.participant.vars['submitted_all'] = False p.participant.vars['submitted1'] = False p.participant.vars['submitted2'] = False p.participant.vars['submitted3'] = False p.participant.vars['submitted4'] = False p.participant.vars['finished'] = False p.participant.vars['last_active'] = time.time() p.participant.vars['myID'] = next(myIDtool) p.participant.vars['failed'] = 0 p.participant.vars['ip2'] = 0 p.participant.vars['lat'] = 0 p.participant.vars['long'] = 0 p.participant.vars['city'] = None with open("./cet_resume/notfinished.txt", "r") as file_notfinished: notfinished = file_notfinished.read() p.session.vars['notfinished'] = [int(i) for i in notfinished.split(",")] #list(Constants.MyParticipTable_df.index) with open("./cet_resume/lats.txt", "r") as file_lats: #file_lats = open("./cet_resume/lats.txt", "r") lats = file_lats.read() p.session.vars['lats'] = [float(i) for i in lats.split(",")] #print(p.session.vars['lats']) with open("./cet_resume/longs.txt", "r") as file_longs: #file_longs = open("./cet_resume/longs.txt", "r") longs = file_longs.read() p.session.vars['longs'] = [float(i) for i in longs.split(",")] #print(p.session.vars['longs']) print(p.participant.vars['myID']) print(p.session.vars['notfinished']) pass class Group(BaseGroup): print("group") pass class Player(BasePlayer): def get_client_ip_my(self, request): ip, is_routable = get_client_ip(request) if ip is None: # Unable to get the client's IP address return None else: # We got the client's IP address if is_routable: # The client's IP address is publicly routable on the Internet return ip else: return "not routable:" + ip def get_ip_info(self, ip): access_token = '1ac551076210cc' handler = ipinfo.getHandler(access_token) details = handler.getDetails(ip) return(details) ## function check lat and long from Constants and from list here. return failed if repeated ## WARNING TURNED OFF check_loc def check_loc(self, lat, long): pass #lats = self.session.vars['lats'] #longs = self.session.vars['longs'] #latindex = [i for i, v in enumerate(lats) if v==round(lat, 3)] #longindex = [i for i, v in enumerate(longs) if v==round(long, 3)] #if [i for i in latindex if i in longindex]: # self.participant.vars['failed'] = 1 # print("failed: same loc") #else: # self.session.vars['lats'].append(round(lat, 3)) # self.session.vars['longs'].append(round(long, 3)) def append_loc(self, lat, long): print("inside append lock") keepgoing = True while keepgoing: try: with open("./cet_resume/lats.txt", "a+") as file_lats: #file_lats = open("./cet_resume/lats.txt", "a+") file_lats.write(", " + str(round(lat, 3))) print("written " + str(round(lat, 3))) keepgoing = False except: pass keepgoing = True while keepgoing: try: with open("./cet_resume/longs.txt", "a+") as file_longs: #file_longs = open("./cet_resume/longs.txt", "a+") file_longs.write(", " + str(round(long, 3))) #file_longs.close() print("written " + str(round(long, 3))) keepgoing = False except: pass def ins_viewing(self): return self.CV_viewing in [0, 21, 22] def standardvars(self): return { 'initial': self.participant.vars.get('initial'), 'submitted_all': self.participant.vars.get('submitted_all', 0), 'submitted1': self.participant.vars.get('submitted1'), 'submitted2': self.participant.vars.get('submitted2'), 'submitted3': self.participant.vars.get('submitted3'), 'submitted4': self.participant.vars.get('submitted4'), 'treated1': self.participant.vars.get('treated1'), 'treated2': self.participant.vars.get('treated2'), 'type_1': self.participant.vars.get('type_1'), 'failed': self.participant.vars.get('failed') == 1 } def specialvars(self): partvars = self.participant.vars if partvars.get('treated1') and partvars.get('type_1'): #treated1, type1 return { 'image_path': 'Resumes/Group{1}/Resume_{0}_T1_Output.jpg'.format( self.CV_viewing, self.participant.vars['mygroup']) } elif partvars.get('treated1') and not partvars.get('type_1'): #treated1, type2 return{ 'image_path': 'Resumes/Group{1}/Resume_{0}_T2_Output.jpg'.format( self.CV_viewing, self.participant.vars['mygroup']) } elif not partvars.get('treated1') and not partvars.get('treated2') and partvars.get('type_1'): #control type1 return { 'image_path': 'Resumes/Group{1}/Resume_{0}_T1_Output.jpg'.format( self.CV_viewing, self.participant.vars['mygroup']) } elif not partvars.get('treated1') and not partvars.get('treated2') and not partvars.get('type_1'): #control type2 return { 'image_path': 'Resumes/Group{1}/Resume_{0}_T2_Output.jpg'.format( self.CV_viewing, self.participant.vars['mygroup']) } elif partvars.get('treated2') and partvars.get('type_1'): #treated2, type1 return { 'image_path': 'Resumes/Group{1}/Resume_{0}_T1_Output.jpg'.format( self.CV_viewing, self.participant.vars['mygroup']) } elif partvars.get('treated2') and not partvars.get('type_1'): #treated2, type2 return{ 'image_path': 'Resumes/Group{1}/Resume_{0}_T2_Output.jpg'.format( self.CV_viewing, self.participant.vars['mygroup']) } else: print('@@@@@@@@@@@@@@@@@@@@@@@@ ERROR NO TYPE @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@') def varsfortemplate(self): if self.round_number == 1: if self.participant.vars.get('treated1'): self.CV_viewing = 21 elif self.participant.vars.get('treated2'): self.CV_viewing = 22 else: self.CV_viewing = 0 if self.round_number != 1 and self.CV_viewing not in [0, 21, 22]: return ({**self.specialvars(), **self.standardvars()}) else: return self.standardvars() def setup(self): print("setup") print(Constants.MyParticipTable_df) print(self.session.vars['notfinished']) selfplayer = self selfplayer.participant.vars['last_active'] = time.time() selfplayer.participant.vars['timeleftfirstpage'] = time.time() me = selfplayer.participant.vars.get('myID') print(me) ### get players, look thru, find the one which has made least progress, take their role, ### next one should leave a bit of time for them to progress? off = False with open("./cet_resume/notfinished.txt", "r") as file_notfinished: # file_notfinished = open("./cet_resume/notfinished.txt", "r") notfinished = file_notfinished.read() pIDlist = [int(i) for i in notfinished.split(",")] # pIDlist = self.session.vars.get('notfinished') print(pIDlist) while not off: if all(Constants.MyParticipTable_df['started'] > 0): print("all started") if not all(Constants.MyParticipTable_df['finishedp1'] > 0): print("not all finished p1") #print(Constants.MyParticipTable_df.loc[Constants.MyParticipTable_df['finishedp1'] == 0]) pID = int(Constants.MyParticipTable_df.loc[Constants.MyParticipTable_df['finishedp1'] == 0][ 'last_active'].sort_values().index[0]) print(" ".join([str(pID), "chosen"])) time.sleep(numpy.random.random(1) * 3) if Constants.MyParticipTable_df['started'][pID] == Constants.MyParticipTable_df['replaced'][pID] + 1: print("replacing in df") Constants.MyParticipTable_df['replaced'][pID] = Constants.MyParticipTable_df['replaced'][pID] + 1 Constants.MyParticipTable_df['last_active'][pID] = time.time() if pID in pIDlist: selfplayer.participant.vars['myID'] = pID off = True Constants.MyParticipTable_df['started'][pID] = Constants.MyParticipTable_df['started'][pID] + 1 #print(Constants.MyParticipTable_df) else: print("all finished p1") if pIDlist: others = Constants.MyParticipTable_df.loc[Constants.MyParticipTable_df.index.isin(pIDlist)] print(others) pID = int(others['last_active'].sort_values().index[0]) print(" ".join([str(pID), "chosen"])) time.sleep(numpy.random.random(1) * 3) if Constants.MyParticipTable_df['started'][pID] == Constants.MyParticipTable_df['replaced'][ pID] + 1: print("updating df") Constants.MyParticipTable_df['replaced'][pID] = Constants.MyParticipTable_df['replaced'][ pID] + 1 Constants.MyParticipTable_df['last_active'][pID] = time.time() selfplayer.participant.vars['myID'] = pID off = True Constants.MyParticipTable_df['started'][pID] = Constants.MyParticipTable_df['started'][pID] + 1 # print(Constants.MyParticipTable_df) else: print("all totally finished, expire HIT") print("continue with my initial ID") Constants.MyParticipTable_df['started'][me] = Constants.MyParticipTable_df['started'][me] + 1 off = True elif me in pIDlist and Constants.MyParticipTable_df['started'][me] == 0: print("continue with my initial ID, " + str(me)) Constants.MyParticipTable_df['started'][me] = Constants.MyParticipTable_df['started'][me] + 1 off = True else: print("not all started") rplc = Constants.MyParticipTable_df.loc[Constants.MyParticipTable_df['started'] == 0].sample(n=1).index[0] print(" ".join([str(rplc), "chosen"])) time.sleep(numpy.random.random(1)*3) if Constants.MyParticipTable_df['started'][rplc] == 0: print("updating df") Constants.MyParticipTable_df['started'][rplc] = Constants.MyParticipTable_df['started'][rplc] + 1 #print(Constants.MyParticipTable_df) if rplc in pIDlist: selfplayer.participant.vars['myID'] = rplc off = True #print(Constants.MyParticipTable_df) selfplayer.participant.vars['treatment'] = \ Constants.MyParticipTable_df['myTreatmentTool'][selfplayer.participant.vars['myID']] selfplayer.participant.vars['mygroup'] = \ str(Constants.MyParticipTable_df['myGroupsTool'][selfplayer.participant.vars['myID']]) #print(selfplayer.participant.vars['treatment'], selfplayer.participant.vars['mygroup']) if selfplayer.participant.vars['treatment'] in ('Treat1_1', 'Treat1_2'): selfplayer.participant.vars['treated1'] = True elif selfplayer.participant.vars['treatment'] in ('Con_1', 'Con_2', 'Treat2_1', 'Treat2_2'): selfplayer.participant.vars['treated1'] = False else: print('@@@@@@@@@@@@ ERROR ERROR neither treated1 or not treated1 @@@@@@@@@@@@@@@@') if selfplayer.participant.vars['treatment'] in ('Treat2_1', 'Treat2_2'): selfplayer.participant.vars['treated2'] = True elif selfplayer.participant.vars['treatment'] in ('Con_1', 'Con_2', 'Treat1_1', 'Treat1_2'): selfplayer.participant.vars['treated2'] = False else: print('@@@@@@@@@@@@ ERROR ERROR neither treated2 or not treated2 @@@@@@@@@@@@@@@@') if selfplayer.participant.vars['treatment'] in ('Treat1_1', 'Con_1', 'Treat2_1'): selfplayer.participant.vars['type_1'] = True elif selfplayer.participant.vars['treatment'] in ('Treat1_2', 'Con_2', 'Treat2_2'): selfplayer.participant.vars['type_1'] = False else: print('@@@@@@@@@@@@ ERROR ERROR neither type 1 nor type 2@@@@@@@@@@@@@@@@') def instructbeforenextpage(self): self.participant.vars['last_active'] = time.time() Constants.MyParticipTable_df['last_active'][self.participant.vars['myID']] = time.time() self.participant_vars_dump = str(self.participant.vars) ##@@ this is full of repeated code, could make multiple functions def beforenextpage(self): selfplayer = self selfplayer.time_clicked = time.time() selfplayer.participant.vars['last_active'] = time.time() Constants.MyParticipTable_df['last_active'][selfplayer.participant.vars['myID']] = time.time() if self.round_number != 1: if selfplayer.CV_viewing == 1: try: selfplayer.TimeSpentCV_1 = selfplayer.TimeSpentCV_1 + ( selfplayer.time_clicked - self.in_round(self.round_number - 1).time_clicked) except: selfplayer.TimeSpentCV_1 = ( selfplayer.time_clicked - self.in_round(self.round_number - 1).time_clicked) elif selfplayer.CV_viewing == 2: try: selfplayer.TimeSpentCV_2 = selfplayer.TimeSpentCV_2 + ( selfplayer.time_clicked - self.in_round(self.round_number - 1).time_clicked) except: selfplayer.TimeSpentCV_2 = ( selfplayer.time_clicked - self.in_round(self.round_number - 1).time_clicked) elif selfplayer.CV_viewing == 3: try: selfplayer.TimeSpentCV_3 = selfplayer.TimeSpentCV_3 + ( selfplayer.time_clicked - self.in_round(self.round_number - 1).time_clicked) except: selfplayer.TimeSpentCV_3 = ( selfplayer.time_clicked - self.in_round(self.round_number - 1).time_clicked) elif selfplayer.CV_viewing == 4: try: selfplayer.TimeSpentCV_4 = selfplayer.TimeSpentCV_4 + ( selfplayer.time_clicked - self.in_round(self.round_number - 1).time_clicked) except: selfplayer.TimeSpentCV_4 = ( selfplayer.time_clicked - self.in_round(self.round_number - 1).time_clicked) elif selfplayer.CV_viewing == 5: try: selfplayer.TimeSpentCV_5 = selfplayer.TimeSpentCV_5 + ( selfplayer.time_clicked - self.in_round(self.round_number - 1).time_clicked) except: selfplayer.TimeSpentCV_5 = ( selfplayer.time_clicked - self.in_round(self.round_number - 1).time_clicked) elif selfplayer.CV_viewing == 6: try: selfplayer.TimeSpentCV_6 = selfplayer.TimeSpentCV_6 + ( selfplayer.time_clicked - self.in_round(self.round_number - 1).time_clicked) except: selfplayer.TimeSpentCV_6 = ( selfplayer.time_clicked - self.in_round(self.round_number - 1).time_clicked) elif selfplayer.CV_viewing in [0, 21, 22]: selfplayer.TimeSpentInstruc = selfplayer.TimeSpentInstruc + ( selfplayer.time_clicked - self.in_round(self.round_number - 1).time_clicked) else: print('@@@@@@@@@@@@@@@@@@@@@@@ ERROR ERROR NO CV_VIEWING @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@') else: selfplayer.TimeSpentInstruc = (selfplayer.time_clicked - self.participant.vars.get('timelefttreatpage')) selfplayer.TimeSpentCV_1 = 0 selfplayer.TimeSpentCV_2 = 0 selfplayer.TimeSpentCV_3 = 0 selfplayer.TimeSpentCV_4 = 0 selfplayer.TimeSpentCV_5 = 0 selfplayer.TimeSpentCV_6 = 0 selfvars = self.participant.vars nextselfplayer = self.in_round(self.round_number + 1) selfplayer.participant_vars_dump = str(selfvars) nextselfplayer.TimeSpentInstruc = selfplayer.TimeSpentInstruc nextselfplayer.TimeSpentCV_1 = selfplayer.TimeSpentCV_1 nextselfplayer.TimeSpentCV_2 = selfplayer.TimeSpentCV_2 nextselfplayer.TimeSpentCV_3 = selfplayer.TimeSpentCV_3 nextselfplayer.TimeSpentCV_4 = selfplayer.TimeSpentCV_4 nextselfplayer.TimeSpentCV_5 = selfplayer.TimeSpentCV_5 nextselfplayer.TimeSpentCV_6 = selfplayer.TimeSpentCV_6 nextselfplayer.CV_1 = selfplayer.CV_1 nextselfplayer.CV_2 = selfplayer.CV_2 nextselfplayer.CV_3 = selfplayer.CV_3 nextselfplayer.CV_4 = selfplayer.CV_4 nextselfplayer.CV_5 = selfplayer.CV_5 nextselfplayer.CV_6 = selfplayer.CV_6 nextselfplayer.CV_1_A = selfplayer.CV_1_A nextselfplayer.CV_2_A = selfplayer.CV_2_A nextselfplayer.CV_3_A = selfplayer.CV_3_A nextselfplayer.CV_4_A = selfplayer.CV_4_A nextselfplayer.CV_5_A = selfplayer.CV_5_A nextselfplayer.CV_6_A = selfplayer.CV_6_A nextselfplayer.CV_1_B = selfplayer.CV_1_B nextselfplayer.CV_2_B = selfplayer.CV_2_B nextselfplayer.CV_3_B = selfplayer.CV_3_B nextselfplayer.CV_4_B = selfplayer.CV_4_B nextselfplayer.CV_5_B = selfplayer.CV_5_B nextselfplayer.CV_6_B = selfplayer.CV_6_B nextselfplayer.CV_1_C = selfplayer.CV_1_C nextselfplayer.CV_2_C = selfplayer.CV_2_C nextselfplayer.CV_3_C = selfplayer.CV_3_C nextselfplayer.CV_4_C = selfplayer.CV_4_C nextselfplayer.CV_5_C = selfplayer.CV_5_C nextselfplayer.CV_6_C = selfplayer.CV_6_C nextselfplayer.Name_1 = selfplayer.Name_1 nextselfplayer.Name_2 = selfplayer.Name_2 nextselfplayer.Name_3 = selfplayer.Name_3 nextselfplayer.Name_4 = selfplayer.Name_4 nextselfplayer.Name_5 = selfplayer.Name_5 nextselfplayer.Name_6 = selfplayer.Name_6 nextselfplayer.Notes_1 = selfplayer.Notes_1 nextselfplayer.Notes_2 = selfplayer.Notes_2 nextselfplayer.Notes_3 = selfplayer.Notes_3 nextselfplayer.Notes_4 = selfplayer.Notes_4 nextselfplayer.Notes_5 = selfplayer.Notes_5 nextselfplayer.Notes_6 = selfplayer.Notes_6 if selfplayer.CV_to_view != None: nextselfplayer.CV_viewing = selfplayer.CV_to_view else: nextselfplayer.CV_viewing = selfplayer.CV_viewing #nextselfplayer.mygroup = selfvars['mygroup'] ##@@ lots of repeated code here, should make function self.participant.vars['initial'] = False if not selfvars['submitted1']: if selfplayer.subreq == True and None not in [selfplayer.CV_1, selfplayer.CV_2, selfplayer.CV_3, selfplayer.CV_4, selfplayer.CV_5, selfplayer.CV_6]: self.participant.vars['initial'] = True self.participant.vars['submitted1'] = True elif not selfvars['submitted2']: if selfplayer.backreq == True: self.participant.vars['submitted1'] = False elif selfplayer.subreq == True and None not in [selfplayer.CV_1_A, selfplayer.CV_2_A, selfplayer.CV_3_A, selfplayer.CV_4_A, selfplayer.CV_5_A, selfplayer.CV_6_A]: self.participant.vars['initial'] = True self.participant.vars['submitted2'] = True elif not selfvars['submitted3']: if selfplayer.backreq == True: self.participant.vars['submitted2'] = False elif selfplayer.subreq == True and None not in [selfplayer.CV_1_B, selfplayer.CV_2_B, selfplayer.CV_3_B, selfplayer.CV_4_B, selfplayer.CV_5_B, selfplayer.CV_6_B]: self.participant.vars['initial'] = True self.participant.vars['submitted3'] = True elif not selfvars['submitted4']: if selfplayer.backreq == True: self.participant.vars['submitted3'] = False elif selfplayer.subreq == True and None not in [selfplayer.CV_1_C, selfplayer.CV_2_C, selfplayer.CV_3_C, selfplayer.CV_4_C, selfplayer.CV_5_C, selfplayer.CV_6_C]: self.participant.vars['initial'] = True self.participant.vars['submitted4'] = True elif not selfvars['submitted_all']: if selfplayer.backreq == True: self.participant.vars['submitted4'] = False elif selfplayer.subreq == True and None not in [selfplayer.CV_1, selfplayer.CV_2, selfplayer.CV_3, selfplayer.CV_4, selfplayer.CV_5, selfplayer.CV_6]: self.participant.vars['initial'] = True self.participant.vars['submitted_all'] = True Constants.MyParticipTable_df['finishedp1'][selfplayer.participant.vars['myID']] = 1 #print("check for attention") namelist = 'katelynhartmanjakedeckerdeshawnjeffersonjanaebookerhunternielsontremaynebanksclaireandersontanishawashington' failedcount = 0 if selfplayer.Name_1 is not None and (len(selfplayer.Name_1) < 3 or not [i for i in str.split(str.lower(selfplayer.Name_1)) if i in namelist]): failedcount = failedcount + 1 if selfplayer.Name_2 is not None and (len(selfplayer.Name_2) < 3 or not [i for i in str.split(str.lower(selfplayer.Name_2)) if i in namelist]): failedcount = failedcount + 1 if selfplayer.Name_3 is not None and (len(selfplayer.Name_3) < 3 or not [i for i in str.split(str.lower(selfplayer.Name_3)) if i in namelist]): failedcount = failedcount + 1 if selfplayer.Name_4 is not None and (len(selfplayer.Name_4) < 3 or not [i for i in str.split(str.lower(selfplayer.Name_4)) if i in namelist]): failedcount = failedcount + 1 if selfplayer.Name_5 is not None and (len(selfplayer.Name_5) < 3 or not [i for i in str.split(str.lower(selfplayer.Name_5)) if i in namelist]): failedcount = failedcount + 1 if selfplayer.Name_6 is not None and (len(selfplayer.Name_6) < 3 or not [i for i in str.split(str.lower(selfplayer.Name_6)) if i in namelist]): failedcount = failedcount + 1 #print(selfplayer.participant.vars['failed']) if failedcount > 1: selfplayer.participant.vars['failed'] = 1 print("failed: incorrect name") #print("print the information") #print(selfplayer.ip) #print(selfplayer.loc) def isint1(self): return not self.CV_1 == None and self.CV_1.is_integer() def isint2(self): return not self.CV_2 == None and self.CV_2.is_integer() def isint3(self): return not self.CV_3 == None and self.CV_3.is_integer() def isint4(self): return not self.CV_4 == None and self.CV_4.is_integer() def isint5(self): return not self.CV_5 == None and self.CV_5.is_integer() def isint6(self): return not self.CV_6 == None and self.CV_6.is_integer() agreed = models.BooleanField() #def role(self): # if self.id_in_group == 1: # return 'Treat1_1' # if self.id_in_group == 2: # return 'Treat1_2' # if self.id_in_group == 3: # return 'Con_1' # if self.id_in_group == 4: # return 'Con_2' # if self.id_in_group == 5: # return 'Treat2_1' # if self.id_in_group == 6: # return 'Treat2_2' participant_vars_dump = models.StringField() TimeSpentInstruc = models.FloatField() TimeSpentCV_1 = models.FloatField() TimeSpentCV_2 =models.FloatField() TimeSpentCV_3 = models.FloatField() TimeSpentCV_4 = models.FloatField() TimeSpentCV_5 = models.FloatField() TimeSpentCV_6 = models.FloatField() #mygroup = models.IntegerField() CV_1 = models.FloatField(min=0, max=10,blank=True) CV_2 = models.FloatField(min=0, max=10,blank=True) CV_3 = models.FloatField(min=0, max=10,blank=True) CV_4 = models.FloatField(min=0, max=10,blank=True) CV_5 = models.FloatField(min=0, max=10,blank=True) CV_6 = models.FloatField(min=0, max=10,blank=True) CV_1_A = models.FloatField(min=0, max=10, blank=True) CV_2_A = models.FloatField(min=0, max=10, blank=True) CV_3_A = models.FloatField(min=0, max=10, blank=True) CV_4_A = models.FloatField(min=0, max=10, blank=True) CV_5_A = models.FloatField(min=0, max=10, blank=True) CV_6_A = models.FloatField(min=0, max=10, blank=True) CV_1_B = models.FloatField(min=0, max=10, blank=True) CV_2_B = models.FloatField(min=0, max=10, blank=True) CV_3_B = models.FloatField(min=0, max=10, blank=True) CV_4_B = models.FloatField(min=0, max=10, blank=True) CV_5_B = models.FloatField(min=0, max=10, blank=True) CV_6_B = models.FloatField(min=0, max=10, blank=True) CV_1_C = models.FloatField(min=0, max=10, blank=True) CV_2_C = models.FloatField(min=0, max=10, blank=True) CV_3_C = models.FloatField(min=0, max=10, blank=True) CV_4_C = models.FloatField(min=0, max=10, blank=True) CV_5_C = models.FloatField(min=0, max=10, blank=True) CV_6_C = models.FloatField(min=0, max=10, blank=True) Name_1 = models.StringField(max_length=20, blank=True) Name_2 = models.StringField(max_length=20, blank=True) Name_3 = models.StringField(max_length=20, blank=True) Name_4 = models.StringField(max_length=20, blank=True) Name_5 = models.StringField(max_length=20, blank=True) Name_6 = models.StringField(max_length=20, blank=True) Notes_1 = models.LongStringField(blank=True, widget=widgets.Textarea(attrs={'placeholder': "Use this box for any notes regarding Résumé 1"})) Notes_2 = models.LongStringField(blank=True, widget=widgets.Textarea(attrs={'placeholder': "Use this box for any notes regarding Résumé 2"})) Notes_3 = models.LongStringField(blank=True, widget=widgets.Textarea(attrs={'placeholder': "Use this box for any notes regarding Résumé 3"})) Notes_4 = models.LongStringField(blank=True, widget=widgets.Textarea(attrs={'placeholder': "Use this box for any notes regarding Résumé 4"})) Notes_5 = models.LongStringField(blank=True, widget=widgets.Textarea(attrs={'placeholder': "Use this box for any notes regarding Résumé 5"})) Notes_6 = models.LongStringField(blank=True, widget=widgets.Textarea(attrs={'placeholder': "Use this box for any notes regarding Résumé 6"})) CV_viewing = models.IntegerField(blank=True) CV_to_view = models.IntegerField(blank=True) time_clicked = models.FloatField() subreq = models.BooleanField(blank=True, initial=False) backreq = models.BooleanField(blank=True, initial=False) loc = models.StringField(max_length=100, blank=True) ip = models.StringField(max_length=100, blank=True) email = models.LongStringField(initial="""Hi Emma, We discussed about meeting next Friday, but now I have a doubt about this. Could we prepone it to tomorrow instead? So you either need to revert back to me and suggest me another time, or book the room for tomorrow. Kindly do the needful. Best, John """)