mturk 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -0
- data/.gemtest +0 -0
- data/History.md +105 -0
- data/LICENSE.txt +202 -0
- data/Manifest.txt +72 -0
- data/NOTICE.txt +4 -0
- data/README.md +100 -0
- data/Rakefile +33 -0
- data/bin/mturk +9 -0
- data/lib/amazon/util.rb +10 -0
- data/lib/amazon/util/binder.rb +48 -0
- data/lib/amazon/util/data_reader.rb +169 -0
- data/lib/amazon/util/filter_chain.rb +79 -0
- data/lib/amazon/util/hash_nesting.rb +93 -0
- data/lib/amazon/util/lazy_results.rb +59 -0
- data/lib/amazon/util/logging.rb +23 -0
- data/lib/amazon/util/paginated_iterator.rb +70 -0
- data/lib/amazon/util/proactive_results.rb +116 -0
- data/lib/amazon/util/threadpool.rb +129 -0
- data/lib/amazon/util/user_data_store.rb +100 -0
- data/lib/amazon/webservices/mechanical_turk.rb +123 -0
- data/lib/amazon/webservices/mechanical_turk_requester.rb +285 -0
- data/lib/amazon/webservices/mturk/mechanical_turk_error_handler.rb +153 -0
- data/lib/amazon/webservices/mturk/question_generator.rb +58 -0
- data/lib/amazon/webservices/util/amazon_authentication_relay.rb +72 -0
- data/lib/amazon/webservices/util/command_line.rb +155 -0
- data/lib/amazon/webservices/util/convenience_wrapper.rb +90 -0
- data/lib/amazon/webservices/util/filter_proxy.rb +45 -0
- data/lib/amazon/webservices/util/mock_transport.rb +70 -0
- data/lib/amazon/webservices/util/request_signer.rb +42 -0
- data/lib/amazon/webservices/util/rest_transport.rb +120 -0
- data/lib/amazon/webservices/util/soap_simplifier.rb +48 -0
- data/lib/amazon/webservices/util/soap_transport.rb +20 -0
- data/lib/amazon/webservices/util/soap_transport_header_handler.rb +27 -0
- data/lib/amazon/webservices/util/unknown_result_exception.rb +27 -0
- data/lib/amazon/webservices/util/validation_exception.rb +55 -0
- data/lib/amazon/webservices/util/xml_simplifier.rb +61 -0
- data/lib/mturk.rb +19 -0
- data/lib/mturk/version.rb +6 -0
- data/run_rcov.sh +1 -0
- data/samples/best_image/BestImage.rb +61 -0
- data/samples/best_image/best_image.properties +39 -0
- data/samples/best_image/best_image.question +82 -0
- data/samples/blank_slate/BlankSlate.rb +63 -0
- data/samples/blank_slate/BlankSlate_multithreaded.rb +67 -0
- data/samples/helloworld/MTurkHelloWorld.rb +56 -0
- data/samples/helloworld/mturk.yml +8 -0
- data/samples/review_policy/ReviewPolicy.rb +139 -0
- data/samples/review_policy/review_policy.question +30 -0
- data/samples/reviewer/Reviewer.rb +103 -0
- data/samples/reviewer/mturk.yml +8 -0
- data/samples/simple_survey/SimpleSurvey.rb +98 -0
- data/samples/simple_survey/simple_survey.question +30 -0
- data/samples/site_category/SiteCategory.rb +87 -0
- data/samples/site_category/externalpage.htm +71 -0
- data/samples/site_category/site_category.input +6 -0
- data/samples/site_category/site_category.properties +56 -0
- data/samples/site_category/site_category.question +9 -0
- data/test/mturk/test_changehittypeofhit.rb +130 -0
- data/test/mturk/test_error_handler.rb +403 -0
- data/test/mturk/test_mechanical_turk_requester.rb +178 -0
- data/test/mturk/test_mock_mechanical_turk_requester.rb +205 -0
- data/test/test_mturk.rb +21 -0
- data/test/unit/test_binder.rb +89 -0
- data/test/unit/test_data_reader.rb +135 -0
- data/test/unit/test_exceptions.rb +32 -0
- data/test/unit/test_hash_nesting.rb +99 -0
- data/test/unit/test_lazy_results.rb +89 -0
- data/test/unit/test_mock_transport.rb +132 -0
- data/test/unit/test_paginated_iterator.rb +58 -0
- data/test/unit/test_proactive_results.rb +108 -0
- data/test/unit/test_question_generator.rb +55 -0
- data/test/unit/test_threadpool.rb +50 -0
- data/test/unit/test_user_data_store.rb +80 -0
- metadata +225 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<QuestionForm xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd">
|
3
|
+
<Question>
|
4
|
+
<QuestionIdentifier>q1</QuestionIdentifier>
|
5
|
+
<QuestionContent>
|
6
|
+
<Text>What is 1 + 1?</Text>
|
7
|
+
</QuestionContent>
|
8
|
+
<AnswerSpecification>
|
9
|
+
<FreeTextAnswer/>
|
10
|
+
</AnswerSpecification>
|
11
|
+
</Question>
|
12
|
+
<Question>
|
13
|
+
<QuestionIdentifier>q2</QuestionIdentifier>
|
14
|
+
<QuestionContent>
|
15
|
+
<Text>What is 2 + 2?</Text>
|
16
|
+
</QuestionContent>
|
17
|
+
<AnswerSpecification>
|
18
|
+
<FreeTextAnswer/>
|
19
|
+
</AnswerSpecification>
|
20
|
+
</Question>
|
21
|
+
<Question>
|
22
|
+
<QuestionIdentifier>q3</QuestionIdentifier>
|
23
|
+
<QuestionContent>
|
24
|
+
<Text>What color is the sky?</Text>
|
25
|
+
</QuestionContent>
|
26
|
+
<AnswerSpecification>
|
27
|
+
<FreeTextAnswer/>
|
28
|
+
</AnswerSpecification>
|
29
|
+
</Question>
|
30
|
+
</QuestionForm>
|
@@ -0,0 +1,103 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
|
6
|
+
begin ; require 'rubygems' ; rescue LoadError ; end
|
7
|
+
|
8
|
+
# The Reviewer sample application will retrieve the completed assignments for a given HIT,
|
9
|
+
# output the results and approve the assignment.
|
10
|
+
#
|
11
|
+
# mturk.yml is used to configure default settings ( must be in the same directory as Reviewer.rb )
|
12
|
+
# You will need to have the HIT ID of an existing HIT that has been accepted, completed and
|
13
|
+
# submitted by a worker.
|
14
|
+
# Or you can use the .success file generated from bulk loading several HITs (i.e. Site Category sample application).
|
15
|
+
#
|
16
|
+
# The following concepts are covered:
|
17
|
+
# - Retrieve results for a HIT
|
18
|
+
# - Output results for several HITs to a file
|
19
|
+
# - Approve assignments
|
20
|
+
|
21
|
+
require 'mturk'
|
22
|
+
@mturk = Amazon::WebServices::MechanicalTurkRequester.new :Config => File.join( File.dirname(__FILE__), 'mturk.yml' )
|
23
|
+
|
24
|
+
# Prints the submitted results of HITs when provided with a .success file.
|
25
|
+
# successFile:: The .success file containing the HIT ID and HIT Type ID
|
26
|
+
# outputFile:: The output file to write the submitted results to
|
27
|
+
def printResults( successFile, outputFile)
|
28
|
+
|
29
|
+
# Loads the .success file containing the HIT IDs and HIT Type IDs of HITs to be retrieved.
|
30
|
+
success = Amazon::Util::DataReader.load( successFile, :Tabular )
|
31
|
+
|
32
|
+
# Retrieves the submitted results of the specified HITs from Mechanical Turk
|
33
|
+
results = @mturk.getHITResults(success)
|
34
|
+
|
35
|
+
# parse answers to they're easier to digest
|
36
|
+
results.each { |assignment| assignment[:Answers] = @mturk.simplifyAnswer( assignment[:Answer] ) }
|
37
|
+
|
38
|
+
# Writes the submitted results to the defined output file.
|
39
|
+
# The output file is a tab delimited file containing all relevant details
|
40
|
+
# of the HIT and assignments. The submitted results are included as the last set of fields
|
41
|
+
# and are represented as tab separated question/answer pairs
|
42
|
+
Amazon::Util::DataReader.save( outputFile, results, :Tabular )
|
43
|
+
puts "Results have been written to: #{outputFile}"
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
# Prints the submitted results of a HIT when provided with a HIT ID.
|
48
|
+
# hitId:: The HIT ID of the HIT to be retrieved.
|
49
|
+
def reviewAnswers( hitId )
|
50
|
+
assignments = @mturk.getAssignmentsForHITAll( :HITId => hitId, :AssignmentStatus => 'Submitted')
|
51
|
+
|
52
|
+
puts "--[Reviewing HITs]----------"
|
53
|
+
puts " HIT Id: #{hitId}"
|
54
|
+
|
55
|
+
assignments.each do |assignment|
|
56
|
+
|
57
|
+
# By default, answers are specified in XML
|
58
|
+
answerXML = assignment[:Answer]
|
59
|
+
|
60
|
+
# Calling a convenience method that will parse the answer XML and extract out the question/answer pairs.
|
61
|
+
answers = @mturk.simplifyAnswer( answerXML )
|
62
|
+
|
63
|
+
answers.each do |id,answer|
|
64
|
+
assignmentId = assignment[:AssignmentId]
|
65
|
+
puts "Got an answer \"#{answer}\" for \"#{id}\" from worker #{assignment[:WorkerId]}"
|
66
|
+
end
|
67
|
+
|
68
|
+
# Approving the assignment
|
69
|
+
@mturk.approveAssignment(:AssignmentId => assignment[:AssignmentId], :RequesterFeedback => "Well Done!")
|
70
|
+
puts "Approved."
|
71
|
+
|
72
|
+
end
|
73
|
+
puts "--[End Reviewing HITs]----------"
|
74
|
+
end
|
75
|
+
|
76
|
+
require 'optparse'
|
77
|
+
hitsToReview = []
|
78
|
+
opts = OptionParser.new
|
79
|
+
opts.on( '--review HITId', 'Review Answers for a single HIT ( can be specified multiple times)') {|hit| hitsToReview << hit ; @review = true }
|
80
|
+
opts.on( '--results', 'Print Results using input and output files') { @getResults = true }
|
81
|
+
opts.on( '--input FILE', 'Input File to get results') {|file| @inputFile = file }
|
82
|
+
opts.on( '--output FILE', 'Output File to save results') {|file| @outputFile = file }
|
83
|
+
|
84
|
+
begin
|
85
|
+
opts.parse ARGV
|
86
|
+
raise "Please, either --review or --results, not both" if @review && @getResults
|
87
|
+
raise "Pick something to do ( either --review or --results )" unless @review || @getResults
|
88
|
+
if @getResults
|
89
|
+
raise "missing input file" unless @inputFile
|
90
|
+
raise "missing output file" unless @outputFile
|
91
|
+
raise "input file does not exist: #{@inputFile}" unless File.exist? @inputFile
|
92
|
+
end
|
93
|
+
rescue => e
|
94
|
+
puts e.message
|
95
|
+
puts opts.to_s
|
96
|
+
exit
|
97
|
+
end
|
98
|
+
|
99
|
+
if @getResults
|
100
|
+
printResults( @inputFile, @outputFile )
|
101
|
+
elsif @review
|
102
|
+
hitsToReview.each {|h| reviewAnswers(h) }
|
103
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright:: Copyright (c) 2007-2014 Amazon Technologies, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
|
6
|
+
begin ; require 'rubygems' ; rescue LoadError ; end
|
7
|
+
|
8
|
+
# The Simple Survey sample application will create a HIT asking a worker to indicate their
|
9
|
+
# political party preferences.
|
10
|
+
#
|
11
|
+
# mturk.properties must be found in the current file path.
|
12
|
+
#
|
13
|
+
# The following concepts are covered:
|
14
|
+
# - File based QuestionForm HIT loading
|
15
|
+
# - Using a locale qualification
|
16
|
+
|
17
|
+
require 'mturk'
|
18
|
+
@mturk = Amazon::WebServices::MechanicalTurkRequester.new
|
19
|
+
|
20
|
+
|
21
|
+
# Check to see if your account has sufficient funds
|
22
|
+
def hasEnoughFunds?
|
23
|
+
available = @mturk.availableFunds
|
24
|
+
puts "Got account balance: %.2f" % available
|
25
|
+
return available > 0.055
|
26
|
+
end
|
27
|
+
|
28
|
+
def getHITUrl( hitTypeId )
|
29
|
+
if @mturk.host =~ /sandbox/
|
30
|
+
"http://workersandbox.mturk.com/mturk/preview?groupId=#{hitTypeId}" # Sandbox Url
|
31
|
+
else
|
32
|
+
"http://mturk.com/mturk/preview?groupId=#{hitTypeId}" # Production Url
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Creates the simple survey.
|
37
|
+
def createSimpleSurvey
|
38
|
+
title = "What is your political preference?"
|
39
|
+
description = "This is a simple survey HIT created by the Amazon Mechanical Turk SDK for Ruby."
|
40
|
+
numAssignments = 1
|
41
|
+
reward = { :Amount => 0.05, :CurrencyCode => 'USD' }
|
42
|
+
keywords = "sample, SDK, survey"
|
43
|
+
assignmentDurationInSeconds = 60 * 60 # 1 hour
|
44
|
+
autoApprovalDelayInSeconds = 60 * 60 # 1 hour
|
45
|
+
lifetimeInSeconds = 60 * 60 # 1 hour
|
46
|
+
requesterAnnotation = "sample#survey"
|
47
|
+
|
48
|
+
# Defining the location of the externalized question (QuestionForm) file.
|
49
|
+
rootDir = File.dirname $0
|
50
|
+
questionFile = rootDir + "/simple_survey.question"
|
51
|
+
|
52
|
+
|
53
|
+
# This is an example of using qualification requirements.
|
54
|
+
# This is a built-in qualification -- user must be based in the Washington (US state), Maryland (US state), Canada, or Great Britain
|
55
|
+
locationQualReq = { :QualificationTypeId => Amazon::WebServices::MechanicalTurkRequester::LOCALE_QUALIFICATION_TYPE_ID,
|
56
|
+
:Comparator => 'In',
|
57
|
+
:LocaleValue => [{:Country => 'US', :Subdivision => 'WA'},
|
58
|
+
{:Country => 'US', :Subdivision => 'MD'},
|
59
|
+
{:Country => 'CA'},
|
60
|
+
{:Country => 'GB'}] }
|
61
|
+
|
62
|
+
# This is a built-in qualification -- user must have had greater than 1000 HTIs approved
|
63
|
+
numHITsApprovedQualReq = { :QualificationTypeId => Amazon::WebServices::MechanicalTurkRequester::NUMBER_OF_HITS_APPROVED_QUALIFICATION_TYPE_ID,
|
64
|
+
:Comparator => 'GreaterThan',
|
65
|
+
:IntegerValue => 1000 }
|
66
|
+
|
67
|
+
# The create HIT method takes in an array of QualificationRequirements since a HIT can have multiple qualifications.
|
68
|
+
qualReqs = [locationQualReq, numHITsApprovedQualReq]
|
69
|
+
|
70
|
+
# Loading the question (QuestionForm) file
|
71
|
+
question = File.read( questionFile )
|
72
|
+
|
73
|
+
# Creating the HIT and loading it into Mechanical Turk
|
74
|
+
hit = @mturk.createHIT( :Title => title,
|
75
|
+
:Description => description,
|
76
|
+
:Keywords => keywords,
|
77
|
+
:Question => question,
|
78
|
+
:Reward => reward,
|
79
|
+
:AssignmentDurationInSeconds => assignmentDurationInSeconds,
|
80
|
+
:AutoApprovalDelayInSeconds => autoApprovalDelayInSeconds,
|
81
|
+
:LifetimeInSeconds => lifetimeInSeconds,
|
82
|
+
:MaxAssignments => numAssignments,
|
83
|
+
:RequesterAnnotation => requesterAnnotation,
|
84
|
+
:QualificationRequirement => qualReqs )
|
85
|
+
|
86
|
+
puts "Created HIT: #{hit[:HITId]}"
|
87
|
+
puts "Url: #{getHITUrl( hit[:HITTypeId] )}"
|
88
|
+
|
89
|
+
# Demonstrates how a HIT can be retrieved if you know its HIT ID
|
90
|
+
hit2 = @mturk.getHIT(:HITId => hit[:HITId])
|
91
|
+
|
92
|
+
puts "Retrieved HIT: #{hit2[:HITId]}"
|
93
|
+
|
94
|
+
puts "Oops! The HIT Ids shoud match: #{hit[:HITId]}, #{hit2[:HITId]}" unless hit[:HITId] == hit2[:HITId]
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
createSimpleSurvey if hasEnoughFunds?
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<QuestionForm xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd">
|
3
|
+
<Question>
|
4
|
+
<QuestionIdentifier>1</QuestionIdentifier>
|
5
|
+
<QuestionContent>
|
6
|
+
<Text>What is your political party affiliation?</Text>
|
7
|
+
</QuestionContent>
|
8
|
+
<AnswerSpecification>
|
9
|
+
<SelectionAnswer>
|
10
|
+
<MinSelectionCount>1</MinSelectionCount>
|
11
|
+
<MaxSelectionCount>1</MaxSelectionCount>
|
12
|
+
<StyleSuggestion>radiobutton</StyleSuggestion>
|
13
|
+
<Selections>
|
14
|
+
<Selection>
|
15
|
+
<SelectionIdentifier>republican</SelectionIdentifier>
|
16
|
+
<Text>Republican</Text>
|
17
|
+
</Selection>
|
18
|
+
<Selection>
|
19
|
+
<SelectionIdentifier>democrat</SelectionIdentifier>
|
20
|
+
<Text>Democrat</Text>
|
21
|
+
</Selection>
|
22
|
+
<Selection>
|
23
|
+
<SelectionIdentifier>noneoftheabove</SelectionIdentifier>
|
24
|
+
<Text>None of the Above</Text>
|
25
|
+
</Selection>
|
26
|
+
</Selections>
|
27
|
+
</SelectionAnswer>
|
28
|
+
</AnswerSpecification>
|
29
|
+
</Question>
|
30
|
+
</QuestionForm>
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
|
6
|
+
begin ; require 'rubygems' ; rescue LoadError ; end
|
7
|
+
|
8
|
+
# The Site Category sample application will create 5 HITs asking workers to categorize websites into predefined categories.
|
9
|
+
#
|
10
|
+
# The following concepts are covered:
|
11
|
+
# - Bulk load HITs using an input file
|
12
|
+
# - File based HIT loading
|
13
|
+
|
14
|
+
require 'mturk'
|
15
|
+
@mturk = Amazon::WebServices::MechanicalTurkRequester.new
|
16
|
+
|
17
|
+
# Check to see if your account has sufficient funds
|
18
|
+
def hasEnoughFunds?
|
19
|
+
available = @mturk.availableFunds
|
20
|
+
puts "Got account balance: %.2f" % available
|
21
|
+
return available > (0.055 * 5)
|
22
|
+
end
|
23
|
+
|
24
|
+
def getHITUrl( hitTypeId )
|
25
|
+
if @mturk.host =~ /sandbox/
|
26
|
+
"http://workersandbox.mturk.com/mturk/preview?groupId=#{hitTypeId}" # Sandbox Url
|
27
|
+
else
|
28
|
+
"http://mturk.com/mturk/preview?groupId=#{hitTypeId}" # Production Url
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Create the website category HITs.
|
33
|
+
def createSiteCategoryHITs
|
34
|
+
|
35
|
+
# Defining the locations of the input files
|
36
|
+
rootDir = File.dirname $0
|
37
|
+
inputFile = rootDir + "/site_category.input"
|
38
|
+
propertiesFile = rootDir + "/site_category.properties"
|
39
|
+
questionFile = rootDir + "/site_category.question"
|
40
|
+
|
41
|
+
# Loading the input file. The input file is a tab delimited file where the first row
|
42
|
+
# defines the fields/variables and the remaining rows contain the values for each HIT.
|
43
|
+
# Each row represents a unique HIT. ERB is used to merge the values into the Question template.
|
44
|
+
input = Amazon::Util::DataReader.load( inputFile, :Tabular )
|
45
|
+
|
46
|
+
# Loading the question (QuestionForm) file
|
47
|
+
question = File.read( questionFile )
|
48
|
+
|
49
|
+
# Loading the HIT properties file. The properties file defines two system qualifications that will
|
50
|
+
# be used for the HIT. The properties file can also be an ERB template. This allows the developer
|
51
|
+
# to "tie in" the input value to the results.
|
52
|
+
props = Amazon::Util::DataReader.load( propertiesFile, :Properties )
|
53
|
+
|
54
|
+
hits = [];
|
55
|
+
|
56
|
+
# Create multiple HITs using the input, properties, and question files
|
57
|
+
|
58
|
+
puts "--[Loading HITs]----------"
|
59
|
+
startTime = Time.now
|
60
|
+
puts " Start time: #{startTime}"
|
61
|
+
|
62
|
+
# The simpliest way to bulk load a large number of HITs where all details are defined in files.
|
63
|
+
# This method returns a hash with two arrays:
|
64
|
+
# - :Created is an array of successfully created HITs
|
65
|
+
# - :Failed is an array of lines we failed to create HITs with
|
66
|
+
hits = @mturk.createHITs(props, question, input);
|
67
|
+
|
68
|
+
puts "--[End Loading HITs]----------"
|
69
|
+
endTime = Time.now
|
70
|
+
puts " End time: #{endTime}"
|
71
|
+
puts "--[Done Loading HITs]----------"
|
72
|
+
puts " Total load time: #{ endTime - startTime } seconds."
|
73
|
+
|
74
|
+
hit_ids = hits[:Created].collect {|h| h[:HITId] }
|
75
|
+
hit_type_id = hits[:Created].first[:HITTypeId]
|
76
|
+
|
77
|
+
puts " Created HITs: #{hit_ids.join(' ')}"
|
78
|
+
puts " Url: #{getHITUrl( hit_type_id )}"
|
79
|
+
|
80
|
+
# We'll save the results to hits.success and hits.failure
|
81
|
+
Amazon::Util::DataReader.save( rootDir + "/hits.success", hits[:Created], :Tabular )
|
82
|
+
Amazon::Util::DataReader.save( rootDir + "/hits.failure", hits[:Failed], :Tabular )
|
83
|
+
# The .success file can be used in subsequent operations to retrieve the results that workers submitted.
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
createSiteCategoryHITs if hasEnoughFunds?
|
@@ -0,0 +1,71 @@
|
|
1
|
+
<!-- This file needs to be hosted on an external server. -->
|
2
|
+
<html>
|
3
|
+
<script language="Javascript">
|
4
|
+
//
|
5
|
+
// This method Gets URL Parameters (GUP)
|
6
|
+
//
|
7
|
+
function gup( name )
|
8
|
+
{
|
9
|
+
var regexS = "[\\?&]"+name+"=([^&#]*)";
|
10
|
+
var regex = new RegExp( regexS );
|
11
|
+
var tmpURL = window.location.href;
|
12
|
+
var results = regex.exec( tmpURL );
|
13
|
+
if( results == null )
|
14
|
+
return "";
|
15
|
+
else
|
16
|
+
return results[1];
|
17
|
+
}
|
18
|
+
|
19
|
+
//
|
20
|
+
// This method decodes the query parameters that were URL-encoded
|
21
|
+
//
|
22
|
+
function decode(strToDecode)
|
23
|
+
{
|
24
|
+
var encoded = strToDecode;
|
25
|
+
return unescape(encoded.replace(/\+/g, " "));
|
26
|
+
}
|
27
|
+
|
28
|
+
</script>
|
29
|
+
<body>
|
30
|
+
<form id="mturk_form" method="POST" action="http://www.mturk.com/mturk/externalSubmit">
|
31
|
+
<input type="hidden" id="assignmentId" name="assignmentId" value="">
|
32
|
+
<table border="0" height="100%" width="100%">
|
33
|
+
<tr><td>
|
34
|
+
<h1>What type of webpage is shown below?</h1>
|
35
|
+
<p>
|
36
|
+
<input type="radio" name="category" value="news"> News Site<br>
|
37
|
+
<input type="radio" name="category" value="search"> Search Engine<br>
|
38
|
+
<input type="radio" name="category" value="retail"> Online Retailer<br>
|
39
|
+
<input type="radio" name="category" value="other" selected> Other<br>
|
40
|
+
<p>
|
41
|
+
<input id="submitButton" type="submit" name="Submit" value="Submit">
|
42
|
+
<p>
|
43
|
+
</td></tr>
|
44
|
+
<tr><td height="100%">
|
45
|
+
<iframe id="pageFrame" width="100%" height="100%"></iframe>
|
46
|
+
</td></tr>
|
47
|
+
</table>
|
48
|
+
</form>
|
49
|
+
<script language="Javascript">
|
50
|
+
document.getElementById('pageFrame').src = decode(gup('url'));
|
51
|
+
document.getElementById('assignmentId').value = gup('assignmentId');
|
52
|
+
|
53
|
+
|
54
|
+
//
|
55
|
+
// Check if the worker is PREVIEWING the HIT or if they've ACCEPTED the HIT
|
56
|
+
//
|
57
|
+
if (gup('assignmentId') == "ASSIGNMENT_ID_NOT_AVAILABLE")
|
58
|
+
{
|
59
|
+
// If we're previewing, disable the button and give it a helpful message
|
60
|
+
document.getElementById('submitButton').disabled = true;
|
61
|
+
document.getElementById('submitButton').value = "You must ACCEPT the HIT before you can submit the results.";
|
62
|
+
} else {
|
63
|
+
var form = document.getElementById('mturk_form');
|
64
|
+
if (document.referrer && ( document.referrer.indexOf('workersandbox') != -1) ) {
|
65
|
+
form.action = "http://workersandbox.mturk.com/mturk/externalSubmit";
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
</script>
|
70
|
+
</body>
|
71
|
+
</html>
|
@@ -0,0 +1,56 @@
|
|
1
|
+
######################################
|
2
|
+
## External HIT Properties
|
3
|
+
######################################
|
4
|
+
|
5
|
+
Title:What website is this?
|
6
|
+
Description:Please look at this website and tell us, in simple words, what website this is.
|
7
|
+
Keywords:category, website, SDK, sample
|
8
|
+
Reward.Amount:0.05
|
9
|
+
Reward.CurrencyCode:USD
|
10
|
+
MaxAssignments:1
|
11
|
+
|
12
|
+
#Notice the use of ERB template directives here.
|
13
|
+
#This allows the input file to define the value of the HIT level annotation field.
|
14
|
+
RequesterAnnotation:<%= @urls %>
|
15
|
+
|
16
|
+
######################################
|
17
|
+
## HIT Timing Properties
|
18
|
+
######################################
|
19
|
+
|
20
|
+
# this Assignment Duration value is 60 * 60 = 1 hour
|
21
|
+
AssignmentDuration:3600
|
22
|
+
|
23
|
+
# this HIT Lifetime value is 60 * 60 = 1 hour
|
24
|
+
LifetimeInSeconds:3600
|
25
|
+
|
26
|
+
# this Auto Approval period is 60 * 60 = 1 hour
|
27
|
+
AutoApprovalDelayInSeconds:3600
|
28
|
+
|
29
|
+
######################################
|
30
|
+
## Qualification Properties
|
31
|
+
######################################
|
32
|
+
|
33
|
+
# In this example, two system qualifications and one location qualification are specified for the HIT.
|
34
|
+
|
35
|
+
# this is a built-in qualification -- user must have an approval rate of 25% or greater
|
36
|
+
QualificationRequirement.1.QualificationTypeId:000000000000000000L0
|
37
|
+
QualificationRequirement.1.Comparator:GreaterThan
|
38
|
+
QualificationRequirement.1.IntegerValue:25
|
39
|
+
QualificationRequirement.1.RequiredToPreview:false
|
40
|
+
|
41
|
+
# this is a built-in qualification -- user must have an abandonment rate of 50% or less
|
42
|
+
QualificationRequirement.2.QualificationTypeId:00000000000000000070
|
43
|
+
QualificationRequirement.2.Comparator:LessThan
|
44
|
+
QualificationRequirement.2.IntegerValue:51
|
45
|
+
QualificationRequirement.2.RequiredToPreview:true
|
46
|
+
|
47
|
+
# this is a built-in qualification -- user must be based in Washington (US state), Maryland (US state), Canada, or Great Britain
|
48
|
+
QualificationRequirement.3.QualificationTypeId:00000000000000000071
|
49
|
+
QualificationRequirement.3.Comparator:In
|
50
|
+
QualificationRequirement.3.LocaleValue.1.Country:US
|
51
|
+
QualificationRequirement.3.LocaleValue.1.Subdivision:WA
|
52
|
+
QualificationRequirement.3.LocaleValue.2.Country:US
|
53
|
+
QualificationRequirement.3.LocaleValue.2.Subdivision:MD
|
54
|
+
QualificationRequirement.3.LocaleValue.3.Country:CA
|
55
|
+
QualificationRequirement.3.LocaleValue.4.Country:GB
|
56
|
+
QualificationRequirement.3.RequiredToPreview:true
|