ExternalQuestion

Instead of providing a QuestionForm data structure that tells Mechanical Turk how to display your questions and collect answers, you can host the questions on your own web site using an "external" question.

A HIT with an external question displays a web page from your web site in a frame in the Worker's web browser. Your web page displays a form for the Worker to fill out and submit. The Worker submits results using your form, and your form submits the results back to Mechanical Turk. Using your web site to display the form gives your web site control over how the question appears and how answers are collected.

To use an external question with a HIT, you provide a ExternalQuestion data structure as the value of the Question parameter. As with the QuestionForm data structure, an ExternalQuestion is a string value that consists of XML data. This data must conform to the ExternalQuestion schema. See WSDL and Schema Locations for the location of this schema. For more information about using XML data as a parameter or return value, see Using XML Parameter Values.

[Note]Note

You can only use an external question as the question of a HIT. You cannot use an external question with a Qualification test.

The ExternalQuestion data structure is used as a parameter value for the CreateHIT operation.

The ExternalQuestion data structure is a value in a HIT data structure.

All elements in a ExternalQuestion belong to a namespace whose name is identical to the URL of the ExternalQuestion schema document for the version of the API you are using.

The ExternalQuestion data structure has a root element of ExternalQuestion.

The ExternalQuestion element contains the following elements:

NameDescriptionTypeValue
ExternalURL

The URL of your web form, to be displayed in a frame in the Worker's web browser.

Mechanical Turk appends three parameters to this URL: hitId, assignmentId, and workerId. See the Preview Mode and Accept Mode sections below for more information.

Required

A valid URL

FrameHeight

The height of the frame, in pixels.

Required

A number of pixels

The following is an example of a complete ExternalQuestion data structure. Remember that to pass this structure in as the value of a parameter to an operation, XML characters must be escaped as character entities. (See Using XML Parameter Values for more information.)

<ExternalQuestion xmlns="[the ExternalQuestion schema URL]">
  <ExternalURL>http://tictactoe.amazon.com/gamesurvey.cgi?gameid=01523</ExternalURL>
  <FrameHeight>400</FrameHeight>
</ExternalQuestion>

When a Worker attempts to complete a HIT with an external question, the external web site is loaded into a frame in the middle of the screen. The web page at that URL should display a form for the Worker to fill out, and all the information the Worker will need to complete the HIT.

The form on the external web site must post the result data back to Amazon Mechanical Turk using the following URL:

http://www.mturk.com/mturk/externalSubmit

The form must include the assignmentId field that was appended to the URL used to access your form. It should be submitted along with the other form fields submitted by your form, with a name of assignmentId and the same value as was passed to the form. Be sure to spell the field name as it appears here, with the same letters uppercase and lowercase.

[Note]Note

The field names assignmentId and hitId are reserved for special purposes. Your form only needs to submit the assignmentId field. Any data submitted with a field name of "hitId" will be ignored, and will not appear in the results data for the HIT.

The form can submit data to that URL using either the "GET" or "POST" methods. The data the form submits should be name-value pairs in the CGI-style:

The easiest way to post the data in the CGI-style is to use an HTML form on the web page, with the externalSubmit URL as the "action," and either "GET" or "POST" as the "method."

When the Worker submits your form, the form sends the field data to Mechanical Turk using the externalSubmit URL, and Mechanical Turk records the field data as the results of the HIT.

When you retrieve the results using the GetAssignmentsForHIT operation, the field data submitted by your form will appear in the Answer of the Assignment as if each field were a free-text answer. The QuestionIdentifier element of the answer will be the name of the field, and the FreeText element will contain the value.

See the QuestionFormAnswers data format for more information about the format of answer data.

External questions give your application a great deal of power over how Workers submit results for your HITs. To ensure you get good results for your HITs, you should make sure your web server and web pages can provide your Workers with a quality experience.

Because external questions depend on your web server for rendering the question form, both while Workers are previewing HITs and while Workers are completing HITs, your server will need to be engineered for high availability. The Amazon Mechanical Turk web site gets heavy traffic, so your web server will need to be able to respond quickly and correctly when receiving many requests in a short period of time.

[Tip]Tip

Amazon S3 offers high availability hosting of data, accessible via public URLs. You can host your external questions as web pages in Amazon S3, and not have to run your own high availability web server.

Your web site can do many things inside the frame, but eventually it must cause the Worker's browser to load the "externalSubmit" URL in the frame with the results in POST data. The easiest way to do this is with an HTML form whose fields contain the HIT results, with a submit button that the Worker will click. If an external HIT prevents the Worker from submitting results back to Mechanical Turk using the "externalSubmit" mechanism, the Worker may not be able to claim rewards or continue doing work without restarting their session. Amazon Mechanical Turk reserves the right to remove any external HITs that are not functioning properly.

[Tip]Tip

Remember that a QuestionForm can contain Java applets, Flash applications, and blocks of XHTML formatted content. If the capabilities of a QuestionForm meet the needs of your HIT, using a QuestionForm instead of an ExternalQuestion is the best way to ensure that your HIT will work correctly.

Finally, please remember that external questions must meet the Amazon Mechanical Turk Participation Agreement, and otherwise meet Mechanical Turk's standards for appropriate content. Specifically, the Participation Agreement expressly prohibits the use of Amazon Mechanical Turk for advertising or solicitation. If your web site typically displays advertising to visitors, please make sure those advertisements do not appear in your external questions. Amazon Mechanical Turk reserves the right to remove HITs with inappropriate content.