# -*- 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_sum3' 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 = [ [ 44 , 14 , 88 , 13 , 60 ] , [ 96 , 54 , 67 , 56 , 75 ] , [ 62 , 87 , 32 , 79 , 42 ] , [ 27 , 45 , 28 , 26 , 15 ] , [ 54 , 89 , 17 , 69 , 73 ] , [ 45 , 25 , 47 , 41 , 70 ] , [ 71 , 89 , 49 , 90 , 24 ] , [ 19 , 73 , 43 , 15 , 66 ] , [ 15 , 28 , 21 , 33 , 71 ] , [ 73 , 41 , 11 , 74 , 18 ] , [ 53 , 55 , 26 , 63 , 85 ] , [ 47 , 65 , 13 , 13 , 51 ] , [ 32 , 66 , 11 , 94 , 14 ] , [ 47 , 86 , 31 , 84 , 44 ] , [ 82 , 96 , 39 , 42 , 95 ] , [ 29 , 17 , 17 , 78 , 36 ] , [ 54 , 59 , 66 , 63 , 22 ] , [ 45 , 20 , 54 , 11 , 28 ] , [ 14 , 49 , 26 , 64 , 41 ] , [ 98 , 97 , 21 , 86 , 96 ] , [ 74 , 15 , 74 , 59 , 26 ] , [ 52 , 64 , 34 , 59 , 16 ] , [ 94 , 14 , 19 , 54 , 32 ] , [ 62 , 14 , 18 , 62 , 15 ] , [ 73 , 41 , 98 , 42 , 48 ] , [ 37 , 78 , 45 , 24 , 94 ] , [ 27 , 20 , 26 , 38 , 58 ] , [ 57 , 93 , 60 , 96 , 16 ] , [ 71 , 88 , 35 , 88 , 48 ] , [ 75 , 44 , 66 , 44 , 72 ] , [ 39 , 29 , 32 , 62 , 26 ] , [ 12 , 71 , 17 , 97 , 97 ] , [ 69 , 33 , 23 , 78 , 27 ] , [ 18 , 69 , 48 , 87 , 65 ] , [ 29 , 70 , 44 , 55 , 44 ] , [ 97 , 45 , 66 , 81 , 30 ] , [ 87 , 82 , 82 , 26 , 57 ] , [ 31 , 82 , 34 , 47 , 97 ] , [ 70 , 27 , 60 , 45 , 20 ] , [ 66 , 88 , 48 , 83 , 56 ] , [ 87 , 80 , 55 , 46 , 12 ] , [ 11 , 25 , 12 , 74 , 35 ] , [ 52 , 23 , 57 , 54 , 73 ] , [ 55 , 27 , 54 , 64 , 60 ] , [ 91 , 32 , 47 , 61 , 57 ] , [ 95 , 60 , 11 , 36 , 34 ] , [ 40 , 43 , 63 , 76 , 83 ] , [ 60 , 94 , 55 , 91 , 70 ] , [ 84 , 37 , 40 , 48 , 72 ] , [ 30 , 54 , 88 , 57 , 94 ] , [ 27 , 74 , 28 , 54 , 56 ] , [ 57 , 13 , 18 , 28 , 29 ] , [ 86 , 95 , 73 , 50 , 86 ] , [ 52 , 47 , 10 , 91 , 76 ] , [ 33 , 37 , 11 , 43 , 35 ] , [ 50 , 50 , 92 , 47 , 87 ] , [ 80 , 32 , 43 , 62 , 31 ] , [ 83 , 45 , 42 , 83 , 40 ] , [ 18 , 74 , 13 , 96 , 41 ] , [ 37 , 45 , 34 , 30 , 80 ] , [ 20 , 13 , 89 , 36 , 53 ] , [ 14 , 30 , 15 , 24 , 54 ] , [ 82 , 87 , 88 , 93 , 81 ] , [ 44 , 65 , 97 , 17 , 49 ] , [ 25 , 35 , 66 , 28 , 70 ] , [ 65 , 26 , 73 , 49 , 85 ] , [ 42 , 68 , 73 , 16 , 29 ] , [ 42 , 37 , 57 , 16 , 22 ] , [ 28 , 41 , 61 , 44 , 77 ] , [ 46 , 77 , 50 , 43 , 40 ] , [ 27 , 84 , 53 , 29 , 28 ] , [ 96 , 41 , 76 , 78 , 26 ] , [ 90 , 18 , 29 , 82 , 74 ] , [ 30 , 89 , 22 , 61 , 42 ] , [ 54 , 97 , 33 , 97 , 29 ] , [ 75 , 83 , 21 , 83 , 96 ] , [ 86 , 57 , 18 , 99 , 92 ] , [ 10 , 74 , 84 , 27 , 11 ] , [ 40 , 94 , 89 , 83 , 77 ] , [ 63 , 14 , 97 , 80 , 24 ] , [ 62 , 97 , 62 , 66 , 50 ] , [ 78 , 91 , 63 , 85 , 84 ] , [ 87 , 86 , 14 , 87 , 82 ] , [ 65 , 86 , 85 , 71 , 31 ] , [ 30 , 35 , 91 , 89 , 30 ] , [ 58 , 49 , 85 , 50 , 49 ] , [ 67 , 82 , 73 , 53 , 83 ] , [ 80 , 19 , 10 , 94 , 33 ] , [ 49 , 67 , 45 , 51 , 61 ] , [ 76 , 58 , 52 , 65 , 76 ] , [ 57 , 23 , 87 , 26 , 52 ] , [ 11 , 76 , 39 , 24 , 30 ] , [ 32 , 52 , 51 , 23 , 22 ] , [ 92 , 66 , 46 , 87 , 84 ] , [ 65 , 66 , 52 , 39 , 63 ] , [ 50 , 35 , 77 , 35 , 94 ] , [ 98 , 75 , 62 , 33 , 63 ] , [ 32 , 80 , 80 , 76 , 82 ] , [ 81 , 66 , 25 , 93 , 19 ] , [ 30 , 71 , 94 , 15 , 90 ] , [ 68 , 37 , 80 , 58 , 19 ] , [ 49 , 92 , 83 , 18 , 32 ] , [ 35 , 58 , 65 , 90 , 64 ] , [ 79 , 72 , 41 , 12 , 36 ] , [ 11 , 61 , 24 , 10 , 76 ] , [ 43 , 89 , 30 , 54 , 26 ] , [ 20 , 33 , 87 , 29 , 64 ] , [ 66 , 83 , 18 , 35 , 65 ] , [ 60 , 54 , 12 , 55 , 87 ] , [ 60 , 96 , 52 , 90 , 18 ] , [ 98 , 98 , 87 , 61 , 45 ] , [ 68 , 18 , 62 , 32 , 96 ] , [ 17 , 34 , 43 , 94 , 25 ] , [ 64 , 12 , 73 , 52 , 97 ] , [ 28 , 27 , 89 , 75 , 64 ] , [ 76 , 56 , 65 , 57 , 96 ] , [ 26 , 29 , 93 , 84 , 97 ] , [ 92 , 40 , 19 , 89 , 50 ] , [ 52 , 22 , 63 , 95 , 83 ] , [ 61 , 75 , 62 , 20 , 93 ] , [ 26 , 36 , 65 , 91 , 88 ] , [ 59 , 86 , 34 , 31 , 39 ] , [ 14 , 34 , 29 , 41 , 57 ] , [ 23 , 12 , 57 , 75 , 53 ] , [ 26 , 91 , 23 , 73 , 72 ] , [ 24 , 27 , 76 , 35 , 61 ] , [ 85 , 80 , 75 , 30 , 19 ] , [ 21 , 18 , 80 , 45 , 92 ] , [ 90 , 32 , 56 , 67 , 44 ] , [ 94 , 96 , 77 , 79 , 49 ] , [ 90 , 33 , 39 , 20 , 73 ] , [ 49 , 36 , 26 , 34 , 54 ] , [ 45 , 46 , 13 , 13 , 28 ] , [ 61 , 12 , 95 , 98 , 30 ] , [ 35 , 86 , 83 , 18 , 84 ] , [ 24 , 89 , 57 , 95 , 40 ] , [ 78 , 66 , 71 , 95 , 16 ] , [ 32 , 27 , 21 , 76 , 23 ] , [ 53 , 72 , 18 , 51 , 55 ] , [ 72 , 17 , 61 , 33 , 55 ] , [ 60 , 42 , 37 , 78 , 58 ] , [ 81 , 89 , 59 , 72 , 91 ] , [ 17 , 40 , 50 , 29 , 26 ] , [ 76 , 44 , 53 , 78 , 88 ] , [ 44 , 86 , 70 , 31 , 54 ] , [ 74 , 71 , 24 , 20 , 41 ] , [ 40 , 85 , 31 , 50 , 26 ] , [ 41 , 20 , 19 , 46 , 22 ] , [ 42 , 26 , 57 , 44 , 81 ] , [ 96 , 89 , 16 , 37 , 21 ] ] class Subsession(BaseSubsession): pass # def before_session_starts(self): # players = self.get_players() # 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) # p.solution = p.int1 + p.int2 class Group(BaseGroup): pass class Player(BasePlayer): Enter = models.IntegerField( choices=[ [0, '50 cents.'], [1, '$2, if you answer more problems correctly than anyone in your group did in the last task; $0, otherwise'], ], widget=widgets.RadioSelect ) 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''' )