from otree.api import Currency as c, currency_range from . import models from ._builtin import Page, WaitPage from .models import Constants import random from random import shuffle import itertools from decimal import * def vars_for_all_templates(self): return { 'condition': self.participant.vars['condition'], } class IC(Page): form_model = models.Player form_fields = ['informed_consent'] def before_next_page(self): # See if that worker ID already appears in players, in which case they at least started the experiment mturk_check = models.Player.objects.filter( worker_id=self.participant.label) if not mturk_check: self.player.mturk_dupe = 0 else: self.player.mturk_dupe = 1 # Bring worker ID into player table/model for accessibility, which will be captured via the participant # label in the URL. Updating for this participant so that if they try again, they'll fail the dupe check. # Worker_Id has a default of 'e,' so for testing outside of MTurk just need to keep it at 'e' if there is no # participant label coming from the URL if not self.participant.label: self.player.worker_id = 'e' else: self.player.worker_id = self.participant.label # Also store condition in the player table just for ease of data analysis self.player.condition = self.participant.vars["condition"] class IC_Decline(Page): def is_displayed(self): return self.player.informed_consent == "No" class DuplicateWorker(Page): def is_displayed(self): return self.player.mturk_dupe == 1 class GenInstructions(Page): pass class TaskInstructions(Page): pass class KnowledgeCheck(Page): form_model = models.Player form_fields = ['kc1', 'kc2', 'kc3', 'kc4', 'kc5'] page_sequence = [ IC, IC_Decline, DuplicateWorker, GenInstructions, TaskInstructions, KnowledgeCheck ]