rturk 1.0.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/.gitmodules +3 -0
  2. data/.yardoc +0 -0
  3. data/README.markdown +49 -29
  4. data/Rakefile +53 -0
  5. data/TODO.markdown +3 -0
  6. data/VERSION +1 -1
  7. data/examples/blank_slate.rb +21 -4
  8. data/examples/create_hit.rb +19 -0
  9. data/examples/newtweet.html +0 -1
  10. data/examples/review_answer.rb +18 -5
  11. data/lib/rturk.rb +33 -6
  12. data/lib/rturk/adapters/answers.rb +38 -0
  13. data/lib/rturk/adapters/assignment.rb +75 -0
  14. data/lib/rturk/adapters/hit.rb +97 -0
  15. data/lib/rturk/builders/qualification_builder.rb +68 -0
  16. data/lib/rturk/builders/qualifications_builder.rb +43 -0
  17. data/lib/rturk/builders/question_builder.rb +51 -0
  18. data/lib/rturk/errors.rb +5 -0
  19. data/lib/rturk/logger.rb +20 -0
  20. data/lib/rturk/macros.rb +35 -0
  21. data/lib/rturk/operation.rb +86 -0
  22. data/lib/rturk/operations/approve_assignment.rb +28 -0
  23. data/lib/rturk/operations/create_hit.rb +77 -0
  24. data/lib/rturk/operations/disable_hit.rb +19 -0
  25. data/lib/rturk/operations/dispose_hit.rb +19 -0
  26. data/lib/rturk/operations/force_expire_hit.rb +18 -0
  27. data/lib/rturk/operations/get_account_balance.rb +15 -0
  28. data/lib/rturk/operations/get_assignments_for_hit.rb +24 -0
  29. data/lib/rturk/operations/get_hit.rb +21 -0
  30. data/lib/rturk/operations/get_reviewable_hits.rb +23 -0
  31. data/lib/rturk/operations/grant_bonus.rb +26 -0
  32. data/lib/rturk/operations/reject_assignment.rb +23 -0
  33. data/lib/rturk/requester.rb +58 -76
  34. data/lib/rturk/response.rb +58 -0
  35. data/lib/rturk/responses/create_hit_response.rb +33 -0
  36. data/lib/rturk/responses/get_account_balance_response.rb +11 -0
  37. data/lib/rturk/responses/get_assignments_for_hit_response.rb +43 -0
  38. data/lib/rturk/responses/get_hit_response.rb +80 -0
  39. data/lib/rturk/responses/get_reviewable_hits_response.rb +33 -0
  40. data/lib/rturk/utilities.rb +19 -1
  41. data/lib/rturk/xml_utilities.rb +23 -0
  42. data/rturk.gemspec +143 -0
  43. data/spec/adapters/answers_spec.rb +27 -0
  44. data/spec/adapters/assignment_spec.rb +0 -0
  45. data/spec/adapters/hit_spec.rb +46 -0
  46. data/spec/builders/qualification_spec.rb +53 -0
  47. data/spec/builders/qualifications_spec.rb +30 -0
  48. data/spec/builders/question_spec.rb +46 -0
  49. data/spec/fake_responses/approve_assignment.xml +5 -0
  50. data/spec/fake_responses/create_hit.xml +12 -0
  51. data/spec/fake_responses/disable_hit.xml +5 -0
  52. data/spec/fake_responses/dispose_hit.xml +5 -0
  53. data/spec/fake_responses/force_expire_hit.xml +5 -0
  54. data/spec/fake_responses/get_account_balance.xml +10 -0
  55. data/spec/fake_responses/get_assignments.xml +35 -0
  56. data/spec/fake_responses/get_hit.xml +41 -0
  57. data/spec/fake_responses/get_reviewable_hits.xml +17 -0
  58. data/spec/fake_responses/grant_bonus.xml +5 -0
  59. data/spec/fake_responses/invalid_credentials.xml +12 -0
  60. data/spec/fake_responses/reject_assignment.xml +5 -0
  61. data/spec/operations/approve_assignment_spec.rb +27 -0
  62. data/spec/operations/create_hit_spec.rb +66 -0
  63. data/spec/operations/disable_hit_spec.rb +26 -0
  64. data/spec/operations/dispose_hit_spec.rb +26 -0
  65. data/spec/operations/force_expire_hit_spec.rb +26 -0
  66. data/spec/operations/get_account_balance_spec.rb +15 -0
  67. data/spec/operations/get_assignments_spec.rb +26 -0
  68. data/spec/operations/get_hit_spec.rb +18 -0
  69. data/spec/operations/get_reviewable_hits_spec.rb +0 -0
  70. data/spec/operations/grant_bonus_spec.rb +32 -0
  71. data/spec/operations/reject_assignment_spec.rb +26 -0
  72. data/spec/requester_spec.rb +7 -18
  73. data/spec/response_spec.rb +48 -0
  74. data/spec/rturk_spec.rb +27 -0
  75. data/spec/spec_helper.rb +28 -3
  76. data/spec/tmp +2 -0
  77. data/spec/xml_parse_spec.rb +32 -0
  78. metadata +94 -34
  79. data/examples/external_page.rb +0 -33
  80. data/lib/rturk/answer.rb +0 -20
  81. data/lib/rturk/custom_operations.rb +0 -80
  82. data/lib/rturk/external_question_builder.rb +0 -22
  83. data/spec/answer_spec.rb +0 -24
  84. data/spec/external_question_spec.rb +0 -27
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "doc"]
2
+ path = doc
3
+ url = git@github.com:markpercival/rturk.git
data/.yardoc ADDED
Binary file
data/README.markdown CHANGED
@@ -11,7 +11,7 @@ You'd be better off with amazon's official library, in all its XML cruftiness.
11
11
 
12
12
  ## Installation
13
13
 
14
- sudo gem install markpercival-rturk --source http://gems.github.com
14
+ sudo gem install rturk --source http://gemcutter.org
15
15
 
16
16
  ## Use
17
17
 
@@ -21,42 +21,62 @@ Let's say you have a form at "http://myapp.com/turkers/add_tags" where Turkers c
21
21
 
22
22
  require 'rturk'
23
23
 
24
- props = {:Title=>"Add tags to an item",
25
- :MaxAssignments=>1, :LifetimeInSeconds=>3600,
26
- :Reward=>{:Amount=>0.05, :CurrencyCode=>"USD"},
27
- :Keywords=>"twitter, blogging, writing, english",
28
- :Description=>"Simply add some tags for me",
29
- :RequesterAnnotation=>"Example1",
30
- :AssignmentDurationInSeconds=>3600, :AutoApprovalDelayInSeconds=>3600,
31
- :QualificationRequirement=>[{
32
- # Approval rate of greater than 90%
33
- :QualificationTypeId=>"000000000000000000L0",
34
- :IntegerValue=>90,
35
- :Comparator=>"GreaterThan",
36
- :RequiredToPreview=>"false"
37
- }]
38
- }
39
-
40
- @turk = RTurk::Requester.new(AWSAccessKeyId, AWSAccessKey, :sandbox => true)
41
- page = RTurk::ExternalQuestionBuilder.build(
42
- "http://myapp.com/turkers/add_tags", :item_id => '1234')
24
+ RTurk.setup(YourAWSAccessKeyId, YourAWSAccessKey, :sandbox => true)
25
+ hit = RTurk::Hit.create(:title => "Add some tags to a photo") do |hit|
26
+ hit.assignments = 2
27
+ hit.question("http://myapp.com/turkers/add_tags")
28
+ hit.reward = 0.05
29
+ hit.qualifications.approval_rate, {:gt => 80}
30
+ end
43
31
 
44
- # Turkers will be directed to http://myapp.com/turkers/add_tags?item_id=1234&AssignmentId=abcd12345
45
-
46
- p @turk.create_hit(props, page)
32
+ p hit.url #=> 'https://workersandbox.mturk.com:443/mturk/preview?groupId=Q29J3XZQ1ASZH5YNKZDZ'
47
33
 
48
- ### Reviewing HIT's
49
-
50
- require 'rturk'
51
- @turk = RTurk::Requester.new(AWSAccessKeyId, AWSAccessKey, :sandbox => true)
34
+ ### Reviewing and Approving hits HIT's
35
+
36
+ hits = RTurk::Hit.all_reviewable
37
+
38
+ puts "#{hits.size} reviewable hits. \n"
39
+
40
+ unless hits.empty?
41
+ puts "Reviewing all assignments"
42
+
43
+ hits.each do |hit|
44
+ hit.assignments.each do |assignment|
45
+ puts assignment.answers['tags']
46
+ assignment.approve! if assignment.status == 'Submitted'
47
+ end
48
+ end
49
+ end
50
+
51
+ ### Wiping all your hits out
52
+
53
+ hits = RTurk::Hit.all_reviewable
54
+
55
+ puts "#{hits.size} reviewable hits. \n"
56
+
57
+ unless hits.empty?
58
+ puts "Approving all assignments and disposing of each hit!"
59
+
60
+ hits.each do |hit|
61
+ hit.expire!
62
+ hit.assignments.each do |assignment|
63
+ assignment.approve!
64
+ end
65
+ hit.dispose!
66
+ end
67
+ end
68
+
69
+
70
+ ### Logging
71
+ Want to see what's going on - enable logging.
52
72
 
53
- p @turk.getAssignmentsForHIT(:HITId => 'abcde1234567890')
73
+ RTurk::Logger.level = Logger::DEBUG
54
74
 
55
75
  ## Nitty Gritty
56
76
 
57
77
  Here's a quick peak at what happens on the Mechanical Turk side.
58
78
 
59
- A worker takes a look at your hit. The page will contain an iframe with your external URL loaded inside of it.
79
+ A worker takes a look at your hit. The page will contain an iframe with your question URL loaded inside of it.
60
80
 
61
81
  Amazon will append the AssignmentID parameter to the URL for your own information. In preview mode this will look like
62
82
  http://myapp.com/turkers/add_tags?item_id=1234&AssignmentId=ASSIGNMENT_ID_NOT_AVAILABLE
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'yard'
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "rturk"
9
+ gem.summary = %Q{Mechanical Turk API Wrapper}
10
+ gem.email = "mark@mpercival.com"
11
+ gem.homepage = "http://github.com/markpercival/rturk"
12
+ gem.authors = ["Mark Percival"]
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
19
+
20
+ require 'spec/rake/spectask'
21
+ Spec::Rake::SpecTask.new(:spec) do |spec|
22
+ spec.libs << 'lib' << 'spec'
23
+ spec.spec_files = FileList['spec/**/*_spec.rb']
24
+ end
25
+
26
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
27
+ spec.libs << 'lib' << 'spec'
28
+ spec.pattern = 'spec/**/*_spec.rb'
29
+ spec.rcov = true
30
+ end
31
+
32
+
33
+ task :default => :spec
34
+
35
+ require 'rake/rdoctask'
36
+ Rake::RDocTask.new do |rdoc|
37
+ if File.exist?('VERSION.yml')
38
+ config = YAML.load(File.read('VERSION.yml'))
39
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
40
+ else
41
+ version = ""
42
+ end
43
+
44
+ rdoc.rdoc_dir = 'rdoc'
45
+ rdoc.title = "rturk-gem #{version}"
46
+ rdoc.rdoc_files.include('README*')
47
+ rdoc.rdoc_files.include('lib/**/*.rb')
48
+ end
49
+
50
+
51
+ YARD::Rake::YardocTask.new do |t|
52
+ t.files = ['lib/**/*.rb', 'lib/**/*.rb']
53
+ end
data/TODO.markdown ADDED
@@ -0,0 +1,3 @@
1
+ Fakeweb all requests, should be able to turn off
2
+ Better error handling and checking
3
+ Operations should include request?
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 2.0.0
@@ -1,6 +1,23 @@
1
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
2
+ require 'rubygems'
1
3
  require '../lib/rturk'
2
- root = File.expand_path(File.dirname(__FILE__))
3
- aws = YAML.load(File.open(File.join(root, 'mturk.yml')))
4
- @turk = RTurk::Requester.new(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
5
4
 
6
- @turk.blank_slate
5
+ aws = YAML.load(File.open(File.join(File.dirname(__FILE__), 'mturk.yml')))
6
+ RTurk::setup(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
7
+
8
+ hits = RTurk::Hit.all_reviewable
9
+
10
+ puts "#{hits.size} reviewable hits. \n"
11
+
12
+ unless hits.empty?
13
+ puts "Approving all assignments and disposing of each hit!"
14
+
15
+ hits.each do |hit|
16
+ hit.expire!
17
+ hit.assignments.each do |assignment|
18
+ assignment.approve!
19
+ end
20
+ hit.dispose!
21
+ end
22
+ end
23
+
@@ -0,0 +1,19 @@
1
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
2
+ require 'rubygems'
3
+ require '../lib/rturk'
4
+
5
+ aws = YAML.load(File.open(File.join(File.dirname(__FILE__), 'mturk.yml')))
6
+ RTurk::setup(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
7
+
8
+ root = File.expand_path(File.dirname(__FILE__))
9
+ aws = YAML.load(File.open(File.join(root, 'mturk.yml')))
10
+ RTurk::setup(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
11
+
12
+ hit = RTurk::Hit.create(:title => 'Write a tweet for me') do |hit|
13
+ hit.description = 'Simply write a witty twitter update for my account'
14
+ hit.reward = 0.05
15
+ hit.assignments = 1
16
+ hit.question("http://mpercival.com.s3.amazonaws.com/newtweet.html")
17
+ end
18
+
19
+ p hit.url
@@ -55,7 +55,6 @@
55
55
  <li>MUST BE LESS THAN 120 CHARACTERS</li>
56
56
  <li>Could be about an interesting topic or current event</li>
57
57
  <li>Could also make up something about what I'm currently doing</li>
58
- <li>Should not be vulgar or crass</li>
59
58
 
60
59
  <li>Should fool people into thinking I am clever and witty</li>
61
60
  </ul>
@@ -1,8 +1,21 @@
1
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
2
+ require 'rubygems'
1
3
  require '../lib/rturk'
2
- root = File.expand_path(File.dirname(__FILE__))
3
- aws = YAML.load(File.open(File.join(root, 'mturk.yml')))
4
- @turk = RTurk::Requester.new(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
5
4
 
6
- last_hit = File.open(File.join(root, 'last_hit'), 'r').read
5
+ aws = YAML.load(File.open(File.join(File.dirname(__FILE__), 'mturk.yml')))
6
+ RTurk::setup(aws['AWSAccessKeyId'], aws['AWSAccessKey'], :sandbox => true)
7
7
 
8
- p @turk.getAssignmentsForHIT(:HITId => last_hit)
8
+ hits = RTurk::Hit.all_reviewable
9
+
10
+ puts "#{hits.size} reviewable hits. \n"
11
+
12
+ unless hits.empty?
13
+ puts "Reviewing all assignments"
14
+
15
+ hits.each do |hit|
16
+ hit.assignments.each do |assignment|
17
+ puts assignment.answers['tweet']
18
+ assignment.approve! if assignment.status == 'Submitted'
19
+ end
20
+ end
21
+ end
data/lib/rturk.rb CHANGED
@@ -1,11 +1,38 @@
1
1
  module RTurk
2
- end
2
+ require 'rturk/logger'
3
+
4
+ SANDBOX = 'http://mechanicalturk.sandbox.amazonaws.com/'
5
+ PRODUCTION = 'http://mechanicalturk.amazonaws.com/'
6
+ class << self
7
+ attr_reader :access_key, :secret_key, :host
8
+
9
+ def setup(access_key, secret_key, opts ={})
10
+ @access_key = access_key
11
+ @secret_key = secret_key
12
+ @host = opts[:sandbox] ? SANDBOX : PRODUCTION
13
+ end
14
+
15
+ def sandbox?
16
+ @host == SANDBOX
17
+ end
18
+
19
+ def log
20
+ RTurk::Logger.logger
21
+ end
3
22
 
4
- $:.unshift(File.dirname(__FILE__)) unless
5
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
23
+ end
24
+
25
+ end
6
26
 
7
27
  require 'rturk/utilities'
8
- require 'rturk/custom_operations'
9
- require 'rturk/answer'
10
- require 'rturk/external_question_builder'
28
+ require 'rturk/xml_utilities'
11
29
  require 'rturk/requester'
30
+ require 'rturk/response'
31
+ Dir.glob(File.join(File.dirname(__FILE__), 'rturk', 'responses', '*.rb')).each {|f| require f }
32
+ require 'rturk/operation'
33
+ Dir.glob(File.join(File.dirname(__FILE__), 'rturk', 'operations', '*.rb')).each {|f| require f }
34
+ Dir.glob(File.join(File.dirname(__FILE__), 'rturk', 'builders', '*.rb')).each {|f| require f }
35
+ Dir.glob(File.join(File.dirname(__FILE__), 'rturk', 'adapters', '*.rb')).each {|f| require f }
36
+ Dir.glob(File.join(File.dirname(__FILE__), 'rturk', 'parsers', '*.rb')).each {|f| require f }
37
+
38
+ require 'rturk/errors'
@@ -0,0 +1,38 @@
1
+ require 'cgi'
2
+
3
+ module RTurk
4
+ class Answers
5
+
6
+ attr_accessor :answer_hash
7
+
8
+ def initialize(xml)
9
+ answer_xml = Nokogiri::XML(CGI.unescapeHTML(xml))
10
+ @answer_hash = {}
11
+ answers = answer_xml.xpath('//xmlns:Answer')
12
+ answers.each do |answer|
13
+ key, value = nil, nil
14
+ answer.children.each do |child|
15
+ next if child.blank?
16
+ if child.name == 'QuestionIdentifier'
17
+ key = child.inner_text
18
+ else
19
+ value = child.inner_text
20
+ end
21
+ end
22
+ @answer_hash[key] = value
23
+ end
24
+ end
25
+
26
+
27
+ # @param [<String, Symbol>] The string or symbol of the question name
28
+ # @return [String] The value of the question name
29
+ def [](key)
30
+ @answer_hash[key]
31
+ end
32
+
33
+ def to_hash
34
+ @answer_hash
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,75 @@
1
+ require 'time'
2
+
3
+ module RTurk
4
+
5
+ # Parses:
6
+ # <Assignment>
7
+ # <AssignmentId>GYFTRHZ5J3DZREY48WNZE38ZR9RR1ZPMXGWE7WE0</AssignmentId>
8
+ # <WorkerId>AD20WXZZP9XXK</WorkerId>
9
+ # <HITId>GYFTRHZ5J3DZREY48WNZ</HITId>
10
+ # <AssignmentStatus>Approved</AssignmentStatus>
11
+ # <AutoApprovalTime>2009-08-12T19:21:54Z</AutoApprovalTime>
12
+ # <AcceptTime>2009-07-13T19:21:40Z</AcceptTime>
13
+ # <SubmitTime>2009-07-13T19:21:54Z</SubmitTime>
14
+ # <ApprovalTime>2009-07-13T19:27:54Z</ApprovalTime>
15
+ # <Answer>
16
+ # <?xml version="1.0" encoding="UTF-8"?>
17
+ # <QuestionFormAnswers xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionFormAnswers.xsd">
18
+ # <Answer>
19
+ # <QuestionIdentifier>Question100</QuestionIdentifier>
20
+ # <FreeText>Move to X.</FreeText>
21
+ # </Answer>
22
+ # </QuestionFormAnswers>
23
+ # </Answer>
24
+ # </Assignment>
25
+
26
+ class Assignment
27
+ include RTurk::XmlUtilities
28
+
29
+ attr_accessor :worker_id, :id, :status, :submitted_at, :accepted_at, :approved_at
30
+ attr_reader :answers
31
+
32
+ def initialize(xml_object)
33
+ map_content(xml_object,
34
+ :id => 'AssignmentId',
35
+ :worker_id => 'WorkerId',
36
+ :status => 'AssignmentStatus',
37
+ :accepted_at => 'AcceptTime',
38
+ :approved_at => "ApprovalTime",
39
+ :submitted_at => 'SubmitTime')
40
+ self.answers = xml_object.xpath('Answer').children.to_s
41
+ end
42
+
43
+ def approved_at=(time)
44
+ @approved_at = Time.parse(time)
45
+ end
46
+
47
+ def submitted_at=(time)
48
+ @submitted_at = Time.parse(time)
49
+ end
50
+
51
+ def accepted_at=(time)
52
+ @accepted_at = Time.parse(time)
53
+ end
54
+
55
+ def approve!(feedback = nil)
56
+ RTurk::ApproveAssignment(:assignment_id => self.id, :feedback => feedback)
57
+ end
58
+
59
+ def reject!(reason)
60
+ RTurk::ApproveAssignment(:assignment_id => self.id, :feedback => reason)
61
+ end
62
+
63
+ def bonus!(amount, reason)
64
+ RTurk::GrantBonus(:amount, :feedback => reason)
65
+ end
66
+
67
+ def answers=(answer_xml)
68
+ unless answer_xml.empty?
69
+ @answers = RTurk::Answers.new(answer_xml)
70
+ end
71
+ end
72
+
73
+ end
74
+
75
+ end
@@ -0,0 +1,97 @@
1
+ module RTurk
2
+
3
+ # =The RTurk Hit Adapter
4
+ #
5
+ # Lets us interact with Mechanical Turk without having to know all the operations.
6
+ #
7
+ # == Basic usage
8
+ # @example
9
+ # require 'rturk'
10
+ #
11
+ # RTurk.setup(YourAWSAccessKeyId, YourAWSAccessKey, :sandbox => true)
12
+ # hit = RTurk::Hit.create(:title => "Add some tags to a photo") do |hit|
13
+ # hit.assignments = 2
14
+ # hit.question("http://myapp.com/turkers/add_tags")
15
+ # hit.reward = 0.05
16
+ # hit.qualifications.approval_rate, {:gt => 80}
17
+ # end
18
+ #
19
+ # hit.url #=> 'http://mturk.amazonaws.com/?group_id=12345678'
20
+
21
+
22
+ class Hit
23
+ include RTurk::XmlUtilities
24
+
25
+ class << self;
26
+
27
+ def create(*args, &blk)
28
+ response = RTurk::CreateHIT(*args, &blk)
29
+ response.hit
30
+ end
31
+
32
+ def find(id)
33
+
34
+ end
35
+
36
+ def all_reviewable
37
+ RTurk.GetReviewableHITs.hits
38
+ end
39
+
40
+ end
41
+
42
+ attr_accessor :id
43
+
44
+ def initialize(id, type = nil)
45
+ @id, @type = id, type
46
+ end
47
+
48
+ def assignments
49
+ RTurk::GetAssignmentsForHIT(:hit_id => self.id).assignments
50
+ end
51
+
52
+ def type_id
53
+ @type_id ||= details.type_id
54
+ end
55
+
56
+ def status
57
+ @status ||= details.status
58
+ end
59
+
60
+ def expires_at
61
+ @expires_at ||= details.expires_at
62
+ end
63
+
64
+ def title
65
+ @title ||= details.title
66
+ end
67
+
68
+ def details
69
+ @details ||= RTurk::GetHIT(:hit_id => self.id)
70
+ end
71
+
72
+ def expire!
73
+ RTurk::ForceExpireHIT(:hit_id => self.id)
74
+ end
75
+
76
+ def dispose!
77
+ RTurk::DisposeHIT(:hit_id => self.id)
78
+ end
79
+
80
+ def disable!
81
+ RTurk::DisableHIT(:hit_id => self.id)
82
+ end
83
+
84
+
85
+ def url
86
+ if RTurk.sandbox?
87
+ "http://workersandbox.mturk.com/mturk/preview?groupId=#{self.type_id}" # Sandbox Url
88
+ else
89
+ "http://mturk.com/mturk/preview?groupId=#{self.type_id}" # Production Url
90
+ end
91
+ end
92
+
93
+
94
+
95
+ end
96
+
97
+ end