#import datetime #import time #from django.http import HttpResponse #from django.shortcuts import render from otree.api import * # 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 C(BaseConstants): NAME_IN_URL = 'cet_prolific_pre_screen' PLAYERS_PER_GROUP = None # whats this? NUM_ROUNDS = 1 DO_CHECKS = True # environ.get('DO_CHECKS') PROLIFIC_COMPLETION_URL = 'https://app.prolific.com/submissions/complete?cc=CWKXSPX8' #'https://app.prolific.com/submissions/complete?cc=C1JA7JRQ' class Subsession(BaseSubsession): print("subsession") pass class Group(BaseGroup): print("group") pass class Player(BasePlayer): 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 """ ) failed_email = models.BooleanField(initial=False) just_clicked_continue = models.BooleanField(initial=False) participant_vars_dump = models.StringField() def make_field2(label): return models.IntegerField( choices=[(1, ''), (2, ''), (3, '')], label=label, widget=widgets.RadioSelect ) screen = make_field2('Screening job applicants') manag = make_field2('Managing a project') create = make_field2("Create content") data = make_field2("Data analysis project") code = make_field2('Writing code for games') attention_check = make_field2('Programming in qualtro') renov = make_field2('Renovation of apartments') social = make_field2('Social Media Product Management') translat = make_field2('Translation from German to English') def standardvars(self): return { 'initial': self.participant.vars.get('initial'), 'submitted_all': self.participant.vars.get('submitted_all', 0), #'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, 'just_clicked_continue': self.just_clicked_continue, } # FUNCTIONS # PAGES # from django.template.loader import get_template class Instructions0(Page): print("instructions") @staticmethod def is_displayed(player: Player): return player.round_number == 1 form_model = 'player' @staticmethod def before_next_page(player: Player, timeout_happened): player.participant_vars_dump = str(player.participant.vars) class Instructions1(Page): print("instructions") form_model = 'player' form_fields = ['email'] @staticmethod def vars_for_template(player: Player): return player.standardvars() @staticmethod def before_next_page(player: Player, timeout_happened): print(player.email) matches = ['prepone', 'revert', 'needful', 'do the needed'] matches2 = ['suggest me', 'have a doubt '] full_email = "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." if len(player.email) < 100: print("failed: email too short") if C.DO_CHECKS: player.participant.vars['failed'] = 1 player.participant.vars['failed_bec'] = "email_short" player.failed_email = True elif full_email in player.email and len(player.email) < 300: print("failed: just clicked continue") player.participant.vars['failed'] = 1 player.participant.vars['failed_bec'] = "email_major:clicked continue" player.failed_email = True player.just_clicked_continue = True elif any(x in player.email for x in matches): print("failed: email major") if C.DO_CHECKS: player.participant.vars['failed'] = 1 player.participant.vars['failed_bec'] = "email_major" player.failed_email = True elif all(x in player.email for x in matches2): print("not failed: email two minor") if C.DO_CHECKS: #### turn of minor fail # self.player.participant.vars['failed'] = 1 player.participant.vars['failed_bec'] = "email_minor" class Instructions2(Page): form_model = 'player' form_fields = [ 'screen', 'manag', 'create', 'data', 'code', 'attention_check', 'renov', 'social', 'translat', ] @staticmethod def vars_for_template(player: Player): return player.standardvars() class redirect(Page): form_model = 'player' @staticmethod def vars_for_template(player: Player): return player.standardvars() ##@@ add in more pages page_sequence = [Instructions1, Instructions2, redirect]