from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random import time class Intro(Page): form_model = 'player' form_fields = ['feedback'] class Demographics(Page): form_model = 'player' form_fields = ['age', 'gender', 'ethnicity', 'highest_education', 'marital_status', 'employment_status', 'state', ] class Inconsistencies(Page): form_model = 'player' def get_form_fields(self): customfields = ['workExperienceInc', 'educationInc', 'health', 'crime', 'discrimination'] random.shuffle(customfields) customfields.append('anythingElse') finalfields = [[s, s +'Text'] for s in customfields] finalfields = [s for sublist in finalfields for s in sublist] return finalfields class ImportantFactors(Page): form_model = 'player' def get_form_fields(self): customfields = ['teams', 'communicate', 'administration', 'customerService', 'ITskills', 'experience', 'education', 'hobbies', #'CVpresentation', #'SMpresentation', 'CVcontents', 'SMcontents'] random.shuffle(customfields) return customfields class SocialMedia1(Page): form_model = 'player' def get_form_fields(self): customfields = ['Twitter', 'Instagram', 'Facebook', 'Snapchat', 'LinkedIn', 'TikTok'] random.shuffle(customfields) return customfields class SocialMedia2(Page): form_model = 'player' form_fields = ['stayintouch', 'toomuchtime', 'potentialemployers', 'professional'] class PoliticsGSS(Page): form_model = 'player' form_fields = ['lib_con'] class Privacy(Page): form_model = 'player' form_fields = ['lostControl', 'advertisers', 'employers'] def before_next_page(self): self.participant.vars['finished'] = True remo = self.participant.vars.get('myID') #remo = 2 with open("./cet_pre_screen/notfinished.txt", "r+") as file_notfinished: #file_notfinished = open("./cet_resume/notfinished.txt", "r+") notfinished = file_notfinished.read() newlist = [int(i) for i in notfinished.split(",")] #newlist = list(self.session.vars.get('notfinished')) try: newlist.remove(remo) except: pass #self.session.vars['notfinished'] = newlist #print(self.session.vars['notfinished']) file_notfinished.seek(0) if len(newlist) > 0: file_notfinished.write(str(int(newlist[0]))) if len(newlist) > 1: for i in newlist[1:]: file_notfinished.write(", " + str(int(i))) file_notfinished.truncate() #file_notfinished.close() self.player.participant.vars['last_active'] = time.time() self.player.participant_vars_dump = str(self.participant.vars) class Finished(Page): form_model = 'player' def vars_for_template(self): return { 'idd': self.player.participant.vars.get('myID') } page_sequence = [ Intro, Demographics, Inconsistencies, ImportantFactors, PoliticsGSS, SocialMedia1, SocialMedia2, Privacy, Finished ]