from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import time #from django.template.loader import get_template from django.http import HttpResponse from django.shortcuts import render import datetime class Instructions0(Page): print("instructions") def is_displayed(self): return self.round_number == 1 form_model = 'player' def before_next_page(self): self.player.participant_vars_dump = str(self.participant.vars) class Instructions1(Page): print("instructions") form_model = 'player' form_fields = ['email'] def vars_for_template(self): return self.player.standardvars() def before_next_page(self): print(self.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(self.player.email) < 100: print("failed: email too short") if C.DO_CHECKS: self.player.participant.vars['failed'] = 1 self.player.participant.vars['failed_bec'] = "email_short" self.player.failed_email = True elif full_email in self.player.email: print("failed: just clicked continue") self.player.participant.vars['failed'] = 1 self.player.participant.vars['failed_bec'] = "email_major:clicked continue" self.player.failed_email = True self.player.just_clicked_continue = True elif any(x in self.player.email for x in matches): print("failed: email major") if C.DO_CHECKS: self.player.participant.vars['failed'] = 1 self.player.participant.vars['failed_bec'] = "email_major" self.player.failed_email = True elif all(x in self.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 self.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',] def vars_for_template(self): return self.player.standardvars() class redirect(Page): form_model = 'player' def vars_for_template(self): return self.player.standardvars() ##@@ add in more pages page_sequence = [ Instructions1, Instructions2, redirect ]