import random from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'Daniyal K. Chawla' doc = """ Grading Project for MTurk """ class Constants(BaseConstants): name_in_url = 'grading_app' players_per_group = None num_rounds = 1 import random timeIncriment = 900 num1 = random.randint(1, 2) flag1 = (num1 == 1) completion_code = "COMPLETE123" import csv with open('grading_app/Grading_v5.csv', encoding='utf-8') as file: rows = list(csv.DictReader(file)) data = rows[0] class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): def CountMistakes(self, seq1, seq2): import numpy as np try: len(seq1) except: seq1 = "" try: len(seq2) except: seq2 = "" size_x = len(seq1) + 1 size_y = len(seq2) + 1 matrix = np.zeros((size_x, size_y)) for x in range(size_x): matrix[x, 0] = x for y in range(size_y): matrix[0, y] = y for x in range(1, size_x): for y in range(1, size_y): if seq1[x - 1] == seq2[y - 1]: matrix[x, y] = min( matrix[x - 1, y] + 1, matrix[x - 1, y - 1], matrix[x, y - 1] + 1 ) else: matrix[x, y] = min( matrix[x - 1, y] + 1, matrix[x - 1, y - 1] + 1, matrix[x, y - 1] + 1 ) mistakes = (matrix[size_x - 1, size_y - 1]) mistakes = int(mistakes) return mistakes timeIntro1 = models.FloatField() timeIntro2 = models.FloatField() timeIntro3 = models.FloatField() timeOnPreBeliefs1 = models.FloatField(initial=0) timeOnPreBeliefs2 = models.FloatField(initial=0) timeOnPreBeliefs3 = models.FloatField(initial=0) captcha1 = models.StringField( doc="""captcha field""", blank=False ) captcha2 = models.StringField( doc="""captcha field""", blank=False, initial="" ) preBeliefsFlag = models.IntegerField() line1 = models.StringField( label="Line 1:", doc="""Amount sent by P1""", blank=True ) practiceMistakes1 = models.IntegerField() line2 = models.StringField( label="Line 2:", doc="""Amount sent by P2""", blank=True ) practiceMistakes2 = models.IntegerField() line3 = models.StringField( label="Line 3:", doc="""Amount sent by P3""", blank=True ) practiceMistakes3 = models.IntegerField() line4 = models.StringField( label="Line 4:", doc="""Amount sent by P4""", blank=True ) practiceMistakes4 = models.IntegerField() line5 = models.StringField( label="Line 5:", doc="""Amount sent by P5""", blank=True ) practiceMistakes5 = models.IntegerField() exampleAnswer1 = models.StringField( label="How many mistakes would you make by entering: “Navarana Brunell”?", choices=[['1', '1'],['2', '2'],['3', '3'],['4', '4'],['5', '5'],['6', '6'],['7', '7'],['8', '8'],['8', '8'], ['9', '9'],['10', '10'],['11', '11'],['12', '12'],['13', '13'],['14', '14'],['15', '15']], widget=widgets.RadioSelect, blank=False, ) exampleAnswer2 = models.StringField( label="How many mistakes would you make by entering: “Navarani brunell 0653047255”?", choices=[['1', '1'],['2', '2'],['3', '3'],['4', '4'],['5', '5'],['6', '6'],['7', '7'],['8', '8'],['8', '8'], ['9', '9'],['10', '10'],['11', '11'],['12', '12'],['13', '13'],['14', '14'],['15', '15']], widget=widgets.RadioSelect, blank=False, ) exampleAnswer3 = models.StringField( label="How many mistakes would you make by entering: “Navaranaaaaa Brunell 0653047255”?", choices=[['1', '1'],['2', '2'],['3', '3'],['4', '4'],['5', '5'],['6', '6'],['7', '7'],['8', '8'],['8', '8'], ['9', '9'],['10', '10'],['11', '11'],['12', '12'],['13', '13'],['14', '14'],['15', '15']], widget=widgets.RadioSelect, blank=False, ) beliefp1q1 = models.StringField( choices=[['1', 'Considerably faster'], ['2', 'Slightly faster'],['3', 'No change'], ['4', 'Slightly slower'], ['5', 'Considerably slower']], label='Do you think you would get faster or slower at transcribing images as time progresses (if you tried to maintain the same accuracy)?', widget=widgets.RadioSelect, ) beliefp1q2 = models.StringField( choices=[['1', 'Considerably more mistakes'], ['2', 'Slightly more mistakes'],['3', 'No change'], ['4', 'Slightly fewer mistakes'], ['5', 'Considerably fewer mistakes']], label='Do you think you would make more or fewer mistakes as time progresses (if you tried to maintain the same typing speed)?', widget=widgets.RadioSelect, ) beliefp2q1 = models.FloatField( label="The first 15 minutes [minutes 0-15]", doc="""label for question 1a""", blank=False, min=0 ) beliefp2q2 = models.FloatField( label="The second 15 minutes [minutes 15-30]", doc="""label for question 1b""", blank=False, min=0 ) beliefp2q3 = models.FloatField( label="The third 15 minutes [minutes 30-45]", doc="""label for question 1c""", blank=False, min=0 ) beliefp2q4 = models.FloatField( label="The last 15 minutes [minutes 45-60]", doc="""label for question 1d""", blank=False, min=0 ) beliefp2q5 = models.FloatField( label="The first 15 minutes [minutes 0-15]", doc="""label for question 1a""", blank=False, min=0 ) beliefp2q6 = models.FloatField( label="The second 15 minutes [minutes 15-30]", doc="""label for question 1b""", blank=False, min=0 ) beliefp2q7 = models.FloatField( label="The third 15 minutes [minutes 30-45]", doc="""label for question 1c""", blank=False, min=0 ) beliefp2q8 = models.FloatField( label="The last 15 minutes [minutes 45-60]", doc="""label for question 1d""", blank=False, min=0 ) beliefp2q9 = models.FloatField( label="The first 15 minutes [minutes 0-15]", doc="""label for question 1a""", blank=False, min=0 ) beliefp2q10 = models.FloatField( label="The second 15 minutes [minutes 15-30]", doc="""label for question 1b""", blank=False, min=0 ) beliefp2q11 = models.FloatField( label="The third 15 minutes [minutes 30-45]", doc="""label for question 1c""", blank=False, min=0 ) beliefp2q12 = models.FloatField( label="The last 15 minutes [minutes 45-60]", doc="""label for question 1d""", blank=False, min=0 ) beliefp2q13 = models.FloatField( label="The first 15 minutes [minutes 0-15]", doc="""label for question 1a""", blank=False, min=0, max=100, ) beliefp2q14 = models.FloatField( label="The second 15 minutes [minutes 15-30]", doc="""label for question 1b""", blank=False, min=0, max=100, ) beliefp2q15 = models.FloatField( label="The third 15 minutes [minutes 30-45]", doc="""label for question 1c""", blank=False, min=0, max=100, ) beliefp2q16 = models.FloatField( label="The last 15 minutes [minutes 45-60]", doc="""label for question 1d""", blank=False, min=0, max=100, ) beliefp2q17 = models.FloatField( label="The last 15 minutes [minutes 45-60]", doc="""label for question 1d""", blank=False, min=0, max=100, ) beliefp2q18 = models.FloatField( label="The first 15 minutes [minutes 0-15]", doc="""label for question 1a""", blank=False, min=0, max=100, ) beliefp2q19 = models.FloatField( label="The second 15 minutes [minutes 15-30]", doc="""label for question 1b""", blank=False, min=0, max=100, ) beliefp2q20 = models.FloatField( label="The third 15 minutes [minutes 30-45]", doc="""label for question 1c""", blank=False, min=0, max=100, ) beliefp2q21 = models.FloatField( label="The last 15 minutes [minutes 45-60]", doc="""label for question 1d""", blank=False, min=0, max=100, ) beliefp2q22 = models.FloatField( label="The first 15 minutes [minutes 0-15]", doc="""label for question 1a""", blank=False, min=0, max=100, ) beliefp2q23 = models.FloatField( label="The second 15 minutes [minutes 15-30]", doc="""label for question 1b""", blank=False, min=0, max=100, ) beliefp2q24 = models.FloatField( label="The third 15 minutes [minutes 30-45]", doc="""label for question 1c""", blank=False, min=0, max=100, ) TimePlaceholder = models.FloatField()