rturk 2.9.0 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +7 -0
- data/Gemfile +1 -6
- data/lib/rturk/adapters/hit.rb +6 -3
- data/lib/rturk/operations/get_assignments_for_hit.rb +3 -2
- data/lib/rturk/version.rb +1 -1
- data/rturk.gemspec +1 -0
- data/spec/adapters/hit_spec.rb +29 -0
- data/spec/fake_responses/get_approved_assignments.xml +35 -0
- data/spec/fake_responses/get_rejected_assignments.xml +35 -0
- data/spec/fake_responses/get_submitted_assignments.xml +35 -0
- data/spec/spec_helper.rb +6 -1
- metadata +20 -1
data/CHANGELOG.markdown
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
2.9.0
|
2
|
+
---
|
3
|
+
* Added 'approve_rejected' [chrisconley]
|
4
|
+
* Add additional attributes to HIT's [seeingidog]
|
5
|
+
* Fixed constant value bug [karimn]
|
6
|
+
* Fix unescaped HTML in raw XML [seeingidog]
|
7
|
+
|
1
8
|
2.8.0
|
2
9
|
----
|
3
10
|
* Adding support for operation SearchQualificationTypes [hampei]
|
data/Gemfile
CHANGED
data/lib/rturk/adapters/hit.rb
CHANGED
@@ -61,11 +61,14 @@ module RTurk
|
|
61
61
|
end
|
62
62
|
|
63
63
|
# memoing
|
64
|
-
def assignments
|
65
|
-
@assignments ||=
|
66
|
-
|
64
|
+
def assignments(options={})
|
65
|
+
@assignments ||= begin
|
66
|
+
assignments_options = options.update(:hit_id => self.id)
|
67
|
+
|
68
|
+
RTurk::GetAssignmentsForHIT(assignments_options).assignments.inject([]) do |arr, assignment|
|
67
69
|
arr << RTurk::Assignment.new(assignment.assignment_id, assignment)
|
68
70
|
end
|
71
|
+
end
|
69
72
|
end
|
70
73
|
|
71
74
|
def details
|
@@ -3,7 +3,7 @@ module RTurk
|
|
3
3
|
|
4
4
|
require_params :hit_id
|
5
5
|
|
6
|
-
attr_accessor :hit_id, :page_size, :page_number
|
6
|
+
attr_accessor :hit_id, :page_size, :page_number, :status
|
7
7
|
|
8
8
|
def parse(xml)
|
9
9
|
GetAssignmentsForHITResponse.new(xml)
|
@@ -12,7 +12,8 @@ module RTurk
|
|
12
12
|
def to_params
|
13
13
|
{'HITId' => hit_id,
|
14
14
|
'PageSize' => (page_size || 100),
|
15
|
-
'PageNumber' => page_number
|
15
|
+
'PageNumber' => page_number,
|
16
|
+
'AssignmentStatus' => status}
|
16
17
|
end
|
17
18
|
|
18
19
|
end
|
data/lib/rturk/version.rb
CHANGED
data/rturk.gemspec
CHANGED
data/spec/adapters/hit_spec.rb
CHANGED
@@ -8,7 +8,19 @@ describe "HIT adapter" do
|
|
8
8
|
faker('create_hit', :operation => 'CreateHIT')
|
9
9
|
faker('get_hit', :operation => 'GetHIT')
|
10
10
|
faker('get_reviewable_hits', :operation => 'GetReviewableHITs')
|
11
|
+
|
11
12
|
faker('get_assignments', :operation => 'GetAssignments')
|
13
|
+
|
14
|
+
faker('get_rejected_assignments',
|
15
|
+
:params => {"AssignmentStatus" => "Rejected"}
|
16
|
+
)
|
17
|
+
faker('get_submitted_assignments',
|
18
|
+
:params => {"AssignmentStatus" => "Submitted"}
|
19
|
+
)
|
20
|
+
faker('get_approved_assignments',
|
21
|
+
:params => {"AssignmentStatus" => "Approved"}
|
22
|
+
)
|
23
|
+
|
12
24
|
faker('extend_hit', :operation => 'ExtendHIT')
|
13
25
|
faker('force_expire_hit', :operation => 'ForceExpireHIT')
|
14
26
|
faker('dispose_hit', :operation => 'DisposeHIT')
|
@@ -53,6 +65,23 @@ describe "HIT adapter" do
|
|
53
65
|
hits = RTurk::Hit.all_reviewable
|
54
66
|
hits.first.assignments.first.answers["tweet"].should eql('This is my tweet!')
|
55
67
|
end
|
68
|
+
|
69
|
+
context "assignment state" do
|
70
|
+
it "finds approved", :focus => true do
|
71
|
+
hits = RTurk::Hit.all_reviewable
|
72
|
+
hits.first.assignments(:status => "Approved").first.answers["tweet"].should eql("I Was approved!")
|
73
|
+
end
|
74
|
+
|
75
|
+
it "finds rejected" do
|
76
|
+
hits = RTurk::Hit.all_reviewable
|
77
|
+
hits.first.assignments(:status => "Rejected").first.answers["tweet"].should eql("I was rejected!")
|
78
|
+
end
|
79
|
+
|
80
|
+
it "finds submitted" do
|
81
|
+
hits = RTurk::Hit.all_reviewable
|
82
|
+
hits.first.assignments(:status => "Submitted").first.answers["tweet"].should eql("I was submitted!")
|
83
|
+
end
|
84
|
+
end
|
56
85
|
|
57
86
|
it "should add time to a hit" do
|
58
87
|
hits = RTurk::Hit.all_reviewable
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<GetAssignmentsForHITResponse>
|
3
|
+
<OperationRequest>
|
4
|
+
<RequestId>a964d1f8-d315-4bbb-9ab6-692625d662ff</RequestId>
|
5
|
+
</OperationRequest>
|
6
|
+
<GetAssignmentsForHITResult>
|
7
|
+
<Request>
|
8
|
+
<IsValid>True</IsValid>
|
9
|
+
</Request>
|
10
|
+
<NumResults>1</NumResults>
|
11
|
+
<TotalNumResults>1</TotalNumResults>
|
12
|
+
<PageNumber>1</PageNumber>
|
13
|
+
<Assignment>
|
14
|
+
<AssignmentId>32A8TDZQEZYRV84XKZ4ZBT6JT05DKJRZ1BC42YSZ</AssignmentId>
|
15
|
+
<WorkerId>ADOJP7RNRYAFG</WorkerId>
|
16
|
+
<HITId>32A8TDZQEZYRV84XKZ4Z</HITId>
|
17
|
+
<AssignmentStatus>Approved</AssignmentStatus>
|
18
|
+
<AutoApprovalTime>2009-11-25T05:17:32Z</AutoApprovalTime>
|
19
|
+
<AcceptTime>2009-10-26T05:17:18Z</AcceptTime>
|
20
|
+
<SubmitTime>2009-10-26T05:17:32Z</SubmitTime>
|
21
|
+
<Answer><?xml version="1.0" encoding="UTF-8"?>
|
22
|
+
<QuestionFormAnswers xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionFormAnswers.xsd">
|
23
|
+
<Answer>
|
24
|
+
<QuestionIdentifier>tweet</QuestionIdentifier>
|
25
|
+
<FreeText>I Was approved!</FreeText>
|
26
|
+
</Answer>
|
27
|
+
<Answer>
|
28
|
+
<QuestionIdentifier>Submit</QuestionIdentifier>
|
29
|
+
<FreeText>Submit</FreeText>
|
30
|
+
</Answer>
|
31
|
+
</QuestionFormAnswers>
|
32
|
+
</Answer>
|
33
|
+
</Assignment>
|
34
|
+
</GetAssignmentsForHITResult>
|
35
|
+
</GetAssignmentsForHITResponse>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<GetAssignmentsForHITResponse>
|
3
|
+
<OperationRequest>
|
4
|
+
<RequestId>a964d1f8-d315-4bbb-9ab6-692625d662ff</RequestId>
|
5
|
+
</OperationRequest>
|
6
|
+
<GetAssignmentsForHITResult>
|
7
|
+
<Request>
|
8
|
+
<IsValid>True</IsValid>
|
9
|
+
</Request>
|
10
|
+
<NumResults>1</NumResults>
|
11
|
+
<TotalNumResults>1</TotalNumResults>
|
12
|
+
<PageNumber>1</PageNumber>
|
13
|
+
<Assignment>
|
14
|
+
<AssignmentId>32A8TDZQEZYRV84XKZ4ZBT6JT05DKJRZ1BC42YSZ</AssignmentId>
|
15
|
+
<WorkerId>ADOJP7RNRYAFG</WorkerId>
|
16
|
+
<HITId>32A8TDZQEZYRV84XKZ4Z</HITId>
|
17
|
+
<AssignmentStatus>Rejected</AssignmentStatus>
|
18
|
+
<AutoApprovalTime>2009-11-25T05:17:32Z</AutoApprovalTime>
|
19
|
+
<AcceptTime>2009-10-26T05:17:18Z</AcceptTime>
|
20
|
+
<SubmitTime>2009-10-26T05:17:32Z</SubmitTime>
|
21
|
+
<Answer><?xml version="1.0" encoding="UTF-8"?>
|
22
|
+
<QuestionFormAnswers xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionFormAnswers.xsd">
|
23
|
+
<Answer>
|
24
|
+
<QuestionIdentifier>tweet</QuestionIdentifier>
|
25
|
+
<FreeText>I was rejected!</FreeText>
|
26
|
+
</Answer>
|
27
|
+
<Answer>
|
28
|
+
<QuestionIdentifier>Submit</QuestionIdentifier>
|
29
|
+
<FreeText>Submit</FreeText>
|
30
|
+
</Answer>
|
31
|
+
</QuestionFormAnswers>
|
32
|
+
</Answer>
|
33
|
+
</Assignment>
|
34
|
+
</GetAssignmentsForHITResult>
|
35
|
+
</GetAssignmentsForHITResponse>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<GetAssignmentsForHITResponse>
|
3
|
+
<OperationRequest>
|
4
|
+
<RequestId>a964d1f8-d315-4bbb-9ab6-692625d662ff</RequestId>
|
5
|
+
</OperationRequest>
|
6
|
+
<GetAssignmentsForHITResult>
|
7
|
+
<Request>
|
8
|
+
<IsValid>True</IsValid>
|
9
|
+
</Request>
|
10
|
+
<NumResults>1</NumResults>
|
11
|
+
<TotalNumResults>1</TotalNumResults>
|
12
|
+
<PageNumber>1</PageNumber>
|
13
|
+
<Assignment>
|
14
|
+
<AssignmentId>32A8TDZQEZYRV84XKZ4ZBT6JT05DKJRZ1BC42YSZ</AssignmentId>
|
15
|
+
<WorkerId>ADOJP7RNRYAFG</WorkerId>
|
16
|
+
<HITId>32A8TDZQEZYRV84XKZ4Z</HITId>
|
17
|
+
<AssignmentStatus>Submitted</AssignmentStatus>
|
18
|
+
<AutoApprovalTime>2009-11-25T05:17:32Z</AutoApprovalTime>
|
19
|
+
<AcceptTime>2009-10-26T05:17:18Z</AcceptTime>
|
20
|
+
<SubmitTime>2009-10-26T05:17:32Z</SubmitTime>
|
21
|
+
<Answer><?xml version="1.0" encoding="UTF-8"?>
|
22
|
+
<QuestionFormAnswers xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionFormAnswers.xsd">
|
23
|
+
<Answer>
|
24
|
+
<QuestionIdentifier>tweet</QuestionIdentifier>
|
25
|
+
<FreeText>I was submitted!</FreeText>
|
26
|
+
</Answer>
|
27
|
+
<Answer>
|
28
|
+
<QuestionIdentifier>Submit</QuestionIdentifier>
|
29
|
+
<FreeText>Submit</FreeText>
|
30
|
+
</Answer>
|
31
|
+
</QuestionFormAnswers>
|
32
|
+
</Answer>
|
33
|
+
</Assignment>
|
34
|
+
</GetAssignmentsForHITResult>
|
35
|
+
</GetAssignmentsForHITResponse>
|
data/spec/spec_helper.rb
CHANGED
@@ -3,7 +3,6 @@ $: << SPEC_ROOT
|
|
3
3
|
$: << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
4
|
require 'rubygems'
|
5
5
|
require 'spec'
|
6
|
-
require 'fakeweb'
|
7
6
|
require 'yaml'
|
8
7
|
require 'webmock'
|
9
8
|
include WebMock::API
|
@@ -18,6 +17,12 @@ def faker(response_name, opts = {})
|
|
18
17
|
response = File.read(File.join(SPEC_ROOT, 'fake_responses', "#{response_name.to_s}.xml"))
|
19
18
|
if opts[:operation]
|
20
19
|
stub_request(:post, /amazonaws.com/).with(:body => /Operation=#{opts[:operation]}/).to_return(:body => response)
|
20
|
+
elsif opts[:params]
|
21
|
+
stub_request(:post, /amazonaws.com/).with do |request|
|
22
|
+
opts[:params].reject do |key, value|
|
23
|
+
!(request.body =~ /#{key}=#{value}/)
|
24
|
+
end.length == opts[:params].length
|
25
|
+
end.to_return(:body => response)
|
21
26
|
else
|
22
27
|
stub_request(:post, /amazonaws.com/).to_return(:body => response)
|
23
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rturk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -62,6 +62,22 @@ dependencies:
|
|
62
62
|
- - ~>
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: 1.3.1
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: rake
|
67
|
+
requirement: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
type: :development
|
74
|
+
prerelease: false
|
75
|
+
version_requirements: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
65
81
|
- !ruby/object:Gem::Dependency
|
66
82
|
name: webmock
|
67
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -280,6 +296,7 @@ files:
|
|
280
296
|
- spec/fake_responses/extend_hit.xml
|
281
297
|
- spec/fake_responses/force_expire_hit.xml
|
282
298
|
- spec/fake_responses/get_account_balance.xml
|
299
|
+
- spec/fake_responses/get_approved_assignments.xml
|
283
300
|
- spec/fake_responses/get_assignment.xml
|
284
301
|
- spec/fake_responses/get_assignments.xml
|
285
302
|
- spec/fake_responses/get_assignments_multiple.xml
|
@@ -288,7 +305,9 @@ files:
|
|
288
305
|
- spec/fake_responses/get_qualification_requests.xml
|
289
306
|
- spec/fake_responses/get_qualification_type.xml
|
290
307
|
- spec/fake_responses/get_qualifications_for_qualification_type.xml
|
308
|
+
- spec/fake_responses/get_rejected_assignments.xml
|
291
309
|
- spec/fake_responses/get_reviewable_hits.xml
|
310
|
+
- spec/fake_responses/get_submitted_assignments.xml
|
292
311
|
- spec/fake_responses/grant_bonus.xml
|
293
312
|
- spec/fake_responses/grant_qualification.xml
|
294
313
|
- spec/fake_responses/invalid_credentials.xml
|