Class Index | File Index

Classes


Class MTurk

MTurk contains wrappers around the Java API for accessing Mechanical Turk.

mturk is a global instance of the MTurk class.


Defined in: MTurk.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
MTurk()
You probably want to use the global variable mturk.
Method Summary
Method Attributes Method Name and Description
 
approveAssignment(assignment, reason)
 
approveAssignmentRaw(assignment, reason)
Approves the given assignment, and provides an optional reason.
 
approveAssignments(assignments, reason)
Calls MTurk#approveAssignment for each assignment in the given assignments array.
 
assertWeCanSpend(money, hits, callbackBeforeCrash)
 
createHIT(params)
 
createHITRaw(params)
Creates a HIT.
 
deleteHIT(hit)
 
Deletes the given hit.
 
deleteHITs(hits)
 
Calls MTurk#deleteHITRaw on the array of hits.
 
extendHIT(hit, moreAssignments, moreSeconds)
 
extendHITRaw(hit, moreAssignments, moreSeconds)
Extends the hit by the given number of assignments (moreAssignments), and the given number of seconds (moreSeconds).
 
Returns the number of dollars in the user's MTurk account.
 
getHIT(hit, getAssignments)
Returns an object representing all of the information MTurk has on the given HIT, including the assigments, and the associated answer data.
 
getHITs(maxPages)
Returns an array of HIT data for all the HITs you currently have on MTurk.
 
Returns a list of HIT Ids of HITs that are ready to be reviewed.
 
grantBonus(assignment, amount, reason)
 
grantBonusRaw(assignment, amount, reason)
Grants a bonus of the given amount to the given assignment for the stated reason.
 
parseHIT(hit)
 
rejectAssignment(assignment, reason)
 
rejectAssignmentRaw(assignment, reason)
Rejects the given assignment, and provides an optional reason.
 
rejectAssignments(assignments, reason)
Calls MTurk#rejectAssignment for each assignment in the given assignments array.
 
sort(a, comparator)
Works just like the JavaScript array sort function, except that this one can perform comparisons in parallel on MTurk by catching the "stop" exception which is thrown when waiting on an MTurk HIT using MTurk#waitForHIT.
 
Tries to determine the type of assignment and return the assignment Id.
 
Tries to determine the type of hit, and return the HIT Id.
 
vote(hit, extractVoteFromAnswer)
Collects multiple votes until a minimum number of necessary votes for a single choice is achieved.
 
Returns information about the hit if it is done (see MTurk#getHIT), and throwing the "stop" exception if it is still in progress.
Class Detail
MTurk()
You probably want to use the global variable mturk.
Method Detail
approveAssignment(assignment, reason)
Calls MTurk#approveAssignmentRaw inside of TraceManager#once.
Parameters:
assignment
reason

approveAssignmentRaw(assignment, reason)
Approves the given assignment, and provides an optional reason.
Parameters:
assignment
reason

approveAssignments(assignments, reason)
Calls MTurk#approveAssignment for each assignment in the given assignments array.
Parameters:
assignments
reason

assertWeCanSpend(money, hits, callbackBeforeCrash)
Parameters:
money
hits
callbackBeforeCrash

createHIT(params)
Calls MTurk#createHITRaw inside of TraceManager#once.
Parameters:
params

createHITRaw(params)
Creates a HIT. params is an object with the following properties: The following properties are optional:
Parameters:
params

deleteHIT(hit)
Calls MTurk#deleteHITRaw inside of TraceManager#once.
Parameters:
hit

deleteHITRaw(hit)
Deletes the given hit. If there are any completed assignments that have not been approved or rejected, then they are approved.
Parameters:
hit

deleteHITs(hits)
Calls MTurk#deleteHITsRaw inside of TraceManager#once.
Parameters:
hits

deleteHITsRaw(hits)
Calls MTurk#deleteHITRaw on the array of hits.
Parameters:
hits

extendHIT(hit, moreAssignments, moreSeconds)
Calls MTurk#extendHITRaw inside of TraceManager#once.
Parameters:
hit
moreAssignments
moreSeconds

extendHITRaw(hit, moreAssignments, moreSeconds)
Extends the hit by the given number of assignments (moreAssignments), and the given number of seconds (moreSeconds).
Parameters:
hit
moreAssignments
moreSeconds

getAccountBalance()
Returns the number of dollars in the user's MTurk account.

getHIT(hit, getAssignments)
Returns an object representing all of the information MTurk has on the given HIT, including the assigments, and the associated answer data. The returned object will have a value called done set to true iff all the pending assigments for this HIT have been completed (unless getAssignments is false).

Note that the answer data structure associated with each assigment is simplified. It is recommended that you print out the result of this function using json, in order to know what it looks like for your specific situation.

Parameters:
hit
getAssignments

getHITs(maxPages)
Returns an array of HIT data for all the HITs you currently have on MTurk.
Parameters:
maxPages

getReviewableHITs(maxPages)
Returns a list of HIT Ids of HITs that are ready to be reviewed. You may optionally specify maxPages, to limit the number of pages of results returned. Each page will have up to 100 reviewable HIT Ids. If maxPages is specified, then the return value will have a property called totalNumResults, which indicates how many HITs are reviewable.
Parameters:
maxPages

grantBonus(assignment, amount, reason)
Calls MTurk#grantBonusRaw inside of TraceManager#once.
Parameters:
assignment
amount
reason

grantBonusRaw(assignment, amount, reason)
Grants a bonus of the given amount to the given assignment for the stated reason.
Parameters:
assignment
amount
reason

parseHIT(hit)
Parameters:
hit

rejectAssignment(assignment, reason)
Calls MTurk#rejectAssignmentRaw inside of TraceManager#once.
Parameters:
assignment
reason

rejectAssignmentRaw(assignment, reason)
Rejects the given assignment, and provides an optional reason.
Parameters:
assignment
reason

rejectAssignments(assignments, reason)
Calls MTurk#rejectAssignment for each assignment in the given assignments array.
Parameters:
assignments
reason

sort(a, comparator)
Works just like the JavaScript array sort function, except that this one can perform comparisons in parallel on MTurk by catching the "stop" exception which is thrown when waiting on an MTurk HIT using MTurk#waitForHIT.
Parameters:
a
comparator

tryToGetAssignmentId(assignment)
Tries to determine the type of assignment and return the assignment Id.
Parameters:
assignment

tryToGetHITId(hit)
Tries to determine the type of hit, and return the HIT Id.
Parameters:
hit

vote(hit, extractVoteFromAnswer)
Collects multiple votes until a minimum number of necessary votes for a single choice is achieved. The hit supplied to this function must have its maxAssignments set to the minimum number of votes necessary for a single choice. This function will add assignments if necessary. This function relies on extractVoteFromAnswer to extract a String representing the choice given an answer data structure (see MTurk#getHIT).

The return value is an object with the following entries:

Parameters:
hit
extractVoteFromAnswer

waitForHIT(hit)
Returns information about the hit if it is done (see MTurk#getHIT), and throwing the "stop" exception if it is still in progress.
Parameters:
hit

Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 08 2010 19:53:20 GMT-0400 (EDT)