1
# Copyright (c) 2008 Chris Moyer http://coredumped.org/
3
# Permission is hereby granted, free of charge, to any person obtaining a
4
# copy of this software and associated documentation files (the
5
# "Software"), to deal in the Software without restriction, including
6
# without limitation the rights to use, copy, modify, merge, publish, dis-
7
# tribute, sublicense, and/or sell copies of the Software, and to permit
8
# persons to whom the Software is furnished to do so, subject to the fol-
11
# The above copyright notice and this permission notice shall be included
12
# in all copies or substantial portions of the Software.
14
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
def __init__(self, requirements = []):
25
self.requirements = requirements
28
self.requirements.append(req)
30
def get_as_params(self):
32
assert(len(self.requirements) <= 10)
33
for n, req in enumerate(self.requirements):
34
reqparams = req.get_as_params()
36
params['QualificationRequirement.%s.%s' % ((n+1),rp) ] = reqparams[rp]
40
class Requirement(object):
42
Representation of a single requirement
45
def __init__(self, qualification_type_id, comparator, integer_value, required_to_preview=False):
46
self.qualification_type_id = qualification_type_id
47
self.comparator = comparator
48
self.integer_value = integer_value
49
self.required_to_preview = required_to_preview
51
def get_as_params(self):
53
"QualificationTypeId": self.qualification_type_id,
54
"Comparator": self.comparator,
55
"IntegerValue": self.integer_value,
57
if self.required_to_preview:
58
params['RequiredToPreview'] = "true"
61
class PercentAssignmentsSubmittedRequirement(Requirement):
63
The percentage of assignments the Worker has submitted, over all assignments the Worker has accepted. The value is an integer between 0 and 100.
66
def __init__(self, comparator, integer_value, required_to_preview=False):
67
Requirement.__init__(self, qualification_type_id="00000000000000000000", comparator=comparator, integer_value=integer_value, required_to_preview=required_to_preview)
69
class PercentAssignmentsAbandonedRequirement(Requirement):
71
The percentage of assignments the Worker has abandoned (allowed the deadline to elapse), over all assignments the Worker has accepted. The value is an integer between 0 and 100.
74
def __init__(self, comparator, integer_value, required_to_preview=False):
75
Requirement.__init__(self, qualification_type_id="00000000000000000070", comparator=comparator, integer_value=integer_value, required_to_preview=required_to_preview)
77
class PercentAssignmentsReturnedRequirement(Requirement):
79
The percentage of assignments the Worker has returned, over all assignments the Worker has accepted. The value is an integer between 0 and 100.
82
def __init__(self, comparator, integer_value, required_to_preview=False):
83
Requirement.__init__(self, qualification_type_id="000000000000000000E0", comparator=comparator, integer_value=integer_value, required_to_preview=required_to_preview)
85
class PercentAssignmentsApprovedRequirement(Requirement):
87
The percentage of assignments the Worker has submitted that were subsequently approved by the Requester, over all assignments the Worker has submitted. The value is an integer between 0 and 100.
90
def __init__(self, comparator, integer_value, required_to_preview=False):
91
Requirement.__init__(self, qualification_type_id="000000000000000000L0", comparator=comparator, integer_value=integer_value, required_to_preview=required_to_preview)
93
class PercentAssignmentsRejectedRequirement(Requirement):
95
The percentage of assignments the Worker has submitted that were subsequently rejected by the Requester, over all assignments the Worker has submitted. The value is an integer between 0 and 100.
98
def __init__(self, comparator, integer_value, required_to_preview=False):
99
Requirement.__init__(self, qualification_type_id="000000000000000000S0", comparator=comparator, integer_value=integer_value, required_to_preview=required_to_preview)
101
class LocaleRequirement(Requirement):
103
A Qualification requirement based on the Worker's location. The Worker's location is specified by the Worker to Mechanical Turk when the Worker creates his account.
106
def __init__(self, comparator, locale, required_to_preview=False):
107
Requirement.__init__(self, qualification_type_id="00000000000000000071", comparator=comparator, integer_value=None, required_to_preview=required_to_preview)
110
def get_as_params(self):
112
"QualificationTypeId": self.qualification_type_id,
113
"Comparator": self.comparator,
114
'LocaleValue.Country': self.locale,
116
if self.required_to_preview:
117
params['RequiredToPreview'] = "true"