Sha256: 45228a29db19ceac06e17a361925b4434550cd40a25c029b3f28ea12cb682b1c

Contents?: true

Size: 962 Bytes

Versions: 35

Compression:

Stored size: 962 Bytes

Contents

module RTurk::Macros

  # Attempt to expire hit, then approve assignments, and finally dispose of
  def kill_hit(hit_id)
    forceExpireHIT(:HITId => hit_id)
    get_assignments_for_hit(hit_id).each do |assignment|
      approveAssignment(:AssignmentId => assignment[:AssignmentId])
    end
    disposeHIT(:HITId => hit_id)
  end

  # Wipe out all HIT's associated with this account
  def blank_slate
    search_response = searchHITs(:PageSize => 100)
    if search_results = search_response['SearchHITsResult']['HIT']
      search_results.each do |hit|
        kill_hit(hit['HITId'])
      end
    end
  end

  def url_for_hit(hit_id)
    url_for_hit_type(getHIT(:HITId => hit_id)[:HITTypeId])
  end

  def url_for_hit_type(hit_type_id)
    if @host =~ /sandbox/
      "http://workersandbox.mturk.com/mturk/preview?groupId=#{hit_type_id}" # Sandbox Url
    else
      "http://mturk.com/mturk/preview?groupId=#{hit_type_id}" # Production Url
    end
  end


end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
rturk-2.12.1 lib/rturk/macros.rb
rturk-2.12.0 lib/rturk/macros.rb
rturk-2.11.3 lib/rturk/macros.rb
rturk-2.11.2 lib/rturk/macros.rb
rturk-2.11.1 lib/rturk/macros.rb
rturk-2.11.0 lib/rturk/macros.rb
rturk-2.10.3 lib/rturk/macros.rb
rturk-2.10.2 lib/rturk/macros.rb
rturk-2.10.1 lib/rturk/macros.rb
rturk-2.10.0 lib/rturk/macros.rb
rturk-2.9.0 lib/rturk/macros.rb
rturk-2.8.0 lib/rturk/macros.rb
rturk-2.7.0 lib/rturk/macros.rb
rturk-2.6.0 lib/rturk/macros.rb
rturk-2.5.2 lib/rturk/macros.rb
rturk-2.5.0 lib/rturk/macros.rb
rturk-2.4.1 lib/rturk/macros.rb
rturk-2.4.0 lib/rturk/macros.rb
rturk-2.3.6 lib/rturk/macros.rb
rturk-2.3.5 lib/rturk/macros.rb