# -*- coding: utf-8 -*- # from __future__ import division # import otree.models # from otree.db import models # from otree import widgets # from otree.common import Currency as c, currency_range, safe_json # from otree.constants import BaseConstants # from otree.models import BaseSubsession, BaseGroup, BasePlayer from otree.api import * import random import csv # author = 'Curtis Kephart (economicurtis@gmail.com)' doc = """ Real Effort Task. Add as many ints as possible. """ class Constants(BaseConstants): name_in_url = 'task_sum' players_per_group = 4 task_timer = 120 #see Subsession, before_session_starts setting. num_rounds = 100 # must be more than the max one person can do in task_timer seconds INTS_T1 = [ [ 24 , 33 , 69 , 92 , 32 ] , [ 21 , 88 , 13 , 46 , 80 ] , [ 86 , 53 , 87 , 26 , 89 ] , [ 97 , 95 , 11 , 65 , 57 ] , [ 14 , 93 , 46 , 85 , 73 ] , [ 63 , 94 , 34 , 60 , 27 ] , [ 48 , 75 , 43 , 85 , 67 ] , [ 98 , 58 , 20 , 21 , 87 ] , [ 22 , 14 , 74 , 46 , 51 ] , [ 21 , 65 , 86 , 38 , 26 ] , [ 22 , 17 , 94 , 69 , 72 ] , [ 45 , 42 , 26 , 84 , 92 ] , [ 81 , 52 , 70 , 35 , 85 ] , [ 72 , 83 , 31 , 21 , 35 ] , [ 20 , 76 , 51 , 38 , 13 ] , [ 23 , 22 , 69 , 18 , 19 ] , [ 28 , 31 , 68 , 53 , 28 ] , [ 38 , 98 , 27 , 46 , 53 ] , [ 16 , 18 , 98 , 99 , 49 ] , [ 65 , 57 , 41 , 11 , 70 ] , [ 26 , 26 , 33 , 51 , 46 ] , [ 59 , 38 , 14 , 28 , 95 ] , [ 33 , 21 , 50 , 41 , 45 ] , [ 52 , 57 , 72 , 37 , 37 ] , [ 87 , 17 , 19 , 18 , 76 ] , [ 31 , 29 , 32 , 47 , 28 ] , [ 31 , 87 , 76 , 10 , 82 ] , [ 60 , 93 , 42 , 84 , 72 ] , [ 26 , 12 , 78 , 89 , 87 ] , [ 25 , 72 , 39 , 83 , 88 ] , [ 33 , 92 , 64 , 58 , 56 ] , [ 93 , 64 , 40 , 33 , 84 ] , [ 88 , 63 , 13 , 43 , 80 ] , [ 95 , 93 , 60 , 34 , 31 ] , [ 94 , 66 , 42 , 14 , 42 ] , [ 75 , 99 , 73 , 49 , 31 ] , [ 19 , 44 , 21 , 97 , 74 ] , [ 47 , 26 , 52 , 94 , 29 ] , [ 17 , 11 , 81 , 23 , 73 ] , [ 23 , 55 , 87 , 90 , 52 ] , [ 96 , 15 , 81 , 50 , 67 ] , [ 58 , 35 , 25 , 89 , 86 ] , [ 61 , 53 , 24 , 14 , 46 ] , [ 20 , 61 , 98 , 79 , 93 ] , [ 93 , 11 , 99 , 83 , 48 ] , [ 76 , 82 , 41 , 72 , 51 ] , [ 51 , 62 , 61 , 30 , 82 ] , [ 94 , 43 , 42 , 85 , 72 ] , [ 76 , 96 , 52 , 80 , 68 ] , [ 78 , 31 , 50 , 84 , 53 ] , [ 27 , 19 , 88 , 22 , 98 ] , [ 66 , 33 , 72 , 26 , 68 ] , [ 31 , 64 , 35 , 97 , 53 ] , [ 60 , 47 , 27 , 65 , 48 ] , [ 60 , 10 , 82 , 23 , 78 ] , [ 36 , 55 , 44 , 87 , 37 ] , [ 74 , 19 , 54 , 82 , 36 ] , [ 67 , 91 , 32 , 15 , 22 ] , [ 37 , 36 , 49 , 22 , 88 ] , [ 27 , 10 , 13 , 83 , 15 ] , [ 67 , 78 , 24 , 19 , 41 ] , [ 36 , 80 , 78 , 52 , 58 ] , [ 30 , 61 , 30 , 67 , 62 ] , [ 47 , 39 , 25 , 34 , 32 ] , [ 13 , 32 , 49 , 45 , 88 ] , [ 44 , 70 , 54 , 12 , 91 ] , [ 37 , 49 , 39 , 96 , 22 ] , [ 96 , 73 , 62 , 45 , 60 ] , [ 23 , 94 , 26 , 99 , 38 ] , [ 83 , 81 , 17 , 50 , 14 ] , [ 44 , 79 , 52 , 55 , 88 ] , [ 76 , 23 , 39 , 32 , 36 ] , [ 62 , 52 , 40 , 28 , 43 ] , [ 20 , 45 , 30 , 62 , 34 ] , [ 89 , 45 , 50 , 89 , 23 ] , [ 71 , 54 , 37 , 27 , 38 ] , [ 40 , 23 , 16 , 56 , 22 ] , [ 44 , 23 , 48 , 63 , 77 ] , [ 64 , 48 , 14 , 71 , 80 ] , [ 27 , 99 , 27 , 21 , 10 ] , [ 94 , 74 , 37 , 94 , 16 ] , [ 37 , 85 , 61 , 67 , 52 ] , [ 15 , 13 , 14 , 31 , 71 ] , [ 79 , 13 , 28 , 56 , 91 ] , [ 48 , 80 , 10 , 55 , 21 ] , [ 13 , 17 , 12 , 27 , 31 ] , [ 64 , 27 , 73 , 53 , 11 ] , [ 21 , 76 , 19 , 26 , 32 ] , [ 18 , 36 , 31 , 95 , 54 ] , [ 25 , 58 , 48 , 16 , 90 ] , [ 90 , 35 , 87 , 97 , 63 ] , [ 14 , 46 , 77 , 30 , 63 ] , [ 56 , 65 , 42 , 61 , 38 ] , [ 93 , 10 , 90 , 62 , 69 ] , [ 18 , 66 , 29 , 79 , 23 ] , [ 32 , 89 , 68 , 35 , 39 ] , [ 97 , 68 , 83 , 25 , 36 ] , [ 87 , 57 , 23 , 15 , 93 ] , [ 93 , 68 , 88 , 32 , 13 ] , [ 50 , 85 , 98 , 80 , 64 ] , [ 53 , 49 , 36 , 61 , 53 ] , [ 68 , 92 , 12 , 26 , 80 ] , [ 16 , 23 , 39 , 67 , 81 ] , [ 57 , 56 , 95 , 66 , 45 ] , [ 84 , 11 , 50 , 81 , 32 ] , [ 72 , 89 , 25 , 84 , 31 ] , [ 56 , 77 , 68 , 20 , 28 ] , [ 10 , 65 , 21 , 86 , 35 ] , [ 96 , 34 , 43 , 58 , 99 ] , [ 12 , 19 , 46 , 82 , 29 ] , [ 94 , 92 , 87 , 29 , 48 ] , [ 84 , 99 , 94 , 91 , 92 ] , [ 94 , 23 , 30 , 37 , 55 ] , [ 12 , 98 , 61 , 35 , 54 ] , [ 69 , 89 , 65 , 20 , 76 ] , [ 17 , 71 , 87 , 44 , 67 ] , [ 14 , 36 , 28 , 75 , 92 ] , [ 54 , 18 , 42 , 21 , 86 ] , [ 35 , 42 , 88 , 27 , 16 ] , [ 38 , 48 , 29 , 81 , 59 ] , [ 13 , 70 , 98 , 43 , 54 ] , [ 49 , 25 , 80 , 31 , 81 ] , [ 69 , 58 , 85 , 63 , 67 ] , [ 62 , 71 , 69 , 34 , 65 ] , [ 24 , 75 , 91 , 14 , 96 ] , [ 18 , 12 , 21 , 30 , 29 ] , [ 58 , 35 , 30 , 25 , 36 ] , [ 70 , 42 , 27 , 30 , 94 ] , [ 40 , 80 , 75 , 52 , 46 ] , [ 19 , 36 , 32 , 16 , 67 ] , [ 28 , 66 , 45 , 62 , 26 ] , [ 39 , 71 , 22 , 25 , 22 ] , [ 94 , 94 , 71 , 26 , 74 ] , [ 34 , 88 , 73 , 80 , 18 ] , [ 30 , 32 , 34 , 19 , 79 ] , [ 60 , 82 , 58 , 18 , 92 ] , [ 73 , 11 , 23 , 43 , 35 ] , [ 48 , 94 , 85 , 37 , 58 ] , [ 59 , 70 , 28 , 30 , 96 ] , [ 91 , 92 , 93 , 54 , 36 ] , [ 49 , 61 , 66 , 85 , 97 ] , [ 29 , 31 , 18 , 16 , 60 ] , [ 85 , 79 , 48 , 46 , 42 ] , [ 58 , 92 , 85 , 46 , 94 ] , [ 11 , 35 , 60 , 32 , 26 ] , [ 34 , 92 , 76 , 60 , 62 ] , [ 84 , 43 , 53 , 94 , 43 ] , [ 16 , 25 , 40 , 54 , 81 ] , [ 21 , 26 , 85 , 56 , 91 ] , [ 66 , 83 , 20 , 16 , 62 ] ] class Subsession(BaseSubsession): def creating_session(self): # def before_session_starts(self): if 'task_timer' in self.session.config: task_timer = self.session.config['task_timer'] else: task_timer = Constants.task_timer for p in self.get_players(): p.task_timer = task_timer p.int1 = Constants.INTS_T1[self.round_number - 1][0] # did not return a value below may cause problems # p.int1 = random.randint(10, 99) p.int2 = Constants.INTS_T1[self.round_number - 1][1] # p.int2 = random.randint(10, 99) # i added the next 3 lines and editted the 4th p.int3 = Constants.INTS_T1[self.round_number - 1][2] p.int4 = Constants.INTS_T1[self.round_number - 1][3] p.int5 = Constants.INTS_T1[self.round_number - 1][4] p.solution = p.int1 + p.int2 + p.int3 + p.int4 + p.int5 # i added the next line p.payoff_score = 0 class Group(BaseGroup): pass class Player(BasePlayer): def score_round(self): # update player payoffs if (self.solution == self.user_total): self.is_correct = True self.payoff_score = 1 else: self.is_correct = False self.payoff_score = 0 task_timer = models.IntegerField( doc="""The length of the real effort task timer.""" ) int1 = models.IntegerField( doc="this round's first int") int2 = models.IntegerField( doc="this round's second int") int3 = models.IntegerField( doc="this round's second int") int4 = models.IntegerField( doc="this round's second int") int5 = models.IntegerField( doc="this round's second int") solution = models.IntegerField( doc="this round's correct summation") user_total = models.IntegerField( min = 1, max = 9999, doc="user's summation", # widget=widgets.TextInput(attrs={'autocomplete':'off'})) widget=widgets.TextInput()) is_correct = models.BooleanField( doc="did the user get the task correct?") payoff_score = models.FloatField( doc = '''score in this task''' )